Bright - Backend - Engineer - Intern - Assignment - Backend
Bright - Backend - Engineer - Intern - Assignment - Backend
Dear Candidate,
Thank you for your interest in Bright. As part of our hiring process, you shall be required to submit the assessment
below. Please note that the deadline to submit your responses is in the next 48 Hours.
Problem Statement
You will be tasked with crafting a Credit Service designed to facilitate efficient lending by a Loan provider to users. This
Credit Service should encompass the following key functionalities:
● Disbursement (Lend money to the user against his/her credit card so that he/she can pay off the debt again
the credit card)
● REPAYMENT (Receiving Payments from the user, which can either clear the minimum due of a user or reduce
the principal amount if the payment exceeds the minimum due).
● BILLING, for each user billing needs to be done each month till the time the account is not closed for that user,
and an Account can be closed only when the user has a principal balance of $0 and there is no interest
amount remaining against that user’s loan.
○ Keep the billing date 30 days after the user’s account is created
MIN DUE FORMULA: (Principal Balance*3%) + (APR accrued on a daily basis for that billing cycle)
Min due represents the amount that the user needs to pay for a billing cycle, it’s the same as the EMI amount for each
month.
Daily apr accrued formula = round(apr / Decimal('365'), 3)
Billing for a user also needs to be done, for each billing cycle you need to map the PAYMENT received against that BILL
for a user. The BILLING cycle duration is a month, after each month BILLING needs to be done again for a user.
Rules to be followed for BILLING:
● Interest needs to be accrued on a daily basis. On the billing day, the interest accrued for each day will be used
to calculate the min_due amount.
● The due date will be 15 days from the billing date, for example, if the billing date is the 2nd of each month then
the due date will be the 17th of that month.
Your assessment will be evaluated on various criteria, including but not limited to model creation, authentication
management, API development, serialization and deserialization, workflow handling, adherence to object-oriented
programming principles, code clarity, project execution, Async task handling, or Celery Task handling.
Kindly assign a name to your project. Be aware that strict plagiarism checks will be enforced, and any instances of
copying will result in disqualification.
Additionally, a .csv file containing details of user savings account transactions will be furnished with the application.
Field Definitions:
● AADHAR ID: A unique user identifier
● Date: The date of the transaction
● Amount: The transaction amount
● Transaction_type: This can be DEBIT or CREDIT, where CREDIT represents an amount added to the account
and vice versa. Please note that sample data is included, and you can supplement it to validate your
processes.
Required Functionalities:
● Implement a POST API View for registering a user who is availing the loan.
● Endpoint: /api/register-user/
● Response Codes: 200 (Success), 400 (Error)
● View: Create a user with the following details:
○ Name
○ Email
○ Annual Income
● Initiate an asynchronous Celery task through this API to calculate the user's credit score.
● The credit score calculation should be conducted using the transactions from the provided CSV file.
● The credit score should fall within a range of 300 to 900; it cannot be fractional.
Fractional.
In calculating the credit score, the total account balance, which is determined as the sum of (CREDIT - DEBIT) across all
transactions for a specific user, follows these rules:
● If the value is greater than or equal to 1,000,000 (Rs. 10,00,000), the credit score reaches its maximum value of
900.
● Conversely, if the value is less than or equal to 10,000 (Rs. 1,00,000), the credit score assumes its minimum
value of 300.
● For any intermediate account balance value, the credit score adjusts by 10 points for every Rs. 15,000 change
in the account balance.
● As an example, for an account balance of Rs. 5,68,450, the corresponding credit score would be 670.
Request Fields
● Aadhar ID: Unique User Identifier already generated and the same is given in csv. ● name
● email_id
● annual_income
Response Fields
● Error: None in case of success. Error string in case ingestion was not successful stating failure reason
● unique_user_id (UUID value) generated for the given User
POST API View to apply & initiate a Loan again Credit Card to pay off the debt of a credit card
Endpoint: /api/apply-loan/
EMIs calculation
● Interest begins accruing from the day following the loan disbursal.
● All due amounts must be repaid within the specified tenure.
● All Equated Monthly Installments (EMIs) should have identical amounts, except for the final EMI, which may be
less than the others.
● It's important to note that the last EMI covers all outstanding dues.
● Each EMI includes a portion of the principal amount due, calculated according to the formula provided for the
minimum due.
● Interest is calculated on the principal amount for the respective month.
● The EMI should not exceed 20% of the user's monthly income.
● The interest rate must be equal to or greater than 12%.
● The cumulative interest earned for a month should surpass Rs.50.
● All EMIs will be due on scheduled dates.
Request Fields
● unique_user_id: A distinctive User Identifier (UUID)
● loan_type: The type of loan, as previously mentioned
● loan_amount: The loan amount in rupees
● interest_rate: The interest rate as a percentage
● term_period: The duration for repayment in months
● disbursement_date: The date of loan disbursal
Response Fields
● Error: None in the event of a successful operation. In case of an unsuccessful operation, an error string will
be provided, indicating the appropriate reason.
● Loan_id: A unique identifier for identifying the initiated loan.
● Due_dates: A list comprising objects specifying EMI dates and corresponding amounts. Each object
includes:
○ Date: The EMI date
○ Amount_due: The amount due on that date.
Request fields
● Loan_id: Loan for which details are to be fetched
Response fields
● Error: None if no error. Error String in case of failure
● Past_transactions: Empty list for no past transactions. For valid transactions, each object contains:
- Date
- Principal
- Interest
- Amount_paid
- Upcoming_transactions: List containing objects of EMI dates and amount. Each object contains:
- Date: EMI date
- Amount_due: Amount due on that date.