Skip to content

LordNayan/nest-loan

Repository files navigation

Loan App

Its a simple loan app built on top of NestJS.

Prerequisite

  • Node.js v18 or higher
  • npm v8 or higher
  • pnpm v8 or higher
  • PostgreSQL

Tech Stack

Server: Node, NestJS

Database: PostgreSQL, TypeORM

Security: JWT, bcrypt

Package Manager: pnpm

Versions: node v18.12.1 (npm v8.19.2) , pnpm 8.6.0

Why this tech stack?

NestJS - It was chosen due to the below reasons,

  > Typescript support - Typescript makes life a lot easier with strict type 
    checking on variables and functions. NestJS is officially supported 
    by the core typescript team and provides out of the box support for latest features.

  > Modular Architecture Pattern - Its easily scalable and easily understandable with 
    its module driven approach

  > Wide support for packages - Jest for testing, Swagger for documentaion,
    JWT for security etc. integrates with NestJS with an ease.
  
  > TypeORM support 

PostgreSQL - It was chosen due to the below reasons,

  > Data is structured.

  > Data is predictable, and is expected to undergo minimal or gradual changes over time.

  > It's a finance-related project, so there will be a lot of transactional queries, 
    which are any day better suited for a SQL database.

Run Locally

Clone the project

  git clone https://github.com/LordNayan/nest-loan

Go to the project directory

  cd nest-loan

Change the .env file by putting your local DB Details

#APPLICATION CONFIG
PORT=3000

#DATABASE CONFIG
DATABASE_HOST=localhost
DATABASE_NAME=postgres
DATABASE_USER=nayanlakhwani
DATABASE_PASSWORD=
DATABASE_PORT=5432

Install node and pnpm (Optional)

After you have installed node,

RUN: sudo npm install -g pnpm

1. Bash Script Way

RUN: ./setup.sh 

2. Normal Way

Install dependencies

RUN: pnpm install

Run Migrations

RUN: pnpm migration:run

Start the server

RUN: pnpm run start

Open Swagger

localhost:3000/docs

Features

  • Role Based API Authorization & JWT Authentication
  • Create loan
  • Approve loan
  • Repay loan
  • Get all loans
  • Get particular loan by id
  • Create new users
  • Login

Additional Instructions

  • Roles:

    1. Admin
    2. User
  • Login - /user/login

    Default users:-
    
    Admin: 
    username - admin, password - 123456
    
    User: 
    username - nayan, password - 123456
    

    After login, you will get a token, copy it and authorize in swagger. It is required by all other apis.

  • Admin APIs: (admin token required)

    1. Create User - /user/create
    2. Approve Loan - /loan/approve

Running Tests

To run tests, run the following command

  unit test:

  RUN: pnpm test:cov

Unit Test

  e2e test:
  
  RUN: pnpm test:e2e

E2E Tests

Support

For support, email [email protected].

About

A basic loan app backend built with NestJS and using REST APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published