Digitizing informal money lending between friends and family with AI-powered features
Features β’ Tech Stack β’ Getting Started β’ Documentation
- Overview
- Key Features
- Tech Stack
- Architecture
- Getting Started
- Environment Variables
- Project Structure
- API Documentation
- Features Deep Dive
- Deployment
- Contributing
- License
TrustFirst is a modern peer-to-peer lending platform that brings structure and accountability to informal money lending between friends, family, and colleagues. Built with cutting-edge AI technologies, TrustFirst transforms casual lending into a professional, trackable, and trust-based experience.
- Awkward money conversations between friends/family
- Forgotten payments and broken promises
- Lack of documentation for informal loans
- No structured repayment plans
- Difficulty tracking multiple small loans
TrustFirst provides:
- β Digital agreements with trust scores
- β AI-generated personalized repayment plans
- β Automated reminders via email and AI voice calls
- β Group lending for community support
- β Payment proof tracking with screenshots
- β Witness verification for added credibility
- β Real-time location tracking for security
- Google Gemini 2.5 Pro integration
- Generates 3 personalized repayment plans:
- Aggressive: Fast repayment, higher installments
- Balanced: Moderate payments over reasonable time
- Flexible: Smaller payments spread over longer period
- Smart date validation ensures all payments before due date
- Considers borrower context and financial capacity
- VAPI AI integration for natural voice calls
- Automated payment reminders via phone
- Professional, empathetic conversation flow
- One-click call initiation by lenders
- Real-time call status tracking
- Create groups of friends, family, or colleagues
- Request money from entire group
- Multiple people contribute partial amounts
- Each contribution creates individual 1-on-1 agreement
- Request auto-closes when full amount received
- Admin controls for group creators:
- Add/remove members
- Delete groups
- Manage permissions
- Real-time trust score (0-100) for each agreement
- Score decreases if payments are late
- Strict Mode option for faster penalties
- Visual indicators with color coding:
- π’ Green (80-100): Excellent
- π‘ Yellow (60-79): Good
- π Orange (40-59): Fair
- π΄ Red (0-39): Poor
- Add third-party witness to agreements
- Email-based approval workflow
- Witness can approve/reject agreements
- Adds legal credibility to informal lending
- Notification system for all parties
- Radar.io integration
- Track borrower's live location (with consent)
- Location history with timestamps
- Address geocoding (city, state, country)
- Privacy-focused implementation
- Upload multiple payment screenshots
- Grid-based UI for organized tracking
- Individual proof for each installment
- View/remove uploaded proofs
- Progress tracking (X/Y proofs uploaded)
- File validation (image only, max 5MB)
- Automated email workflows:
- Agreement creation confirmations
- Witness approval requests
- Payment due date reminders
- Settlement notifications
- Professional HTML email templates
- Clickable buttons with ngrok URLs
- Real-time delivery status
- Firebase Authentication
- Email/password login
- User profile management
- Role-based access control (lender/borrower/witness)
- Session management
- Clean, modern dark-themed UI
- Real-time updates and notifications
- Mobile-responsive design
- Intuitive navigation
- Visual progress indicators
- Color-coded status badges
- Next.js 16.0 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- Shadcn/ui - Beautiful component library
- Lucide Icons - Modern icon set
- Next.js API Routes - Serverless API endpoints
- MongoDB Atlas - Cloud NoSQL database
- Mongoose - MongoDB ODM
- Google Gemini 2.5 Pro - AI installment planning
- VAPI AI - Conversational voice calling
- Make.com - Webhook automation workflows
- Firebase - Authentication & user management
- Radar.io - Location tracking & geocoding
- Nodemailer - Email delivery
- Ngrok - Local development tunneling
- ESLint - Code linting
- Prettier - Code formatting
- Git - Version control
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client (Browser) β
β Next.js 16 + React β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Next.js API Routes β
β (Serverless Functions) β
βββ¬ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬ββββββββββββββ
β β β β β
βΌ βΌ βΌ βΌ βΌ
ββββββ ββββββββββ ββββββββ ββββββββ ββββββββββ
β DB β βFirebaseβ βGeminiβ βVAPI β βRadar.ioβ
β β β Auth β β AI β β AI β βLocationβ
ββββββ ββββββββββ ββββββββ ββββββββ ββββββββββ
MongoDB
- User Authentication: Firebase handles login/signup
- Agreement Creation: Stored in MongoDB with Mongoose
- AI Planning: Gemini generates installment plans
- Notifications: Nodemailer sends emails
- Voice Calls: VAPI AI makes conversational calls
- Location: Radar.io tracks borrower location
- File Storage: Local filesystem for payment proofs
- Node.js 18.x or higher
- npm or yarn or pnpm
- MongoDB Atlas account
- Firebase project
- Google Cloud account (for Gemini API)
- Ngrok account (for local development)
- Clone the repository
git clone https://github.com/yourusername/trustfirst.git
cd trustfirst- Install dependencies
npm install
# or
yarn install
# or
pnpm install- Set up environment variables
cp .env.example .env.localEdit .env.local with your credentials (see Environment Variables)
- Start development server
npm run dev- Start ngrok tunnel (in a new terminal)
npx ngrok http 3000- Update ngrok URL
- Copy the ngrok HTTPS URL
- Update
NEXT_PUBLIC_APP_URLin.env.local - Restart the dev server
- Open the app
http://localhost:3000
Create a .env.local file in the root directory:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
# MongoDB
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname
# Email Configuration (Gmail)
EMAIL_USER=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
EMAIL_SERVER_HOST=smtp.gmail.com
EMAIL_SERVER_PORT=587
EMAIL_FROM=your_email@gmail.com
# Application URL (Ngrok)
NEXT_PUBLIC_APP_URL=https://your-ngrok-url.ngrok-free.dev
# AI Configuration
GEMINI_API_KEY=your_gemini_api_key
# Make.com Webhook (for VAPI AI calls)
MAKE_CALL_WEBHOOK_URL=https://hook.us2.make.com/your_webhook_id
# Radar.io (Location Tracking)
NEXT_PUBLIC_RADAR_PUBLISHABLE_KEY=your_radar_key
# Firebase Admin (for server-side)
FIREBASE_CLIENT_EMAIL=your_service_account@project.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"- Firebase: https://console.firebase.google.com/
- MongoDB Atlas: https://www.mongodb.com/cloud/atlas
- Google Gemini: https://makersuite.google.com/app/apikey
- Radar.io: https://radar.com/dashboard
- Make.com: https://www.make.com/
- Gmail App Password: https://myaccount.google.com/apppasswords
trustfirst/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β β βββ agreements/ # Agreement CRUD
β β β βββ [id]/
β β β βββ route.ts
β β β βββ approve-witness/
β β β βββ send-reminder/
β β β βββ ask-ai-call/
β β β βββ save-plan/
β β β βββ upload-installment-proof/
β β β βββ remove-installment-proof/
β β βββ auth/ # Authentication
β β βββ groups/ # Group management
β β βββ money-requests/ # Group lending
β β βββ notifications/ # Notifications
β β βββ user/ # User management
β β βββ live-location/ # Location tracking
β βββ actions/ # Server Actions
β β βββ generate-installment-plan.ts
β βββ auth/ # Auth pages
β β βββ signin/
β β βββ signup/
β βββ dashboard/ # Main app pages
β β βββ page.tsx # Dashboard home
β β βββ layout.tsx # Dashboard layout
β β βββ agreement/[id]/ # Agreement details
β β β βββ upload-proofs/ # Payment proof upload
β β βββ groups/ # Group pages
β β β βββ page.tsx
β β β βββ create/
β β β βββ [id]/
β β βββ notifications/
β β βββ profile/
β βββ utils/ # Utility functions
β β βββ radar.ts # Radar.io integration
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Landing page
βββ components/ # React components
β βββ dashboard/
β β βββ RecentFriendsModal.tsx
β βββ ui/ # Shadcn/ui components
β β βββ button.tsx
β β βββ card.tsx
β β βββ dialog.tsx
β β βββ ... (50+ components)
β βββ installment-plan-generator.tsx
β βββ theme-provider.tsx
βββ lib/ # Libraries & utilities
β βββ mongodb.ts # MongoDB connection
β βββ email.ts # Email service
β βββ utils.ts # Helper functions
βββ models/ # Mongoose models
β βββ Agreement.ts
β βββ Group.ts
β βββ MoneyRequest.ts
β βββ Notification.ts
β βββ User.ts
β βββ LiveLocation.ts
βββ hooks/ # Custom React hooks
β βββ use-mobile.ts
β βββ use-toast.ts
βββ public/ # Static assets
β βββ uploads/ # User uploads
β βββ installments/
βββ .env.local # Environment variables
βββ .gitignore
βββ next.config.mjs # Next.js config
βββ tailwind.config.ts # Tailwind config
βββ tsconfig.json # TypeScript config
βββ package.json
βββ README.md
Create a new user account.
Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword"
}Sign in to existing account.
Request Body:
{
"email": "john@example.com",
"password": "securepassword"
}Get all agreements for a user.
Create a new agreement.
Request Body:
{
"lenderId": "user123",
"lenderName": "John Doe",
"lenderEmail": "john@example.com",
"borrowerName": "Jane Smith",
"borrowerEmail": "jane@example.com",
"amount": 10000,
"purpose": "Medical emergency",
"dueDate": "2026-03-15",
"witnessEmail": "witness@example.com"
}Get agreement details.
Update agreement (settle, update status, etc.).
Send payment reminder email.
Initiate AI voice call to borrower.
Witness approves the agreement.
Save selected installment plan.
Request Body:
{
"planIndex": 1,
"planName": "Balanced Approach",
"installments": [
{
"date": "2026-02-15",
"amount": 3333,
"note": "First payment"
}
]
}Upload payment proof screenshot.
Form Data:
file: Image fileinstallmentIndex: Index of installment (0, 1, 2...)
Get all groups for a user.
Create a new group.
Request Body:
{
"name": "College Friends",
"description": "My college buddies",
"createdBy": "user123",
"createdByName": "John Doe",
"createdByEmail": "john@example.com",
"memberEmails": ["friend1@example.com", "friend2@example.com"]
}Get group details.
Update group (add/remove members).
Request Body:
{
"addMemberEmails": ["newmember@example.com"],
"removeMemberEmail": "oldmember@example.com"
}Delete a group.
Get all money requests for a group.
Create a money request in a group.
Request Body:
{
"groupId": "group123",
"requesterId": "user123",
"requesterName": "John Doe",
"requesterEmail": "john@example.com",
"amount": 5000,
"purpose": "Emergency",
"dueDate": "2026-03-15"
}Contribute to a money request.
Request Body:
{
"lenderId": "user456",
"lenderName": "Jane Smith",
"lenderEmail": "jane@example.com",
"amount": 1000
}Get all notifications for a user.
Save borrower's live location.
Request Body:
{
"agreementId": "agreement123",
"userId": "user123",
"latitude": 18.5204,
"longitude": 73.8567,
"locationContext": {
"description": "Pune, Maharashtra, India",
"city": "Pune",
"state": "Maharashtra",
"country": "India"
}
}The AI installment planner uses Google Gemini 2.5 Pro to generate personalized repayment schedules:
- Input Analysis: Analyzes amount, due date, and borrower context
- Plan Generation: Creates 3 distinct plans with different strategies
- Date Validation: Ensures all installments are before due date
- Smart Scheduling: Distributes payments evenly (monthly/bi-weekly)
- User Selection: Borrower selects preferred plan
- Proof Tracking: Each installment tracked with screenshot uploads
Example Plans for βΉ10,000 due in 3 months:
- Aggressive: 2 payments of βΉ5,000 each (1 month)
- Balanced: 3 payments of βΉ3,333 each (2 months)
- Flexible: 4 payments of βΉ2,500 each (3 months)
- Create Group: User creates group and adds members
- Request Money: Member posts money request to group
- Contributions: Multiple members contribute partial amounts
- Agreement Creation: Each contribution creates 1-on-1 agreement
- Request Closure: Auto-closes when full amount received
- Individual Tracking: Each agreement tracked separately
Example:
- Alice requests βΉ10,000 from "College Friends" group
- Bob contributes βΉ3,000 β Creates Agreement #1 (Bob β Alice)
- Charlie contributes βΉ4,000 β Creates Agreement #2 (Charlie β Alice)
- David contributes βΉ3,000 β Creates Agreement #3 (David β Alice)
- Request closes, Alice has 3 separate agreements to repay
// Initial score: 80
let trustScore = 80
// If payment is late:
if (daysOverdue > 0) {
if (strictMode) {
trustScore -= (daysOverdue * 2) // Faster penalty
} else {
trustScore -= daysOverdue // Normal penalty
}
}
// Minimum score: 0
trustScore = Math.max(0, trustScore)All emails use professional HTML templates with:
- Responsive design
- Branded colors
- Clickable buttons
- Dynamic content
- Ngrok URLs for live access
Email Types:
- Agreement Request
- Witness Approval Request
- Witness Approved Notification
- Payment Reminder
- Settlement Confirmation
- Push to GitHub
git push origin main- Import to Vercel
- Go to https://vercel.com/new
- Import your repository
- Add environment variables
- Deploy
- Update URLs
- Replace ngrok URL with Vercel URL
- Update
NEXT_PUBLIC_APP_URL - Update Firebase authorized domains
Add all variables from .env.local to Vercel:
- Settings β Environment Variables
- Add each variable
- Redeploy
- Add domain in Vercel settings
- Update DNS records
- Update
NEXT_PUBLIC_APP_URL - Update Firebase authorized domains
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier
- Write meaningful commit messages
- Add comments for complex logic
- Test thoroughly before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
Team CarpeDiem π
- Shardul Narvekar - Full Stack Developer & AI Integration
- Tejas Adhiya - Backend Developer & Database Architecture
- Jeel Nandha - Frontend Developer & UI/UX Design
- Google Gemini for AI capabilities
- VAPI AI for conversational calling
- Radar.io for location services
- Firebase for authentication
- MongoDB for database
- Vercel for hosting
- Shadcn/ui for beautiful components
For support, email the team or open an issue on GitHub.
Made with β€οΈ by Team CarpeDiem
Shardul Narvekar β’ Tejas Adhiya β’ Jeel Nandha
β Star this repo if you find it helpful!