Monolithic web application for tracking user expenses with JWT authentication.
- FastAPI
- SQLAlchemy (SQLite)
- Pydantic
- bcrypt
- python-jose (JWT)
- Uvicorn
expense_tracker/
├── app/
│ ├── main.py
│ ├── database.py
│ ├── models.py
│ ├── schemas.py
│ ├── crud.py
│ ├── auth.py
│ └── routers/
│ ├── auth.py
│ ├── users.py
│ ├── expenses.py
│ └── stats.py
├── requirements.txt
└── README.md
- Create virtual environment (recommended)
python -m venv .venv
. .venv/Scripts/activate # Windows PowerShell: .venv\Scripts\Activate.ps1- Install dependencies
pip install -r requirements.txt- Run the server
uvicorn app.main:app --reload- API: http://127.0.0.1:8000
- Swagger UI: http://127.0.0.1:8000/docs
The SQLite database file expense_tracker.db will be created automatically on first launch.
- Registration:
POST /auth/register - Login:
POST /auth/login- Returns:
{ "access_token": "...", "token_type": "bearer" }
- Returns:
- Auth scheme: HTTP Bearer. Use header
Authorization: Bearer <token>
POST /auth/register
{
"email": "alex@example.com",
"password": "12345",
"full_name": "Alex Ivanov"
}POST /auth/login
{
"email": "alex@example.com",
"password": "12345"
}GET /users/me
Authorization: Bearer <JWT_TOKEN>
POST /expenses
Authorization: Bearer <JWT_TOKEN>
{
"category": "Food",
"description": "Lunch",
"amount": 15.0
}GET /expenses
Authorization: Bearer <JWT_TOKEN>
GET /expenses/{id}
Authorization: Bearer <JWT_TOKEN>
DELETE /expenses/{id}
Authorization: Bearer <JWT_TOKEN>
GET /stats/summary
Authorization: Bearer <JWT_TOKEN>
GET /stats/by-date?from=YYYY-MM-DD&to=YYYY-MM-DD
Authorization: Bearer <JWT_TOKEN>
- Update the
SECRET_KEYinapp/auth.pyfor production. - Ready to be split into microservices: auth, users, expenses, stats can be extracted as separate services.