Engineered a production-style Finance Management REST API featuring 15+ endpoints for authentication, income, expense, and transaction management. Integrated JWT Authentication, Role-Based Access Control (RBAC), SQLAlchemy ORM, and secure password hashing to build a scalable and secure backend. Designed modular CRUD services, request validation, and protected API routes following RESTful architecture and backend development best practices.
- User Registration & Login (JWT authentication)
- Password hashing using bcrypt
- Token-based authorization (Bearer token)
| Role | Permissions |
|---|---|
| Admin | Full control (users + records) |
| Analyst | Manage & view financial records |
| Viewer | View dashboard only |
- Only one Admin allowed initially
- Admin can create users
- Inactive users are restricted from access
- Create user (Admin only)
- View all users
- Activate / Deactivate users
- Prevent duplicate user registration
- β Add record (income / expense)
- π View records
- βοΈ Update record
- β Delete record
- π Filter records by:
- Type (income / expense)
- Category
- Date (optional)
- Total Income
- Total Expense
- Net Balance
- Category-wise totals
- Monthly trend analysis
- Enum validation (income / expense only)
- Input validation (amount > 0, email format)
- Role-based route protection
- Clean API documentation using Swagger
- Framework: FastAPI
- Database: SQLite
- ORM: SQLAlchemy
- Authentication: JWT (python-jose)
- Password Hashing: passlib (bcrypt)
app/ β βββ api/ # Routes β βββ auth_routes.py β βββ users.py β βββ record_routes.py β βββ models/ # DB Models βββ schemas/ # Pydantic Schemas βββ services/ # Business Logic βββ core/ # Security & Config βββ db/ # Database setup
# Install dependencies
pip install -r requirements.txt
# Run server
uvicorn app.main:app --reload
---
## π API Documentation
After running server:
http://127.0.0.1:8000/docs
Use Swagger UI to:
- Register
- Login
- Authorize (Bearer Token)
- Test APIs
---
## β οΈ Important Notes
1.Only first registered user becomes Admin
2.All passwords are securely hashed
3.Duplicate users are not allowed
## πAuthentication Flow
1.Register user
2.Login β get JWT token
3.Click Authorize in Swagger
4.Paste token
5.Access protected routes
π Example Use Case -
Track income and expenses
Analyze spending patterns
Monitor monthly trends
Manage users in organization
## Author
Atharv Gupta