This Loan Management API handles loan applications, repayment schedules, and tracking for users. The API provides secure authentication via JWT, allows users to manage their loans, and enables administrators to oversee transactions. The project demonstrates expertise in API development, authentication, database design, and follows best practices for scalability, security, and maintainability.
- Django REST Framework (DRF): For building the API endpoints
- PostgreSQL: As the primary relational database
- JWT Authentication: For securing API endpoints with token-based auth
- Swagger & OpenAPI: For API documentation and visualization
- Python-dateutil: For advanced date manipulation
- Django-environ: For environment variable management
- Django CORS headers: For cross-origin resource sharing
- JWT Authentication: Secure endpoints with access and refresh tokens
- User Management: Register, login, and profile management
- Loan Application & Lifecycle: Apply, approve/reject, and track loans
- Repayment Schedule: Automatic generation of payment schedules with interest calculation
- Loan Repayment Tracking: Process payments and update loan balances
- Role-Based Access Control: Different permissions for regular users and admins
- CORS Support: Cross-origin resource sharing for frontend integration
- POST /api/auth/register/: Register a new user
- POST /api/auth/login/: User login with JWT token response
- POST /api/auth/logout/: Logout and blacklist user token
- POST /api/token/refresh/: Refresh an expired access token
- GET /api/auth/user/: Get authenticated user's profile
- GET /api/loans/: List all loans for the authenticated user
- POST /api/loans/: Apply for a new loan
- GET /api/loans/{loan_id}/: Get details of a specific loan
- GET /api/loans/{loan_id}/approve/: Approve a loan (admin function)
- GET /api/loans/{loan_id}/reject/: Reject a loan (admin function)
- GET /api/loans/{loan_id}/schedule/: Get the repayment schedule for a loan
- POST /api/repayments/{loan_id}/: Make a repayment towards a loan
- Python 3.8+
- PostgreSQL database
- Git
Ensure you have Docker installed, if not follow their installation guide Docker Installation
docker build -t loan-service .The project will run at localhost:8000, add the -d tag to run in the background.
docker run --name loan-service -p 8000:8000 loan-servicedocker psdocker exec -it loan-service python manage.py changepassword adminAccess the admin page at http://127.0.0.1:8000/admin or localhost:8000/admin
- username:
admin - password:
(Your set password from the above command)
docker stop loan-servicegit clone https://github.com/BlacAc3/loan-api.git
cd loan-apipython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file with the following variables:
SECRET_KEY=your_secret_key
DATABASE_URL=postgres://username:password@localhost:5432/loan_db
python manage.py migratepython manage.py createsuperuserpython manage.py runserverAccess the API at http://127.0.0.1:8000/ or localhost:8000.
python manage.py testFor detailed API documentation, please refer to:
This project is licensed under the MIT License. See the LICENSE file for details.