ElectroShop is an e-commerce application built with the MERN stack (MongoDB, Express, React, Node.js) and Dockerized for seamless deployment. This project includes backend, frontend, and MongoDB services, with automatic database restoration.
- Frontend: React app for the e-commerce interface.
- Backend: Node.js server with Express for handling API requests.
- MongoDB: Database for storing product and user data.
- Dockerized: Run the entire stack with Docker Compose.
Before you begin, ensure you have the following installed on your machine:
git clone https://github.com/vaho-aka/ElectroShop.git
cd ElectroShop
Use Docker Compose to build and start all the services (backend, frontend, and MongoDB).
docker-compose up --build
This will:
- Build the backend and frontend Docker images.
- Start the MongoDB service and restore the initial data from the dump file.
- Launch the backend on
http://localhost:5000
and the frontend onhttp://localhost:5001
.
- Frontend: Open your browser and navigate to
http://localhost:5001
. - Backend: API requests can be made to
http://localhost:5000
.
The docker-compose
setup automatically restores data to the MongoDB database using the dump file in the ./database
directory. Ensure the data is restored by accessing the MongoDB container or checking via your backend API.
ElectroShop/
│
├── Backend/ # Backend service with Node.js and Express
├── Frontend/ # Frontend service with React
├── database/ # MongoDB dump directory
├── data/ # MongoDB data volume
├── docker-compose.yml # Docker Compose configuration file
├── Dockerfile # Backend Dockerfile
└── Frontend/Dockerfile # Frontend Dockerfile
Make sure to configure the following environment variables .env
for the backend:
- Backend (
backend/.env
):MONGO_URI=mongodb://mongodb:27017/ElectroShop PORT = 5000 NODE_ENV = development JWT_SECRET = JWT_EXPIRES_IN = JWT_COOKIE_EXPIRES_IN =
To stop the services, use:
docker-compose down
This project is licensed under the MIT License. See the LICENSE file for details.