This project is a full-stack web application designed to manage a Mobile Shop. It includes:
- A Frontend built with React for a dynamic user interface.
- A Backend built with Node.js and Express for API handling.
- A MongoDB database for data storage.
The frontend is served efficiently using NGINX, ensuring optimal performance and static file handling.
This project allows users to explore mobile products, add them to a cart, and manage their purchases.
Developers can deploy this project seamlessly using Docker and Docker Compose.
- Frontend: React-based dynamic interface for user interaction.
- Backend: RESTful APIs for managing data.
- Database: MongoDB for efficient and scalable data storage.
- Containerization: Docker ensures consistent deployment across environments.
Ensure you have the following installed on your system:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
Start by cloning the project repository:
git clone https://github.com/badhan-saha-bjit/mobile-shop.git
Navigate to the project directory:
cd mobile-shop/
Inside this directory, you'll find two main folders:
- frontend/: Contains the React frontend code.
- backend/: Contains the Node.js backend code.
To connect the frontend to the backend:
- Navigate to the frontend directory:
cd frontend/
- Open the
.env
file to configure the API URL. Replace<localhost>
with the IP address or hostname of your backend:Examplevim .env
.env
file content:# Development environment variables API_URL=http://<localhost>:5000/api
- Save and exit the file.
- Return to the root directory:
cd ..
To persist MongoDB data on your host machine:
- Create a directory for MongoDB data:
mkdir -p /mobileshop/db
- Grant read, write, and execute permissions:
chmod 777 -Rf /mobileshop/db
To build and start all project services:
-
Ensure you're in the root directory:
cd /path/to/mobile-shop
-
Build and start the services:
docker compose up -d
This command will:
- Build Docker images for the frontend and backend.
- Start the containers for the frontend, backend, and MongoDB.
-
Verify that all services are running:
docker ps
- Frontend: http://localhost:3001
- Backend: API endpoints are available at http://localhost:5000
- Database: MongoDB is accessible on
localhost:27017
.
To stop all running containers:
docker compose down
This will remove the containers but keep the data in /mobileshop/db
.
Feel free to fork this repository, submit issues, or create pull requests for improvements.
Enjoy working with the Mobile Shop project! 🚀