# Spendro MERN Application
This project is a MERN stack application consisting of a `frontend` (React), `backend` (Node.js + Express), and MongoDB (database). The application is containerized using Docker for easier deployment.
## Requirements
To run this project, you need to have:
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
- [Docker Compose](https://docs.docker.com/compose/install/) (already included with Docker Desktop)
> **Note:** Ensure that Docker is running in **Linux Containers** mode (if you are on Windows).
## Project Structure
```plaintext
spendro/
├── backend/ # Backend Node.js/Express
│ ├── controllers/ # Backend controllers
│ ├── db/ # Database setup
│ ├── models/ # Database models
│ ├── routes/ # Backend routes
│ └── server.js # Main server file
├── frontend/ # Frontend React
│ ├── public/ # Public files for React
│ └── src/ # Source files for React
├── docker-compose.yml # Docker Compose file
└── README.md # This file
Make sure to create .env files in the backend and frontend directories. You can use the .env.example files as templates to create the corresponding .env files.
For backend/.env:
MONGO_URI=mongodb://mongo:27017/spendrodb
PORT=5000
For frontend/.env:
REACT_APP_API_URL=http://localhost:5000
docker-compose up --buildThis will build images for the backend, frontend, and MongoDB, and run them in containers.
Open your browser and check the application:
- The frontend (React) will be available at: http://localhost:3000
- The backend (Node.js/Express) will run on port 5000 but can be accessed through the frontend.
To stop the containers, press Ctrl + C in the terminal where Docker Compose is running, or use the command:
docker-compose downIf you added new dependencies or made changes to the Dockerfile, restart with --build:
docker-compose up --build- Start containers:
docker-compose up - Start containers with rebuild:
docker-compose up --build - Stop containers:
docker-compose down - View running containers:
docker ps - Check logs:
docker-compose logs -f <service_name>- For example:
docker-compose logs -f backendto view backend logs.
- For example:
If you see an error like EADDRINUSE, it means the port is already in use. Make sure other services are not using ports 5000 or 3000.
Ensure that the environment variable MONGO_URI points to the correct host (in our case, it's mongo, as that's the name of the service in docker-compose.yml).
If you make changes to the code, they should be automatically recognized due to volumes. If changes are not applying, check the settings in docker-compose.yml.