Giter Site home page Giter Site logo

rock10578 / ecommerce_website Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shakilhasan/sabil

0.0 0.0 0.0 14.57 MB

A full-functional (Work in progress now) ecommerce web application that is developed by using MERN (MongoDB, Express.js, React.js, and Node.js)

Home Page: https://sabil.vercel.app

Shell 0.01% JavaScript 94.42% TypeScript 5.42% CSS 0.03% HTML 0.09% Dockerfile 0.03% Procfile 0.01%

ecommerce_website's Introduction

Welcome to the Sabil Project By MERN-STACK

This is a full-functional (Work in progress now) ecommerce web application that is developed by using MERN (MongoDB, Express.js, React.js, and Node.js).

In this repository I will keep adding the best practices we should follow in a MERN project. Also for better UX I am using MUI for the UI.

Below are the sample of a product-shop and list page:

Product List Page

Product List Page

Technology stack

This repository is built on top of Express.js and React.js, however in the implementation detail, we will find other supporting technologies as well.

Client side

  • React - A JavaScript library for building user interfaces
  • Material-UI Design - A design system for enterprise-level products. Create an efficient and enjoyable work experience
  • Testing Library - React Testing Library (Not done yet)

Server side

  • Node.js - evented I/O for the backend
  • Express.js - Fast, unopinionated, minimalist web framework for Node.js
  • MongoDB - The application data platform for NoSQL databases
  • Mongoose - mongoose
  • Swagger - Swagger (Not done yet)
  • Jest - JavaScript testing framework (Not done yet)
  • Super Test - Super test API testing framework (Not done yet)

Details frameworks and packages can be found in the package.json files in server and client directory.

Running the application

This project can be run basically in two ways. One is using docker, other way is to run manually via vscode.

Docker

Depending on the MongoDB hosting option, we choose the appropriate docker-compose file.

Docker compose files

Currently we have two docker-compose files:

  • docker-compose.mongocloud.yml - MongoDB.com hosted cluster
  • docker-compose.yml - Local MongoDB container
Notes
  1. We need to change the MONGODB_CLOUD_URL in docker-compose.mongocloud.yml to the appropriate MongoDB URL.
  2. We need to change the REACT_APP_API_URL in docker-compose.yml to the appropriate API URL. If we want to expose our client to the internet, we need to change the REACT_APP_API_URL to the appropriate API URL. Otherwise keep REACT_APP_API_URL as http://localhost:8008.

Run docker-compose commands

It is expected that the machine must have docker and docker-compose installed. Go to the root of the repository and execute appropriate commands. This will spin up the server and client containers along with the MongoDB container (if we are using local MongoDB server) inside of Docker environment.

Using docker containers with cloud hosted MongoDB

> cd project-root
> docker-compose -f docker-compose.mongocloud.yml build
> docker-compose -f docker-compose.mongocloud.yml up

Using docker containers with local MongoDB

> cd project-root
> docker-compose build
> docker-compose up

The client and server both are up and running and we should see the following screen if we navigate to the client url.

Login screen

  • seed data Go inside of the docker container and execute below commands. These will seed the database with roles, users and products data.

    docker exec -it appserver bash
    npm run db:seed
    npm run db:migrate

    You should see the following output: Product List Page

    Product List Page

    Product List Page

    You should be now login to the application and see the products list.

Visual Studio Code

Prerequisites

  • Node.js : To run npm packages
  • MongoDB : As a database for the application
Steps
  • To run via vscode, we should run the server and client side projects separately, and also make sure mongodb is up and running.

  • Create a .env file inside of the server directory. Add the below entries or change accordingly. You can follow the .env.sample file to see the format.

    DB_HOST=localhost
    DB_PORT=27017
    DB_NAME=sabil
    JWT_SECRET=secret
    JWT_EXPIRES_IN=3600
    PORT=8008
    IS_MONGODB_CLOUD_URL=false
    MONGODB_CLOUD_URL=mongodb+srv:// <USER >: <PASSWORD >@cluster0.abcd.mongodb.net/myFirstDatabase?retryWrites=true
    

Server commands

We assume we run the MongoDB in the docker container.

cd server
npm i
npm run db:up
npm start

Client commands

cd client
nvm use --lts
npm i
npm start

Data seeding

To seed the database, we need to run the following commands in the docker container. You can run these commands in the terminal as well if you are running the server and client outside of the docker environment. I assume we are running appserver in the docker container.

docker exec -it appserver bash
npm run db:seed
npm run db:migrate

You should be able to see the username and password in the /server/setup/users.json file.

๐Ÿ”— Important Links โ—

  • ๐Ÿ”ด Project Live : Sabil

ecommerce_website's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.