A simple yet functional FastAPI project for tracking daily expenses using a SQLite database.
You can create, view, update, and delete expenses and categories, and also retrieve a summary of your spending.
- Track individual expenses
- Categorize your expenses
- Filter expenses by date and category
- Get spending summaries (total amount, average cost, count)
- Fully RESTful API structure with clear schema validation
- Built with modular, production-ready FastAPI architecture
- FastAPI - Web framework
- Pydantic - Data validation
- SQLAlchemy - ORM + SQLite database
- Uvicorn - ASGI server
git clone https://github.com/stargate91/expense-tracker-api.git
cd expense-tracker-apipython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtuvicorn expense_tracker_api.main:app --reloadVisit http://127.0.0.1:8000/docs
Interactive documentation (Swagger UI) is available for testing endpoints.
| Method | Endpoint | Description |
|---|---|---|
| GET | /expenses |
List expenses (with filters) |
| GET | /expenses/{id} |
Get a specific expense |
| POST | /expenses |
Create a new expense |
| PUT | /expenses/{id} |
Update an expense |
| DELETE | /expenses/{id} |
Delete an expense |
| GET | /categories |
List all categories |
| GET | /categories/{id} |
Get a specific category |
| POST | /categories |
Create a new category |
| PUT | /categories/{id} |
Update a category |
| DELETE | /categories/{id} |
Delete a category |
| GET | /summary |
Get summary of expenses (filtered) |
expense_tracker_api/
├── main.py # FastAPI app entry point
├── routes/
│ ├── expenses.py # Expense endpoints
│ ├── categories.py # Category endpoints
│ └── summary.py # Summary endpoint
├── models.py # SQLAlchemy ORM models
├── schemas.py # Pydantic models for validation
├── database.py # SQLite DB connection + Base
├── dependencies.py # Dependency injection (DB session)
├── __init__.py
requirements.txt # Project dependencies
.gitignore
README.md
- Add SQLite + SQLAlchemy integration
- Add user authentication (JWT or session-based)
- Add CSV export
- Create desktop GUI (Tkinter or PyQT)
- Dockerize the application
v0.2 – Switched from in-memory to persistent SQLite DB, added summary endpoint, modularized architecture.
Made by a Python learner to practice REST APIs, FastAPI, and SQLAlchemy.
Thanks for checking it out! 😊