Skip to content

Repository files navigation

FinTrackPy - Personal Finance Tracker API

A comprehensive REST API for managing personal finances, built with Python and FastAPI as a learning project to transition from Node.js/TypeScript to Python development.

🎯 Why This Project?

This project was created as a hands-on learning experience to:

  • Learn Python development coming from a JavaScript/TypeScript background
  • Master FastAPI as a modern Python web framework
  • Understand Python ecosystem including virtual environments, pip, and project structure
  • Practice database design with PostgreSQL and SQLAlchemy ORM
  • Implement authentication using session-based security instead of JWT
  • Build a real-world application that solves actual personal finance tracking needs

🚀 What It Does

FinTrackPy provides a complete backend for personal finance management with:

  • User Management - Registration, authentication, and user profiles
  • Account Tracking - Multiple bank accounts, credit cards, and cash accounts
  • Transaction Management - Income and expense tracking with categorization
  • Budget Management - Set spending limits and track against categories
  • Category System - Organize transactions with custom and default categories

🏗️ Tech Stack

  • Language: Python 3.14
  • Framework: FastAPI (async web framework)
  • Database: PostgreSQL (via Docker)
  • ORM: SQLAlchemy with Alembic migrations
  • Authentication: Session-based with httpOnly cookies
  • Security: bcrypt password hashing
  • Logging: Loguru for structured logging
  • Documentation: Auto-generated Swagger/ReDoc

📊 Database Schema

The API manages five core entities with proper relationships:

Users → Accounts → Transactions ← Categories ← Budgets
  ↓                                    ↑
Sessions                          (User-specific + Shared defaults)
  • Users: Account holders with secure authentication
  • Accounts: Financial accounts (checking, savings, credit, cash)
  • Transactions: Individual financial transactions with amount, date, and notes
  • Categories: Income/expense categorization (user-specific + shared defaults)
  • Budgets: Spending limits per category with time periods
  • Sessions: Secure session management for authentication

🔐 Security Features

  • Session-based authentication (more secure than JWT for web apps)
  • httpOnly cookies to prevent XSS attacks
  • bcrypt password hashing with proper salt rounds
  • Database session storage for easy revocation
  • CSRF protection via samesite cookie attributes

🛠️ Development Setup

# Clone and setup
git clone <repo-url>
cd fintrackpy

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Start PostgreSQL
docker-compose up -d

# Run migrations
alembic upgrade head

# Start development server
uvicorn main:app --reload

Visit http://localhost:8000/docs for interactive API documentation.

🎓 Learning Outcomes

Through building this project, I've gained hands-on experience with:

Python Ecosystem

  • Virtual environments and dependency management
  • Python project structure and module system
  • Type hints and modern Python practices
  • Package management with pip and requirements.txt

FastAPI Framework

  • Async request handling and dependency injection
  • Automatic API documentation generation
  • Pydantic models for request/response validation
  • Middleware and error handling patterns

Database Management

  • SQLAlchemy ORM with relationship modeling
  • Alembic migrations for schema versioning
  • PostgreSQL integration with proper connection pooling
  • Database session management and transactions

API Design

  • RESTful endpoint design and HTTP semantics
  • Modular code organization with separate endpoint files
  • Authentication flow and session management
  • Error handling and status code conventions

DevOps & Tools

  • Docker for development database setup
  • Structured logging with rotation and JSON output
  • Environment variable management
  • Git workflow with proper commit practices

🌟 Key Features Implemented

  • ✅ Complete CRUD operations for all resources
  • ✅ Session-based authentication system
  • ✅ Database migrations with Alembic
  • ✅ Comprehensive error handling and logging
  • ✅ Auto-generated API documentation
  • ✅ Modular, maintainable code architecture
  • ✅ Security best practices implementation

🔮 Future Enhancements

  • API rate limiting and advanced pagination
  • Background job processing for reports
  • Data export functionality (CSV, JSON)
  • Email notifications for budget alerts
  • Performance monitoring and metrics
  • Comprehensive test suite

📚 For Fellow Learners

This repository serves as a practical example of:

  • Transitioning from Node.js/TypeScript to Python
  • Building production-ready APIs with FastAPI
  • Implementing proper database design and relationships
  • Following Python best practices and conventions

Feel free to explore the code, ask questions, or use this as a reference for your own learning journey!


Note: This is a learning project built to understand Python development. While functional, it's designed primarily for educational purposes and hands-on practice.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages