A full-stack loan application system built with Node.js, Express, MongoDB, and React. The system allows users to apply for loans, make payments via M-PESA, and administrators to manage loan approvals.
- User registration and authentication
- Loan eligibility checking based on credit score
- Loan application with M-PESA payment integration
- Dashboard with loan history and statistics
- Real-time loan status tracking
- Admin dashboard for loan management
- Approve/reject loan applications
- View all loan applications with filtering
- User management and statistics
- Secure JWT-based authentication
- M-PESA STK Push integration for payments
- Credit scoring system
- Responsive React frontend with Tailwind CSS
- RESTful API with proper error handling
- MongoDB database with Mongoose ODM
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- Axios - HTTP client for M-PESA API
- React - UI library
- React Router - Client-side routing
- Axios - HTTP client
- Tailwind CSS - Styling
- Recharts - Data visualization
- Lucide React - Icons
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- M-PESA API credentials (for production)
-
Clone the repository
git clone <repository-url> cd jamii-loan
-
Install dependencies
# Install all dependencies (backend and frontend) npm run install-all -
Environment Setup
Backend (.env)
PORT=5000 MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/jamii-loan?retryWrites=true&w=majority JWT_SECRET=your_jwt_secret_key_here MPESA_CONSUMER_KEY=your_mpesa_consumer_key MPESA_CONSUMER_SECRET=your_mpesa_consumer_secret MPESA_SHORTCODE=174379 MPESA_PASSKEY=your_mpesa_passkey MPESA_CALLBACK_URL=https://yourdomain.com/api/mpesa/callback NODE_ENV=development
Frontend (.env)
VITE_API_URL=http://localhost:5000/api
-
Start the application
# Start both backend and frontend npm run devOr run them separately:
# Backend cd server npm run dev # Frontend (new terminal) cd client npm run dev
POST /api/auth/register- Register new userPOST /api/auth/login- User login
GET /api/user/profile- Get user profileGET /api/user/eligibility- Check loan eligibilityGET /api/user/loans- Get loan history
POST /api/loan/apply- Apply for loan
GET /api/admin/loans- Get all loansPATCH /api/admin/loan/:id/approve- Approve loanPATCH /api/admin/loan/:id/reject- Reject loan
POST /api/mpesa/callback- M-PESA payment callback
- Email:
user@jamii.com - Password:
password123
- Email:
admin@jamii.com - Password:
admin123
jamii-loan/
├── server/ # Backend application
│ ├── config/ # Database configuration
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Custom middleware
│ ├── models/ # MongoDB models
│ ├── routes/ # API routes
│ ├── utils/ # Utility functions
│ ├── server.js # Main server file
│ └── package.json
├── client/ # Frontend application
│ ├── public/ # Static assets
│ ├── src/
│ │ ├── api/ # API configuration
│ │ ├── components/ # Reusable components
│ │ ├── context/ # React context providers
│ │ ├── pages/ # Page components
│ │ ├── App.jsx # Main app component
│ │ └── main.jsx # App entry point
│ └── package.json
├── .gitignore
├── README.md
└── package.json # Root package.json with scripts
npm run install-all- Install dependencies for both backend and frontendnpm run dev- Start both backend and frontend in development modenpm run build- Build the frontend for productionnpm run start- Start the backend server
cd server
npm run dev # Uses nodemon for auto-restartcd client
npm run dev # Uses Vite for fast development- Set environment variables for production
- Build and deploy to your preferred hosting service (Heroku, AWS, etc.)
- Ensure MongoDB is accessible from your deployment environment
- Build the frontend:
npm run build - Deploy the
distfolder to your hosting service (Netlify, Vercel, etc.)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the ISC License.
For support or questions, please contact the development team.