Skip to content

malawadd/cipherLend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cipherLend - Decentralized P2P Lending Platform 🏦

cipherLend is a privacy-first peer-to-peer lending platform built on Web3 infrastructure, combining traditional financial document analysis with cutting-edge privacy technology.

πŸš€ What is cipherLend?

cipherLend enables borrowers to request loans by uploading financial documents (bank statements, bills, income proof) that are analyzed by AI and encrypted using Nillion's SecretVault technology. Lenders can assess loan applications by viewing AI-generated summaries without accessing raw financial documents, ensuring borrower privacy while enabling informed lending decisions.

Key Features

  • πŸ” Privacy-First: Documents encrypted in Nillion SecretVault - only borrowers can decrypt raw files
  • πŸ€– AI Document Analysis: AI analyzes financial documents and extracts key insights
  • πŸ’° P2P Lending: Direct borrower-lender matching without traditional banking intermediaries
  • 🌍 Global Access: Web3-based, accessible worldwide with crypto wallet integration
  • πŸ“Š Humanity Score: Gitcoin Passport integration for identity verification
  • πŸ”— Blockchain Integration: Wallet connections via RainbowKit/WagMi

πŸ—οΈ Technical Architecture

Frontend Stack

  • Next.js 15 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling with custom neo-brutalist design
  • Clerk - Authentication and user management
  • Convex - Real-time database and backend logic
  • RainbowKit/WagMI - Web3 wallet integration

Privacy & Security

  • Nillion AI - Provide private AI assessments
  • Nillion SecretVault - Encrypted document storage with user-controlled access
  • Gitcoin Passport - Humanity verification and scoring

Database Schema (Convex)

users/ - User profiles and preferences
loanRequests/ - Loan applications with terms
documents/ - Financial document metadata (encrypted files in SecretVault)
assessments/ - Lender evaluations of loan requests
wallets/ - User wallet connections

πŸ“ Project Structure

β”œβ”€β”€ app/                          # Next.js App Router pages
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ analyze-document/     # AI document analysis
β”‚   β”‚   β”œβ”€β”€ generate-keypair/     # SecretVault keypair generation
β”‚   β”‚   β”œβ”€β”€ vault-operations/     # Document encryption/decryption
β”‚   β”‚   └── verify-score/         # Gitcoin Passport verification
β”‚   β”œβ”€β”€ borrow/                   # Borrower interface
β”‚   β”‚   β”œβ”€β”€ new/                  # Create loan request
β”‚   β”‚   └── [shortId]/            # View specific loan request
β”‚   β”œβ”€β”€ lend/                     # Lender interface
β”‚   β”‚   └── [shortId]/            # Assess loan requests
β”‚   └── profile/                  # User profile management
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ borrower/                 # Borrower-specific components
β”‚   β”‚   β”œβ”€β”€ LoanRequestBuilder.tsx    # Loan creation form
β”‚   β”‚   β”œβ”€β”€ UploadPanel.tsx           # General document upload
β”‚   β”‚   β”œβ”€β”€ LoanRequestUploadPanel.tsx # Loan-specific uploads
β”‚   β”‚   β”œβ”€β”€ SecretVaultManager.tsx    # SecretVault integration
β”‚   β”‚   └── HumanityScore.tsx         # Gitcoin Passport display
β”‚   β”œβ”€β”€ lender/                   # Lender-specific components
β”‚   β”‚   β”œβ”€β”€ BorrowerCard.tsx          # Loan request display
β”‚   β”‚   └── AssessmentModal.tsx       # Loan evaluation interface
β”‚   └── ui/                       # Reusable UI components (Neo-brutalist design)
β”œβ”€β”€ convex/                       # Backend logic and database
β”‚   β”œβ”€β”€ users.ts                  # User management
β”‚   β”œβ”€β”€ loanRequests.ts          # Loan CRUD operations
β”‚   β”œβ”€β”€ documents.ts             # Document metadata management
β”‚   └── assessments.ts           # Lender evaluations
└── lib/
    β”œβ”€β”€ secretvaults.ts          # Nillion integration
    └── loan-utils.ts            # Loan calculation utilities

