This project is a Django-based application that handles user registrations, loan applications, EMI payments, and billing processes. It includes various Django models, views, and Celery tasks for background processing.
- Python 3.x
- Django
- Celery
- Redis
-
Clone the repository:
git clone https://github.com/shashank-23002/Credit-Service cd Brightmoney
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
-
Apply the migrations:
python manage.py makemigrations python manage.py migrate
-
Run the development server:
python manage.py runserver
Ensure that your settings.py
file has the necessary configurations for Celery:
# settings.py
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'UTC'
-
Ensure Redis is installed and running on your system. You can start Redis using:
redis-server
-
Start the Celery worker:
celery -A Brightmoney worker --loglevel=info
-
Start the Celery task asynchronously:
python manage.py import_transactions
-
Setup Cron Job :
python manage.py billing
aadhar_id
: CharField (Primary Key)name
: CharFieldemail
: EmailFieldannual_income
: DecimalFieldcredit_score
: IntegerFieldcreated_at
: DateTimeField
user_id
: ForeignKey(User)loan_type
: CharFieldloan_amount
: DecimalFieldinterest_rate
: DecimalFieldterm_period
: IntegerFielddisbursement_date
: DateFieldprincipal_balance
: DecimalFieldis_closed
: BooleanFieldemi_dates
: TextField
loan
: ForeignKey(Loan)date
: DateFieldamount_due
: DecimalFieldis_paid
: BooleanField
user
: ForeignKey(User)date
: DateFieldamount
: DecimalFieldtransaction_type
: CharField
user
: ForeignKey(User)billing_date
: DateFieldmin_due
: DecimalFielddue_date
: DateField
loan
: ForeignKey(Loan)date
: DateFieldamount
: DecimalField
URL: api/register-user/
Method: POST
Request JSON:
{
"aadhar_id": "8bac0a2d-f31a-4fc4-a5d2-2e86b379915b",
"name": "John Doe",
"email": "john.doe@example.com",
"annual_income": "500000.00"
}
Response JSON:
{
"aadhar_id": "8bac0a2d-f31a-4fc4-a5d2-2e86b379915b"
}
URL: api/apply-loan/
Method: POST
Request JSON:
{
"user_id": "8bac0a2d-f31a-4fc4-a5d2-2e86b379915b",
"loan_amount": "2000",
"interest_rate": "5",
"term_period": 6,
"loan_type": "CREDIT_CARD",
"disbursement_date": "2024-06-14"
}
Response JSON:
{
"loan_id": 3,
"due_dates": [
{"date": "2024-07-14", "amount_due": "338.21"},
{"date": "2024-08-14", "amount_due": "338.21"},
]
}
URL: api/make-payment/
Method: POST
Request JSON:
{
"loan_id": 1,
"amount": "420.00"
}
Response JSON:
{
"message": "Payment recorded successfully."
}
URL: api/get-statement/
Method: GET
Query Parameters: loan_id
Example: api/get-statement/?loan_id=1
Response JSON:
{
"error": null,
"past_transactions": [
{"date": "2024-06-14", "amount_paid": "420.00"},
...
],
"upcoming_transactions": [
{"date": "2024-08-13", "amount_due": "321.85"},
{"date": "2024-09-12", "amount_due": "321.85"},
...
]
}