SpendWise
Personal Finance REST API
A RESTful backend for managing personal financial transactions and expense categories, with validated requests and interactive API docs.
- Python
- FastAPI
- SQLite
- SQLAlchemy
- Pydantic
Overview
SpendWise is a RESTful backend application designed to manage personal financial transactions and expense categories. It is built with FastAPI, uses SQLAlchemy for database access and Pydantic for validation, and stores data in SQLite.
The API exposes CRUD endpoints for transactions and category management, and documents itself through the Swagger/OpenAPI interface that FastAPI generates.
Problem statement
Tracking spending needs a reliable backend before it needs a polished interface: data must be validated on the way in, related correctly (a transaction belongs to a category), and available through a predictable API that any client can use.
SpendWise provides that backend as a documented REST API.
Technical architecture
A request moves through SpendWise in a fixed sequence. FastAPI matches the HTTP method and path to a route function. Before the function runs, Pydantic parses the JSON body into a typed schema and rejects invalid input with a 422 response that lists each error.
The route declares its database session as a dependency. FastAPI's dependency injection calls a get_db generator that opens a SQLAlchemy session, yields it to the route, and closes it in a finally block after the response is produced, so every request gets its own session and no connection is leaked.
The route uses the session to query or write SQLAlchemy models and commits changes. The returned object is serialized through a Pydantic response model, which controls exactly which fields leave the API. FastAPI builds the OpenAPI schema from these type declarations, which powers the Swagger UI at /docs.
Database design
The relational model contains users, transactions, categories, and budgets.
Transactions reference a category through a foreign key, which lets the API group and filter spending by category. A Budget model is part of the schema. SQLAlchemy relationships map these foreign keys to Python attributes, and the database itself stores the links.
Key functionality
- Transaction CRUD endpoints
- Category management
- Relational database models
- Pydantic request and response validation
- SQLAlchemy database sessions
- Dependency injection for database sessions
- Budget database model
- Swagger/OpenAPI documentation
Technologies used
- Python
- FastAPI
- SQLite
- SQLAlchemy
- Pydantic
Technical challenges
Separating schemas from models
SQLAlchemy models describe tables while Pydantic schemas describe API input and output. Keeping them separate means the API contract can change without changing the table, and internal columns are never exposed by accident.
Session lifecycle
Opening one session per request through a dependency, and always closing it, avoids shared state between requests and connection leaks.
More projects
StockFlow
Inventory & Order Management System
A database-driven inventory and order management application for products, categories, stock movements, and customer orders.
- Python
- Django
- SQLite
- Django ORM
- Product and category management
- Product search and filtering
- Stock movement tracking
Developer Portfolio
Full-Stack Django Application
This website: a Django application with admin-managed projects, skills and resume, and a validated, rate-limited contact form.
- Python
- Django
- HTML
- JavaScript
- CSS
- Database-driven profile, skills, projects, and resume content
- Django admin with search, filters, inline screenshots, and publish/unpublish actions
- Project case-study pages with unpublished projects hidden from visitors