πŸ”„ User Workflow

For Borrowers:

  1. Sign Up β†’ Clerk authentication
  2. Generate SecretVault Keypair β†’ Privacy setup for document encryption
  3. Create Loan Request β†’ Specify amount, terms, purpose
  4. Upload Documents β†’ Bank statements, bills, income proof (AI analyzed + encrypted)
  5. Wait for Lenders β†’ Receive assessments and funding offers
  6. Accept Funding β†’ Connect wallet and receive funds

For Lenders:

  1. Sign Up β†’ Clerk authentication
  2. Browse Loan Requests β†’ View AI-generated summaries
  3. Assess Applications β†’ Evaluate risk based on financial insights
  4. Fund Loans β†’ Connect wallet and transfer funds to borrowers

Privacy Flow:

  1. Document Upload β†’ Files analyzed by OpenAI API
  2. Encryption β†’ Raw documents + analysis stored in SecretVault (user-controlled)
  3. Summary Sharing β†’ Only AI summaries visible to lenders
  4. Access Control β†’ Borrowers can grant/revoke document access

πŸ› οΈ Development Setup

Prerequisites

  • Node.js 18+
  • npm/yarn/pnpm
  • Convex account
  • Clerk account
  • OpenAI API key
  • Nillion API key

Environment Variables

# Convex
CONVEX_DEPLOYMENT=dev:your-deployment
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloud

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...

# OpenAI
OPENAI_API_KEY=sk-...

# Nillion SecretVault
NILLION_BUILDER_PRIVATE_KEY=your-builder-key
NILLION_USER_KEY=your-user-key

# Gitcoin Passport
PASSPORT_API_KEY=your-passport-key
NEXT_PUBLIC_PASSPORT_SCORER_ID=your-scorer-id

# Wallet Connect
NEXT_PUBLIC_REOWN_PROJECT_ID=your-project-id

Installation & Running

# Install dependencies
npm install

# Start Convex development
npx convex dev

# Start Next.js development server
npm run dev

Key API Endpoints

  • POST /api/analyze-document - Analyze financial documents with OpenAI
  • POST /api/generate-keypair - Create SecretVault encryption keypair
  • POST /api/vault-operations - Store/retrieve encrypted documents
  • POST /api/verify-score - Verify Gitcoin Passport humanity score

πŸ” Security & Privacy

Document Privacy Architecture

  1. Upload β†’ Files sent to OpenAI for analysis (temporary)
  2. Analysis β†’ AI extracts financial insights and categories
  3. Encryption β†’ Raw files + analysis encrypted in SecretVault
  4. Access Control β†’ Users control who can decrypt their documents
  5. Sharing β†’ Lenders only see AI summaries, never raw documents

SecretVault Integration

  • Each user generates a unique encryption keypair
  • Documents stored encrypted with user-controlled access
  • Delegation tokens enable secure sharing with specific parties
  • Zero-knowledge architecture - platform cannot decrypt user documents

🀝 Contributing

Development Guidelines

  • Follow TypeScript strict mode
  • Use Tailwind for styling (neo-brutalist design system)
  • All forms use Convex mutations for data persistence
  • Privacy-first: always encrypt sensitive documents
  • Real-time updates via Convex subscriptions

Testing Components

  • StoreToVaultButton - Test SecretVault integration
  • NilaiTestComponent - Test document analysis
  • Upload panels have built-in privacy checks

Code Organization

  • Components: Reusable UI in /components/ui/
  • Feature Components: Domain-specific in /components/borrower/ or /components/lender/
  • Backend Logic: Convex functions in /convex/
  • API Routes: External integrations in /app/api/

πŸ“š Key Technologies

🎯 Vision

cipherLend aims to democratize access to credit while preserving financial privacy. By combining AI-powered document analysis with zero-knowledge encryption, we enable global P2P lending without compromising sensitive financial data.

The platform bridges traditional finance (bank statements, credit scores) with Web3 infrastructure (wallet connections, decentralized storage), creating a new paradigm for privacy-preserving financial services.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •