A production-ready backend system for managing financial records with role-based access control, authentication, and analytics dashboard.
This project implements a backend system for managing financial transactions with:
- User and role management (RBAC)
- Secure authentication using JWT
- Financial record CRUD operations
- Dashboard analytics APIs
- Production-level enhancements (pagination, soft delete, rate limiting)
Built using:
- FastAPI
- PostgreSQL
- SQLAlchemy ORM
The system follows a layered architecture:
Route Layer → Service Layer → Repository Layer → Database
- Routes: Handle HTTP requests/responses
- Services: Business logic and orchestration
- Repositories: Database interaction
- Schemas: Data validation and serialization
| Role | Permissions |
|---|---|
| Admin | Full access (users + transactions + dashboard) |
| Analyst | Create & view transactions, access insights |
| Viewer | Read-only access (dashboard + transactions) |
- Centralized via dependency (
require_roles) - Data-level control implemented in service layer (dashboard shaping)
- JWT-based authentication
- Token generation on login
- Secure endpoints using HTTP Bearer token
- Create users (Admin only)
- Update role and active status
- Enforce active/inactive users
Supports:
- Create
- Read
- Update
- Soft Delete
Additional:
- Filtering (date, category, type)
- Pagination
- Search support
Provides:
- Total income
- Total expenses
- Net balance
- Category-wise totals
- Monthly trends
- Recent transactions
- Viewer → basic summary
- Analyst → insights
- Admin → full analytics
- ✅ JWT Authentication
- ✅ Pagination
- ✅ Search support
- ✅ Soft delete
- ✅ Basic rate limiting
- ✅ Unit tests
- ✅ API documentation (Swagger)
- id
- name
- email (unique)
- password (hashed)
- role
- is_active
- id
- user_id (FK)
- amount
- type (income/expense)
- category
- date
- notes
- is_deleted
git clone <repo-url>
cd Finance_Data_Processing
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
Create .env file:
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=your_db_name
SECRET_KEY=your_secret
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
uvicorn app.main:app --reload
http://127.0.0.1:8000/docs
- Each user only accesses their own transactions
- Role-based permissions are strictly enforced
- Dashboard data is scoped per user
- Rate limiting is simplified (in-memory)
| Decision | Reason |
|---|---|
| No Alembic migrations | Simplified setup for assignment |
| Basic rate limiting | Avoid external dependencies (Redis) |
| Enum not enforced in DB for transaction type | Faster implementation, can be improved |
| No async DB usage | Simplicity over premature optimization |
- Async SQLAlchemy support
- Redis-based rate limiting
- Advanced analytics (yearly trends, forecasting)
- Role-based field masking
- Docker deployment
- CI/CD pipeline
- Layered backend architecture design
- RBAC vs authentication separation
- Secure password handling & JWT
- Writing scalable and maintainable APIs
Aditya Raj