Loading repository data…
Loading repository data…
sohamkhore / repository
Production-style Expense Tracker REST API built with FastAPI, PostgreSQL, SQLAlchemy, Docker, JWT Authentication, Alembic and Redis.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A production-inspired backend project built to learn modern backend engineering concepts incrementally—from CRUD APIs to authentication, Docker, Redis caching, and rate limiting.
Each resource belongs to its authenticated owner.
Users can access only:
Cross-user access is completely restricted.
Deletion is prevented while expenses exist under a category to preserve referential integrity.
| Layer | Technology |
|---|---|
| Backend | FastAPI |
| Language | Python 3.13 |
| Database | PostgreSQL |
| ORM | SQLAlchemy |
| Authentication | JWT + Passlib (BCrypt) |
| Cache | Redis |
| Database Migrations | Alembic |
| Containerization | Docker & Docker Compose |
Client Request
│
▼
Check Redis Cache
│
┌─────────┴─────────┐
│ │
Cache Hit Cache Miss
│ │
│ Query PostgreSQL
│ │
│ Store Result in Redis
└──────────────► Return Response
Implemented using Redis Atomic Counters.
Example
GET /expenses
Limit:
200 requests / minute
Protected endpoints require
Authorization: Bearer <access_token>
Every resource belongs to a single authenticated user.
Cross-user access is denied.
Expense_Tracker/
├── alembic/
│
├── app/
│ ├── auth/
│ ├── cache/
│ ├── core/
│ ├── models/
│ ├── rate_limit/
│ ├── routers/
│ ├── schemas/
│ ├── database.py
│ ├── dependencies.py
│ └── main.py
│
├── assets/
├── Dockerfile
├── docker-compose.yml
├── .dockerignore
├── alembic.ini
├── requirements.txt
├── .env.example
└── README.md
| Method | Endpoint |
|---|---|
| POST | /auth/register |
| POST | /auth/login |
| GET | /auth/me |
| Method | Endpoint |
|---|---|
| POST | /categories |
| GET | /categories |
| GET | /categories/{id} |
| PUT | /categories/update_category/{id} |
| DELETE | /categories/{id} |
| Method | Endpoint |
|---|---|
| POST | /expenses/add_expense |
| GET | /expenses |
| GET | /expenses/{id} |
| PUT | /expenses/update_record/{id} |
| PATCH | /expenses/update_record_something/{id} |
| DELETE | /expenses/delete/{id} |
| Method | Endpoint |
|---|---|
| GET | /expenses/get_expense_by_category/{id} |
| GET | /expenses/expense_by_date/{date} |
| GET | /expenses/total_expense_ofdate/{date} |
| GET | /expenses/category_expense/{id} |
Create a .env file using .env.example
DATABASE_URL=postgresql://...
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
CACHE_TTL=3600
RATE_LIMIT_WINDOW=60
CATEGORY_REQUEST_LIMIT=100
EXPENSE_REQUEST_LIMIT=200
AUTH_REQUEST_LIMIT=5
Clone the repository
git clone https://github.com/sohamkhore/expense-tracker-api.git
cd expense-tracker-api
Create virtual environment
python -m venv venv
Activate virtual environment
Windows
venv\Scripts\activate
Install dependencies
pip install -r requirements.txt
Create environment file
cp .env.example .env
Run database migrations
alembic upgrade head
Start the server
uvicorn app.main:app --reload
Build and start containers
docker compose up --build -d
Run migrations
docker compose exec api alembic upgrade head
Stop containers
docker compose down
Swagger UI
http://localhost:8000/docs
This project helped me gain hands-on experience with:
The next versions of this project will include:
After completing this backend series, I plan to build AI-focused backend applications involving:
Soham Khore
B.Tech Computer Engineering
Backend Engineering • FastAPI • PostgreSQL • Redis • Docker • AI Engineering
⭐ If you found this project helpful, consider giving it a star!