E-Commune is a web application designed for project management within a municipality. It provides tools for managing tasks, projects, and users, facilitating efficient collaboration and oversight of municipal operations.
The application is containerized using Docker and orchestrated with Docker Compose, consisting of a React frontend, a Node.js/Express backend, and a MongoDB database.
- Frontend: React.js, Bootstrap
- Backend: Node.js, Express.js
- Database: MongoDB
- Containerization: Docker, Docker Compose
- Others: Axios (for HTTP requests), JSON Web Tokens (JWT) for authentication
To run this application, you will need the following installed on your system:
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Environment Variables: The application is configured to run with Docker Compose, which handles necessary environment variables (like
MONGO_URIfor the backend to connect to the MongoDB container). If you intend to run the backend service locally outside of Docker (e.g., for development), you would need to ensure a MongoDB instance is accessible and potentially set theMONGO_URIenvironment variable manually (e.g.,export MONGO_URI=mongodb://localhost:27017/E-Commune). However, for Docker-based deployment, this is managed. -
Build and Run the Application: Use Docker Compose to build the images and start the services in detached mode:
docker-compose up -d --build
This command will build the Docker images for the frontend and backend services (if they don't exist or if changes are detected) and then start all defined services.
The application consists of the following services managed by Docker Compose:
- Frontend:
- Accessible at:
http://localhost:80 - Serves the React single-page application.
- Accessible at:
- Backend:
- Accessible at:
http://localhost:5000(for API calls) - Provides the RESTful API for the application.
- Accessible at:
- MongoDB (
mongoservice):- Database service for the application.
- Accessible on
mongodb://localhost:27017/E-Communefrom the host machine if you wish to connect directly (e.g., with MongoDB Compass), due to the port mapping indocker-compose.yml. The backend service connects to it using the service namemongowithin the Docker network.
The project is organized into two main directories:
frontend/: Contains the React.js application code, including components, services, and assets.backend/: Contains the Node.js/Express.js application code, including API routes, controllers, models, and database connection logic.
To stop all running services, use the following command in the project root directory:
docker-compose downThis will stop and remove the containers. Add the -v flag if you also want to remove the named volumes (e.g., mongo-data): docker-compose down -v.
You can view the logs for a specific service using:
docker-compose logs <service_name>For example, to view backend logs:
docker-compose logs backendTo follow the logs in real-time:
docker-compose logs -f <service_name>The application uses Docker volumes to persist data:
- MongoDB Data: User data, project details, tasks, etc., are stored in MongoDB. This data is persisted in a Docker named volume called
mongo-data. This means that even if you stop and remove the MongoDB container, the data will remain intact as long as the volume is not explicitly deleted. - Backend Uploads: Any files uploaded to the backend (e.g., user profile pictures, project attachments) are stored in the
./backend/uploadsdirectory on the host machine, which is mounted into the backend container at/usr/src/app/uploads. This ensures that uploaded files are also persisted.
This README provides a comprehensive guide to setting up, running, and managing the E-Commune application using Docker.