Skip to content

becool14/spendro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# 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

Create .env Files

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

Start Docker Compose to Build and Run Containers

docker-compose up --build

This 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.

Stopping Containers

To stop the containers, press Ctrl + C in the terminal where Docker Compose is running, or use the command:

docker-compose down

If you added new dependencies or made changes to the Dockerfile, restart with --build:

docker-compose up --build

Basic Docker Commands

  • 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 backend to view backend logs.

Troubleshooting

"Address already in use" Error

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.

MongoDB Connection Error

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).

Changes Not Applying After Code Edit

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.

About

Spendro - Empower Your Finances, Achieve Financial Freedom!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors