Track your expenses, store them securely in S3, and get monthly budget forecasts.
This project was created for training purposes as preparation for a company challenge covering the following topics:
- docker and docker-compose
- model deployment (Amazon EC2)
- AWS S3
- pandas
- pytest
- SQL
- Flask, fastAPI and REST API
Stil missing: Amazon EC2, SQL
- REST API with FastAPI
- ML Forecasting (3-month horizon)
- Docker + Pytest + Pandas
- Add and retrieve personal expenses via API
- Store and read data from AWS S3 (CSV format)
- Machine Learning-based forecasting (Linear Regression)
- Streamlit dashboard for visual insights
- Docker-ready for deployment
.envfile for secure configuration
expense-tracker/
├── app/
│ ├── main.py # FastAPI app
│ ├── ml_model.py # Forecasting logic
│ ├── s3_handler.py # Save/load expenses in S3
│ ├── db.py # Save/load expenses in local CSV
│ ├── schemas.py # Pydantic models
├── streamlit_app/
│ └── dashboard.py # Optional frontend
├── tests/
│ └── test_app.py # testing usecases
├── models/
│ └── model_LR.pkl # Models saved
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── README.md
POST /add_expense/ → Add a new expense
GET /expenses/ → Get all expenses
GET /forecast/ → Monthly forecast
git clone https://github.com/Nynor-code/personal-expense-tracking.git
cd personal-expense-trackingpython -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windowspip install -r requirements.txtcp .env.example .envUpdate it with your AWS credentials.
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=your_region
S3_BUCKET_NAME=your_bucket
S3_KEY=expenses.csvOpen two terminals
python src/main.py # or make apistreamlit run src/dashboard.py # or make streamlitpytest # or make testdocker build -t expense-tracker .
docker run -p 5000:5000 --env-file .env expense-trackerCreated by Nynor Pires
MIT License