A robust Python-based finance tracking system built with FastAPI and SQLAlchemy (SQLite). This project demonstrates clean architecture, role-based access control (RBAC), and automated financial reporting.
- User Management: Authentication using JWT tokens.
- Role-Based Access Control:
Admin: Full CRUD access to all transactions and user management.Analyst: View all records and access detailed financial summaries.Viewer: Can view their own transactions and personal financial summaries.
- Financial Records: Store transactions with amount, type, category, and date.
- Summaries & Analytics:
- Total Income / Expenses / Balance.
- Category-wise breakdown.
- Monthly trends.
- Recent activity tracking.
- Modern API: Interactive documentation with FastAPI/Swagger.
- Framework: FastAPI
- Database: SQLite (SQLAlchemy ORM)
- Security: JWT (Jose), Bcrypt
- Validation: Pydantic v2
.
├── app/
│ ├── api/ # API Route handlers
│ ├── core/ # Settings and constants
│ ├── db/ # Database session logic
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas (validation)
│ └── services/ # Business logic
├── tests/ # Pytest suite
├── scripts/ # Seeding and utility scripts
├── main.py # Application entry point
└── requirements.txt # Dependencies
-
Install Dependencies:
pip install -r requirements.txt
-
Seed the Database:
python scripts/seed_db.py
This creates test users:
admin,analyst, andsayam(default passwords arerole123, e.g.,admin123). -
Run the Application:
uvicorn main:app --reload
-
Access Documentation: Visit
http://127.0.0.1:8000/docsto explore the REST API.
- Only users with the
adminrole can create, update, or delete transaction records (as per 'Admin can manage records' requirement). Viewercan only see their own transactions to ensure privacy.Analysthas read access to the entire system's financial health but cannot modify entries.