How mayankwiz/personal-finance-dashboard works
Project Type and Purpose
• This is a backend API service for a Personal Finance Dashboard.
• It exposes HTTP endpoints (via FastAPI/uvicorn) to manage users, authentication, transactions, and exchange-rate lookups, persisting data in a relational database (SQLite or other).
File Structure
• Top–level files:
• README.md, requirements.txt, alembic.ini, migration scripts → documentation, dependencies, and DB migration tools
• .gitignore, .coveragerc, LICENSE → meta/config
• Main package khazana/ broken into three vertical modules:
a. core/
– apis/ (FastAPI route definitions: auth.py, users.py, main.py)
– database.py (SQLAlchemy engine/session setup)
– models/ (ORM classes)
– serializers/ (Pydantic schemas)
– utils/ (shared constants, auth config)
b. exchange_rates/
– APIs, models, serializers, utils for fetching and storing FX rates
c. transactions/
– APIs, models, serializers, utils for transaction CRUD and dashboard aggregates
• Tests mirror the same structure under tests/.
README for Technical Stack
• Python 3.8+, FastAPI (implied by uvicorn), SQLAlchemy, Alembic for migrations, Pydantic, pytest, flake8, black.
Main Components
a. Client(s) / UI (web/mobile) → HTTP requests
b. API Gateway / FastAPI Server
• Entry point: khazana.core.apis.main:app
• Routers for /auth, /users, /transactions, /dashboard, /exchange_rates
c. Business Logic Layers
• Controllers (API handlers)
• Serializers (Pydantic schemas)
• Utility/Service modules for shared logic
d. Data Persistence
• Relational Database (SQLite or configured RDBMS)
• Access via SQLAlchemy sessions in khazana.core.database
• Alembic migrations to manage schema
e. External Services
• (Optional) External FX rate provider (HTTP REST API) consumed by exchange_rates/utils/exchange_rates.py
Relationships and Interactions
• Within server:
• Router → Controller function → Serializer (validate/serialize) → Utility/Service logic → Database session → ORM Model → Database
• For exchange rates: Service logic → External FX API → Local cache/table → API response
• Database migrations (Alembic) run offline or at startup; not in the request flow
Architectural Patterns & Design Principles
• Layered Architecture:
• Presentation (FastAPI routers)
• Application / Service (utils modules)
• Domain Model (ORM + Pydantic schemas)
• Infrastructure (DB engine, external HTTP client)
• Separation of Concerns: APIs vs. models vs. serializers vs. utils
• Modularity: Three vertical feature modules (core, transactions, exchange_rates)