Final Push

This commit is contained in:
root 2026-04-01 00:51:18 +02:00
parent 241a4a912c
commit d9a1697bd1

262
README.md
View File

@ -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
---
## Persistent Storage
The application uses Docker volumes to preserve data across container restarts:
- `mongo-data` stores database records
- `uploads/` stores user-uploaded files
Data is retained even after stopping the application.
---
## How to Run
### 1. Prepare the application
```bash
./prepare-app.sh
```
### 2. Start the application
```bash
./start-app.sh
```
Once running, open the following in your browser:
- Application: `http://147.232.204.210:8080`
- Database UI: `http://147.232.204.210/:8081`
### 3. Stop the application
```bash
./stop-app.sh
```
### 4. Remove the application
```bash
./remove-app.sh
```
---
## Application Workflow
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.
---
## Features
- Create and delete notes
- Create notes
- Delete notes
- Upload files
- View and download uploaded files
- Persistent storage via Docker volumes
- List uploaded files
- Download files
- Persistent data storage
------------------------------------------------------------------------
## 5. Technologies Used
- Docker
- Docker Compose
- Node.js (Express)
- MongoDB
- Nginx
- HTML, CSS, JavaScript
------------------------------------------------------------------------
## 6. Ports and Services
| Service | Port | Description |
|----------------|------|-----------------|
| Frontend | 8080 | Web interface |
| Backend | 3000 | API server |
| Mongo Express | 8081 | Database UI |
------------------------------------------------------------------------
## 7. Database Credentials
The MongoDB database is configured with the following credentials:
- **Username:** admin
- **Password:** pass
These credentials are used by Mongo Express to connect to the MongoDB service.
------------------------------------------------------------------------
## 8. Persistent Storage
The application uses Docker volumes:
- mongo-data → stores database data
- uploads → stores uploaded files
These ensure that data is not lost when containers restart.
------------------------------------------------------------------------
## 9. Network Requirement (IMPORTANT)
⚠️ This application is hosted on a university virtual machine.
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.
------------------------------------------------------------------------