Skip to content

ZEN5072/ExpenseTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker (FastAPI + SQLite)

Monolithic web application for tracking user expenses with JWT authentication.

Tech Stack

  • FastAPI
  • SQLAlchemy (SQLite)
  • Pydantic
  • bcrypt
  • python-jose (JWT)
  • Uvicorn

Project Structure

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

Setup

  1. Create virtual environment (recommended)
python -m venv .venv
. .venv/Scripts/activate  # Windows PowerShell: .venv\Scripts\Activate.ps1
  1. Install dependencies
pip install -r requirements.txt
  1. Run the server
uvicorn app.main:app --reload

The SQLite database file expense_tracker.db will be created automatically on first launch.

Auth

  • Registration: POST /auth/register
  • Login: POST /auth/login
    • Returns: { "access_token": "...", "token_type": "bearer" }
  • Auth scheme: HTTP Bearer. Use header Authorization: Bearer <token>

Example Requests

Register

POST /auth/register
{
  "email": "alex@example.com",
  "password": "12345",
  "full_name": "Alex Ivanov"
}

Login

POST /auth/login
{
  "email": "alex@example.com",
  "password": "12345"
}

Get current user

GET /users/me
Authorization: Bearer <JWT_TOKEN>

Create expense

POST /expenses
Authorization: Bearer <JWT_TOKEN>
{
  "category": "Food",
  "description": "Lunch",
  "amount": 15.0
}

List expenses

GET /expenses
Authorization: Bearer <JWT_TOKEN>

Get expense by id

GET /expenses/{id}
Authorization: Bearer <JWT_TOKEN>

Delete expense

DELETE /expenses/{id}
Authorization: Bearer <JWT_TOKEN>

Summary by category

GET /stats/summary
Authorization: Bearer <JWT_TOKEN>

Total by date range

GET /stats/by-date?from=YYYY-MM-DD&to=YYYY-MM-DD
Authorization: Bearer <JWT_TOKEN>

Notes

  • Update the SECRET_KEY in app/auth.py for production.
  • Ready to be split into microservices: auth, users, expenses, stats can be extracted as separate services.

About

PAD_lab1 App to help track finances

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages