How eshang2006/p2p-lending-platform works
CredFlow is a P2P micro-lending platform. Borrowers register and create scored loan campaigns; investors browse campaigns and fund them through Razorpay; borrowers release fully funded escrow into repayment, then track repayments. The React client calls an Express API, which applies JWT and role checks and persists lending records in MongoDB. The README also documents email and real-time updates. Some repayment and frontend integrations are only documented or indexed, so their links are cited to the README or left out where wiring is not shown.
Main entry points: App.jsx Route shell · investmentController.js Investment and escrow · api.js API client · server.js Express and sockets
Components 31
Web client
- Route shell
frontend/src/App.jsx - Auth state
frontend/src/context/AuthContext.jsx - Login and register
frontend/src/pages/Login.jsx - Home page
frontend/src/pages/Home.jsx - Borrower dashboard
frontend/src/pages/BorrowerDashboard.jsx - Create campaign
frontend/src/pages/CreateLoan.jsx - Campaign listing
frontend/src/pages/CampaignList.jsx - Campaign detail
frontend/src/pages/CampaignDetail.jsx - Investor dashboard
frontend/src/pages/InvestorDashboard.jsx - API client
frontend/src/utils/api.js
Identity and access
- Auth routes
backend/routes/authRoutes.js - Auth service
backend/controllers/authController.js - JWT and role checks
backend/middleware/authMiddleware.js - User records
backend/models/User.js
Campaign and credit
- Loan routes
backend/routes/loanRoutes.js - Campaign service
backend/controllers/loanController.js - Credit scoring
backend/utils/creditScore.js - Loan records
backend/models/Loan.js
Funding and repayment
- Investment routes
backend/routes/investmentRoutes.js - Investment and escrow
backend/controllers/investmentController.js - Investment records
backend/models/Investment.js - Transaction records
backend/models/Transaction.js - Repayment routes
backend/routes/repaymentRoutes.js - Repayment records
backend/models/Repayment.js
API and persistence
- Express and sockets
backend/server.js - MongoDB
backend/config/db.js
Other components
- Borrower
- Investor
- Razorpay
- Email service
- Socket.io clients
Connections 46
- Borrower → Route shell: uses
README.md - Investor → Route shell: uses
README.md - Route shell → Auth state: provides auth
frontend/src/App.jsx - Route shell → Home page: routes to
frontend/src/App.jsx - Route shell → Login and register: routes to
frontend/src/App.jsx - Route shell → Borrower dashboard: routes to
frontend/src/App.jsx - Route shell → Create campaign: routes to
frontend/src/App.jsx - Route shell → Campaign listing: routes to
frontend/src/App.jsx - Route shell → Campaign detail: routes to
frontend/src/App.jsx - Route shell → Investor dashboard: routes to
frontend/src/App.jsx - Login and register → Auth state: updates
frontend/src/pages/Login.jsx - Login and register → API client: calls
frontend/src/pages/Login.jsx - Borrower dashboard → API client: calls
frontend/src/pages/BorrowerDashboard.jsx - Create campaign → API client: calls
frontend/src/pages/CreateLoan.jsx - Campaign listing → API client: calls
frontend/src/pages/CampaignList.jsx - Campaign detail → API client: calls
frontend/src/pages/CampaignDetail.jsx - Investor dashboard → API client: calls
frontend/src/pages/InvestorDashboard.jsx - API client → Express and sockets: HTTP requests
README.md - Express and sockets → MongoDB: connects
backend/server.js - Express and sockets → Auth routes: mounts
backend/server.js - Express and sockets → Loan routes: mounts
backend/server.js - Express and sockets → Investment routes: mounts
backend/server.js - Express and sockets → Repayment routes: mounts
backend/server.js - Auth routes → Auth service: dispatches
backend/routes/authRoutes.js - Auth routes → JWT and role checks: protects
backend/routes/authRoutes.js - Auth service → User records: reads and writes
backend/controllers/authController.js - JWT and role checks → User records: loads user
backend/middleware/authMiddleware.js - Loan routes → Campaign service: dispatches
backend/routes/loanRoutes.js - Loan routes → JWT and role checks: protects
backend/routes/loanRoutes.js - Campaign service → Credit scoring: calculates score
backend/controllers/loanController.js - Campaign service → Loan records: reads and writes
backend/controllers/loanController.js - Credit scoring → Loan records: reads history
backend/utils/creditScore.js - Investment routes → Investment and escrow: dispatches
backend/routes/investmentRoutes.js - Investment routes → JWT and role checks: checks roles
backend/routes/investmentRoutes.js - Investment and escrow → Razorpay: creates orders
backend/controllers/investmentController.js - Investment and escrow → Loan records: reads and updates
backend/controllers/investmentController.js - Investment and escrow → Investment records: creates and reads
backend/controllers/investmentController.js - Investment and escrow → Transaction records: records payment
backend/controllers/investmentController.js - Investment and escrow → User records: loads parties
backend/controllers/investmentController.js - Investment and escrow → Repayment records: creates schedule
backend/controllers/investmentController.js - Investment and escrow → Email service: sends notice
backend/controllers/investmentController.js - Investment and escrow → Socket.io clients: emits update
backend/controllers/investmentController.js - Repayment routes → JWT and role checks: protects
backend/routes/repaymentRoutes.js - Repayment routes → Repayment records: reads and updates
backend/routes/repaymentRoutes.js - Repayment routes → Loan records: completes loan
backend/routes/repaymentRoutes.js - Campaign service → Socket.io clients: emits campaign
backend/controllers/loanController.js