This is a basic full-stack CRUD application demonstrating on how to set up a Multi-service monolithic architectured application using Docker. The app features a React frontend (built with Vite), a Node.js backend (Express), MongoDB for data storage, Redis for caching, and an Nginx reverse proxy to handle requests. This project is a demonstration of how to orchestrate multiple services using Docker Compose.
multi-service-app/
│── frontend/ # React (Vite) App
│── backend/ # Node.js + Express API
│── database/ # MongoDB (Docker volume)
│── cache/ # Redis setup
│── proxy/ # Nginx reverse proxy
│── docker-compose.yml
│── .env # Environment variables
- Frontend: React + Vite for a fast, modern front-end development experience.
- Backend: Node.js with Express for handling API requests.
- MongoDB: For persistent database storage (user details: name, email).
- Redis: For caching user data to improve performance.
- Nginx: Reverse proxy for routing traffic to the correct service.
- Docker Compose: To manage multi-container applications efficiently.
- React with Vite (Frontend)
- Node.js + Express (Backend)
- MongoDB (Database)
- Redis (Cache)
- Nginx (Reverse Proxy)
- Docker (Containers)
- Docker Compose (Orchestration)
git clone https://github.com/<your-username>/docker-multi-service-app.git
cd docker-multi-service-appCreate a .env file in the root of the backend directory with the following:
MONGO_URI=mongodb://admin:password@database:27017/mydatabase?authSource=admin
REDIS_URL=redis://cache:6379To build and start all services (frontend, backend, MongoDB, Redis, Nginx) using Docker Compose:
docker-compose up --buildThe application should be accessible at:
- Frontend:
http://localhost:3000 - API:
http://localhost:5000/api/users - Nginx Proxy:
http://localhost
-
Create a User:
- Endpoint:
POST /api/users - Payload:
{ "name": "John Doe", "email": "john@example.com" }
- Endpoint:
-
Get All Users:
- Endpoint:
GET /api/users
- Endpoint:
-
Update a User:
- Endpoint:
PUT /api/users/:id - Payload:
{ "name": "John Smith", "email": "johnsmith@example.com" }
- Endpoint:
-
Delete a User:
- Endpoint:
DELETE /api/users/:id
- Endpoint:
-
Frontend (React + Vite):
frontend/src/App.jsxhandles the UI and makes API requests to the backend.
-
Backend (Node.js + Express):
backend/server.jsprovides API routes for CRUD operations using MongoDB.
-
MongoDB:
- Stores user data (name, email).
-
Redis:
- Caches the list of users for 60 seconds to optimize read performance.
-
Nginx:
- Acts as a reverse proxy, routing traffic between the frontend and backend.
The services are defined in the docker-compose.yml file:
- Frontend: React app running on port
3000. - Backend: Node.js API running on port
5000. - MongoDB: Exposed on port
27017. - Redis: Exposed on port
6379. - Nginx: Exposed on port
80, acting as a reverse proxy.
If you'd like to contribute to this project, please fork the repository and use a feature branch. Pull requests are warmly welcome.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a pull request
Distributed under the MIT License. See LICENSE for more information.
Special thanks to all the open-source libraries and tools used in this project. and this project is based on the DevOps Roadmap's Project