Skip to content

muneeb21/loan-management-system

Repository files navigation

Loan Management API

An API which facilitates the working of a minimal loan management system

Theme of the API

  • There are three types of users:- Customer, Agent, Admin
  • Customer is the client who makes a request for the loan
  • Agent is the middleman associated with the bank who has certain authourities such as edit loans,
    listing users, and making loan request on behalf of customer
  • Before accessing to these functions an agent has to get the approval by the admin of being an agent
  • Admin is the highest authority who can approve or reject a loan and also the request by agent
  • Customers and agents can Sign up
  • Admin, cutomers and agents can login(agent can login only if agent is approved by the admin)
  • When an agent will signup a request will be sent to the admin for approvalxxxxxx
  • A loan has entities such as principle, interest rate, months to repay, emi and status
  • The value of interest rate would depend on the value of principlexxxxxxxxx
  • The loan can have 3 kinds of status: Approved, New or Rejected

Tech stack used
Nodejs, Express framework, Mongodb

Key modules used
Passport-jwt, Jsonwebtoken, Bcryptjs, Mocha, Chai

Model Schemas

User
Has details about the user such as name, email, password, user type and if user is approved or not
Loan
Has details of principle, interest rate, months to repay, emi, status and history of edited loans

Explaination of key features

  • Only customers and agents can signup
  • Customer will be created in the database on signup
  • When agent would signup a request would to the the admin to approve the agent.
  • Admin and customer are by default approved but not agent
  • Agent can only login after being approved
  • An instance of admin is created initially in the database(see the main index file, uncomment the mentioned code, run "npm start", comment the same code again and run "npm start",later the admin can change password if want to)
  • All the users can update their passwords and its length should be greater than 6
  • Passwords are encrypted before being stored
  • Agents can list all customers and admin can list all users
  • The interest on a loan would depend on the principle
    For range (10000,50000) interest = 3%
    For range (50000,100000) interest = 4%
    Greater than 100000 interest = 5%
  • Loan can be approved or rejected by admin only
  • Only agent can edit a loan if it is still not approved
  • Previous instance of the same loan is pushed inside the history before being edited
  • Loans can be listed according to filter

Routes

/users/signup
/users/login
/users/listUsers
/users/agentRequestList
/users//approveAgent
/users/updatePassword
/users/loan/newLoan
/users/loan/approveLoan
/users/loan/rejectLoan
/users/loan/editLoan
/users/loan/allLoans
/users/loan/loansbyFilter

Set up Project using Docker files

  • Dockerfile.production (This is for main project)
  • Dockerfile.test (This is for running testcases)
  • Create an image for each by command => "docker build -t {your username}/{name of app} {dockerfile name} ."
  • Run the image with command => "docker run -p 49160:8000 -d {your username}/{name of app}"

If can't set it up on docker

Run "npm init", setup the project install the dependencies and run "npm start"


Run unit tests on Node

  • Install the dev dependencies: mocha, chai and chai http
  • Navigate to project directory and run => "npm test"

alt text



Working of API on postman (examples)


Signup
alt text

alt text

Agent Signup

alt text

Loan Request
alt text

alt text

Releases

No releases published

Packages

No packages published