diff --git a/README.md b/README.md index 1ef2380..baf1291 100644 --- a/README.md +++ b/README.md @@ -1,112 +1,192 @@ # Docker Multi-Service Notes Application -## Project Overview +## 1. Introduction -This project is a multi-container web application deployed using Docker. It demonstrates how different services can work together using containerization. +This project is a multi-container web application deployed using Docker. +It demonstrates how multiple services such as frontend, backend, +database, and file storage can be containerized and orchestrated using +Docker Compose. -The application allows users to: +The system follows a microservices architecture where each service runs +independently and communicates through a Docker network. -- Add and delete notes -- Upload files -- View and download uploaded files +------------------------------------------------------------------------ ---- +## 2. Objectives -## Architecture +- Deploy a complete web application using Docker containers +- Use multiple services (frontend, backend, database) +- Enable communication between services +- Implement persistent storage using Docker volumes +- Provide scripts for managing the application lifecycle + +------------------------------------------------------------------------ + +## 3. System Architecture The application consists of the following services: -**Frontend (Nginx)** -Serves static HTML, CSS, and JavaScript files. Accessible via browser. +### 3.1 Frontend (Nginx) -**Backend (Node.js + Express)** -Handles API requests and manages notes and file uploads. +- Serves static files (HTML, CSS, JavaScript) +- Provides user interface for interacting with the system -**MongoDB** -Stores notes data and uses a persistent Docker volume. +### 3.2 Backend (Node.js + Express) -**Mongo Express** -Provides a web interface to view and manage database data. +- Handles API requests +- Implements business logic +- Manages notes and file uploads ---- +### 3.3 MongoDB -## Technologies Used +- NoSQL database for storing notes +- Uses persistent storage -- Docker and Docker Compose -- Node.js with Express -- MongoDB (NoSQL database) -- Nginx (web server) -- HTML, CSS, and JavaScript +### 3.4 Mongo Express ---- +- Web interface to view and manage database data -## Service Ports +------------------------------------------------------------------------ -| Service | Port | -|---------------|------| -| Frontend | 8080 | -| Backend | 3000 | -| Mongo Express | 8081 | +## 4. Features ---- +- Create notes +- Delete notes +- Upload files +- List uploaded files +- Download files +- Persistent data storage -## Persistent Storage +------------------------------------------------------------------------ -The application uses Docker volumes to preserve data across container restarts: +## 5. Technologies Used -- `mongo-data` stores database records -- `uploads/` stores user-uploaded files +- Docker +- Docker Compose +- Node.js (Express) +- MongoDB +- Nginx +- HTML, CSS, JavaScript -Data is retained even after stopping the application. +------------------------------------------------------------------------ ---- +## 6. Ports and Services -## How to Run +| Service | Port | Description | +|----------------|------|-----------------| +| Frontend | 8080 | Web interface | +| Backend | 3000 | API server | +| Mongo Express | 8081 | Database UI | -### 1. Prepare the application +------------------------------------------------------------------------ +## 7. Database Credentials -```bash -./prepare-app.sh -``` +The MongoDB database is configured with the following credentials: -### 2. Start the application +- **Username:** admin +- **Password:** pass -```bash -./start-app.sh -``` +These credentials are used by Mongo Express to connect to the MongoDB service. -Once running, open the following in your browser: +------------------------------------------------------------------------ -- Application: `http://147.232.204.210:8080` -- Database UI: `http://147.232.204.210/:8081` +## 8. Persistent Storage -### 3. Stop the application +The application uses Docker volumes: -```bash -./stop-app.sh -``` +- mongo-data → stores database data +- uploads → stores uploaded files -### 4. Remove the application +These ensure that data is not lost when containers restart. -```bash -./remove-app.sh -``` +------------------------------------------------------------------------ ---- +## 9. Network Requirement (IMPORTANT) -## Application Workflow +⚠️ This application is hosted on a university virtual machine. -1. The user interacts with the frontend in a browser. -2. The frontend sends API requests to the backend. -3. The backend processes the requests and communicates with MongoDB. -4. MongoDB stores or retrieves the relevant data. -5. Mongo Express provides a separate interface to inspect database content directly. +To access the application, you must: ---- +- Be connected to the **Tuke university network**, OR +- Use a **Tuke VPN connection** + +Without VPN/network access, the application URLs may not be reachable. + +------------------------------------------------------------------------ + +## 10. Application Workflow + +1. User accesses frontend via browser +2. Frontend sends requests to backend API +3. Backend processes requests +4. Backend interacts with MongoDB +5. MongoDB stores/retrieves data +6. Mongo Express allows database visualization + +------------------------------------------------------------------------ + +## 11. Scripts + +### 11.1 Prepare Application + + ./prepare-app.sh + +- Builds Docker images +- Creates volumes and network + +### 11.2 Start Application + + ./start-app.sh + +- Starts all containers +- Application available at: + - http://147.232.204.210:8080 + - http://147.232.204.210:8081 + - http://147.232.204.210:3000 + - http://147.232.204.210:3000/notes + + +### 11.3 Stop Application + + ./stop-app.sh + +- Stops all containers +- Data remains intact + +### 11.4 Remove Application + + ./remove-app.sh + +- Removes containers, volumes, and images + +------------------------------------------------------------------------ + +## 12. Docker Configuration + +The application is configured using docker-compose.yml, where: + +- Each service runs in its own container +- Services communicate using Docker networking +- Volumes are used for persistent storage + +------------------------------------------------------------------------ + +## 13. Key Concepts Demonstrated + +- Multi-container Docker architecture +- Service isolation and communication +- Persistent storage using volumes +- RESTful API design +- Static file serving + +------------------------------------------------------------------------ + +## 14. Conclusion + +This project demonstrates how to deploy a scalable web application using +Docker containers. It highlights the importance of modular architecture, +persistent storage, and service communication. + +------------------------------------------------------------------------ -## Features -- Create and delete notes -- Upload files -- View and download uploaded files -- Persistent storage via Docker volumes