This document describes the architectural layout, core subsystems, component interactions, and algorithms implemented in Fin-Trust.
Fin-Trust utilizes a client-server architecture with external system integrations.
graph TD
User[Browser Frontend] -->|HTTPS Requests| Backend[Express Backend API]
Backend -->|Mongoose ODM| DB[(MongoDB Database)]
Backend -->|REST API| Gemini[Google Gemini AI API]
Backend -->|HTTP POST| Brevo[Brevo SMTP / HTTP Email API]
User -->|Read-Only Coordinates| Nominatim[OSM Nominatim API]
- Framework: React 19 (Vite)
- Styling: Tailwind CSS v4 & custom HSL-based design system
- Motion/UX: GSAP (GreenSock Animation Platform) for fluid transitions, micro-animations, magnetic fields, and parallax cards.
- Client routing: React Router DOM (v7) with protected route boundaries.
- Framework: Node.js & Express
- Session management: Stateless JSON Web Tokens (JWT)
- Request logging: Morgan (Development environment)
- File parsing: Multer (KyC file upload buffering)
- Database: MongoDB Atlas
- Object Modeling: Mongoose ODM with pre-save password-hashing hooks and schema-level projection exclusions.
sequenceDiagram
autonumber
actor User
participant Frontend
participant Backend
participant Brevo as Brevo API
User->>Frontend: Fill Registration Form
Frontend->>Backend: POST /api/auth/register
Backend->>Backend: Create user (isVerified: false)
Backend->>Backend: Generate & hash 6-digit OTP
Backend->>Brevo: Send OTP email (or debugOtp in dev)
Backend-->>Frontend: Response 201 (Pending verification)
Frontend->>User: Redirect to Verify Email page
User->>Frontend: Input OTP
Frontend->>Backend: POST /api/auth/verify-email
Backend->>Backend: Compare hashes & verify
Backend-->>Frontend: Response 200 (Success)
Frontend->>User: Allow login
Fin-Trust calculates the physical distance between matched borrowers and lenders dynamically on the backend. This is implemented via the Haversine formula, which computes the shortest distance between two points on the surface of a sphere given their longitudes and latitudes.
Where:
-
$R$ is the Earth's radius (6,371 km or 6,371,000 meters). -
$\phi_1, \phi_2$ are the latitudes of point 1 and point 2 in radians. -
$\Delta \phi$ is the difference in latitudes. -
$\Delta \lambda$ is the difference in longitudes.
The system assigns a standard rating score from 0 to 100 based on specific profile parameters:
- Income-to-Loan Ratio (Up to 30 points): Computed by dividing the requested loan amount by monthly income.
- Employment Status (Up to 20 points):
Salariedprofiles receive 20 points,Self-Employedreceive 15 points, andUnemployedreceive 0 points. - Document Verification via AI OCR (Up to 35 points):
- 10 points per uploaded document (Aadhaar, PAN, Bank Statement).
- 5 points if the user's registered profile name matches the names parsed from the uploaded documents by the OCR engine.
- Profile Completeness (Up to 15 points): Points awarded for completing all bio fields.
Matches are ranked using a multi-factor scoring formula:
- Location Match (25%): Proximity matching of cities and actual coordinates.
- Lending Range Fit (30%): Verification of whether the requested borrower amount fits within the lender's threshold limits.
- Trust Score compliance (30%): Borrower's calculated trust score must meet the lender's minimum score constraints.
- Duration Fit (15%): Proximity of requested repayment durations.