|
| 1 | +# Loan Management System |
| 2 | + |
| 3 | +A full-stack application for managing loans, including user onboarding, loan creation, and EMI calculations. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- User registration with validation (PAN, Aadhar, GSTIN, UDYAM) |
| 8 | +- Loan creation with EMI calculations |
| 9 | +- Loan ledger view |
| 10 | +- CSV export of loan schedule |
| 11 | +- Responsive UI using Material-UI |
| 12 | + |
| 13 | +## Tech Stack |
| 14 | + |
| 15 | +- Frontend: React.js (Vite) |
| 16 | +- Backend: Node.js, Express |
| 17 | +- Database: MongoDB |
| 18 | +- UI Library: Material-UI |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Node.js (v14 or higher) |
| 23 | +- MongoDB (local or Atlas URI) |
| 24 | +- npm or yarn |
| 25 | + |
| 26 | +## Installation & Setup |
| 27 | + |
| 28 | +### 1. Clone the repository |
| 29 | +```bash |
| 30 | +git clone https://github.com/CRYPTOcoderAS/LMS-BE |
| 31 | +``` |
| 32 | + |
| 33 | +### 2. Backend Setup |
| 34 | +```bash |
| 35 | +npm install |
| 36 | +``` |
| 37 | + |
| 38 | +Create a `.env` file in the server directory: |
| 39 | +```env |
| 40 | +PORT=5000 |
| 41 | +MONGODB_URI= |
| 42 | +``` |
| 43 | + |
| 44 | +Start the server: |
| 45 | +```bash |
| 46 | +npm start |
| 47 | +``` |
| 48 | + |
| 49 | +### 3. Frontend Setup |
| 50 | +```bash |
| 51 | +cd client |
| 52 | +npm install |
| 53 | +npm run dev |
| 54 | +``` |
| 55 | + |
| 56 | +The application will be available at `http://localhost:5173` |
| 57 | + |
| 58 | +## API Endpoints & Testing |
| 59 | + |
| 60 | +### 1. Create User |
| 61 | +```bash |
| 62 | +curl -X POST http://localhost:5000/api/users \ |
| 63 | +-H "Content-Type: application/json" \ |
| 64 | +-d '{ |
| 65 | + "name": "John Doe", |
| 66 | + "dob": "1990-01-01", |
| 67 | + "pan": "ABCDE1234F", |
| 68 | + "aadhaar": "123456789012", |
| 69 | + "gstin": "27AAPFU0939F1ZV", |
| 70 | + "udyam": "UDYAM-MH-02-0000001" |
| 71 | +}' |
| 72 | +``` |
| 73 | + |
| 74 | +### 2. Create Loan |
| 75 | +```bash |
| 76 | +curl -X POST http://localhost:5000/api/loans \ |
| 77 | +-H "Content-Type: application/json" \ |
| 78 | +-d '{ |
| 79 | + "userId": "USER_ID_FROM_PREVIOUS_RESPONSE", |
| 80 | + "disbursementDate": "2024-03-15", |
| 81 | + "amount": 1000000, |
| 82 | + "interestRate": 12, |
| 83 | + "tenure": 3 |
| 84 | +}' |
| 85 | +``` |
| 86 | + |
| 87 | +### 3. Get Loan Details |
| 88 | +```bash |
| 89 | +curl http://localhost:5000/api/loans/LOAN_ID |
| 90 | +``` |
| 91 | + |
| 92 | +### 4. Download Loan Ledger |
| 93 | +```bash |
| 94 | +curl -O -J http://localhost:5000/api/loans/LOAN_ID/download |
| 95 | +``` |
| 96 | + |
| 97 | +## Data Validation Rules |
| 98 | + |
| 99 | +### PAN Format |
| 100 | +- 5 alphabets + 4 numbers + 1 alphabet |
| 101 | +- Example: ABCDE1234F |
| 102 | + |
| 103 | +### Aadhaar Format |
| 104 | +- 12 digits |
| 105 | +- Example: 123456789012 |
| 106 | + |
| 107 | +### GSTIN Format |
| 108 | +- 2 digits + 5 alphabets + 4 digits + 1 alphabet + 1 digit/alphabet + Z + 1 digit/alphabet |
| 109 | +- Example: 27AAPFU0939F1ZV |
| 110 | + |
| 111 | +### UDYAM Format |
| 112 | +- UDYAM-XX-DD-XXXXXXX |
| 113 | +- Example: UDYAM-MH-02-0000001 |
| 114 | + |
| 115 | + |
| 116 | +## Sample Data for Testing |
| 117 | + |
| 118 | +### User Data |
| 119 | +```json |
| 120 | +{ |
| 121 | + "name": "John Doe", |
| 122 | + "dob": "1990-01-01", |
| 123 | + "pan": "ABCDE1234F", |
| 124 | + "aadhaar": "123456789012", |
| 125 | + "gstin": "27AAPFU0939F1ZV", |
| 126 | + "udyam": "UDYAM-MH-02-0000001" |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +### Loan Data |
| 131 | +```json |
| 132 | +{ |
| 133 | + "userId": "{userId}", |
| 134 | + "disbursementDate": "2024-03-15", |
| 135 | + "amount": 100000, |
| 136 | + "interestRate": 12, |
| 137 | + "tenure": 2 |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +## Error Handling |
| 142 | + |
| 143 | +The API returns appropriate HTTP status codes: |
| 144 | +- 200: Success |
| 145 | +- 201: Created |
| 146 | +- 400: Bad Request (validation errors) |
| 147 | +- 404: Not Found |
| 148 | +- 500: Server Error |
| 149 | + |
| 150 | +## Development |
| 151 | + |
| 152 | +To run in development mode with hot reloading: |
| 153 | + |
| 154 | +Backend: |
| 155 | +```bash |
| 156 | +npm run dev # if nodemon is configured |
| 157 | +``` |
| 158 | + |
| 159 | +Frontend: |
| 160 | +```bash |
| 161 | +cd client |
| 162 | +npm run dev |
| 163 | +``` |
| 164 | + |
| 165 | +## Production Build |
| 166 | + |
| 167 | +Frontend: |
| 168 | +```bash |
| 169 | +cd client |
| 170 | +npm run build |
| 171 | +``` |
| 172 | + |
| 173 | +The build files will be in the `dist` directory. |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | +## License |
| 178 | + |
| 179 | +This project is licensed under the MIT License - see the LICENSE file for details |
0 commit comments