A decentralized peer-to-peer lending platform built on Cartesi, enabling borrowers to access loans and investors to earn yields through lending pools.
- Frontend: Next.js 15, React, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes, Prisma ORM
- Database: PostgreSQL with Supabase
- Authentication: NextAuth.js with Alchemy Account Kit
- Blockchain: Cartesi, Arbitrum, Ethereum
- Wallet Integration: WalletConnect, Alchemy Account Kit (Embedded & External Wallets)
- Identity Verification: Reclaim Protocol, Plaid
- Browse and filter lending pools by APY, TVL, risk level, and investor count
- Advanced search with real-time filtering
- Side-by-side pool comparison tool
- Detailed pool analytics and performance metrics
- Real-time portfolio dashboard with performance charts
- Asset allocation visualization (pie charts)
- 30-day performance trend analysis
- Active stake tracking across multiple pools
- Earnings history and projections
- Platform-wide metrics (Total TVL, Active Pools, Total Investors)
- TVL growth trends over time
- APY distribution across pools
- Investor growth analytics
- Pool type breakdown
- Top performing pools ranking
- Market trends and seasonal insights
- Account management with wallet integration
- Notification preferences (email, investment updates, earnings alerts)
- Transaction history export
- Wallet disconnect with confirmation
- Sign in with wallet (WalletConnect or Alchemy embedded wallet)
- KYC verification for account addresses
- Loan application with bank account verification
- Credit score integration via Reclaim Protocol
- Transaction history analysis through Plaid
- Review and approve/reject loan applications
- Manage lending pools (create, edit, archive)
- Investor management dashboard
- Pool analytics and performance monitoring
- Platform-wide statistics
- Set up the Loan Pool Smart Contracts and Cartesi instance for local development
- PostgreSQL database (local or Supabase)
- Node.js 18+ and npm
- Clone the repository:
git clone https://github.com/Locale-Network/lending-platform.git
cd lending-platform- Copy the example environment file:
cp .example.env .env- Configure environment variables in
.env:
Required Variables:
NEXT_PUBLIC_REOWN_CLOUD_PROJECT_ID- Your Reown (WalletConnect) project IDNEXT_PUBLIC_WALLETCONNECT_PROJECT_ID- WalletConnect project ID for AlchemyCARTESI_PRIVATE_KEY- Private key from the loan-pool repo (starts with 0x)NEXT_PUBLIC_ALCHEMY_API_KEY- Alchemy API key for Account KitNEXT_PUBLIC_SUPABASE_URL- Your Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY- Supabase anonymous keySUPABASE_SERVICE_ROLE_KEY- Supabase service role keyPOSTGRES_URL- PostgreSQL connection stringPLAID_CLIENT_ID- Plaid client ID for bank verificationPLAID_SECRET- Plaid secret keyTEMPLATE_ID- Identity verification template IDNEXTAUTH_SECRET- NextAuth secret (generate withopenssl rand -base64 32)
Optional (Development):
DISABLE_SBT_CHECKS="true"- Bypass soulbound token checks during development
- Start PostgreSQL database (if using Docker):
docker compose up db- Install dependencies:
npm install --legacy-peer-deps- Run database migrations:
npx prisma generate && npx prisma migrate dev- (Optional) Seed the database with sample pools:
npx tsx prisma/seed-pools.ts- Start the development server:
npm run dev- Open http://localhost:3000 in your browser
- Apply for loans
- Connect bank accounts via Plaid
- Submit identity verification
- Track loan status
- Browse and invest in lending pools
- Track portfolio performance
- Earn yields from loans
- Withdraw earnings
- Review and approve loan applications
- Manage lending pools
- Access platform analytics
- Monitor system health
The platform supports multiple wallet connection methods:
- Embedded Wallets: Email-based wallets with passkey support
- External Wallets: MetaMask, Rainbow, Trust Wallet, Rabby, WalletConnect
- Arbitrum (Primary)
- Ethereum Mainnet
- Base (Testnet support)
GET /api/pools/public- List all public poolsGET /api/pools/public/[slug]- Get pool detailsPOST /api/pools/stake- Stake in a poolPOST /api/pools/unstake- Withdraw from a poolGET /api/pools/[id]/user-stake- Get user's stake in a pool
GET /api/portfolio/stakes- Get user's active stakes
GET /api/stake-transactions- Get stake transaction history
GET /api/pools- List all pools (admin)POST /api/pools- Create new poolPUT /api/pools/[id]- Update poolDELETE /api/pools/[id]- Archive pool
users- User accounts and profilesloan_pools- Lending pool configurationsuser_stakes- Investor stakes in poolsstake_transactions- Transaction historyloan_requests- Borrower loan applicationsaccounts- NextAuth account linking
Notices from the Cartesi machine are processed via CRON job on Vercel.
Manual Trigger:
curl http://localhost:3000/api/cron/notices \
-H "Authorization: Bearer {CRON_SECRET}"- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy automatically on push to main branch
- Production database: Use Supabase or managed PostgreSQL
- Cartesi node: Deploy to production Cartesi network
- CRON jobs: Configure via Vercel cron configuration
npm run buildnpm run start# Generate Prisma client
npx prisma generate
# Create new migration
npx prisma migrate dev --name migration_name
# Push schema without migration (dev only)
npx prisma db push
# Open Prisma Studio
npx prisma studio# Run linter
npm run lint
# Run type checking
npx tsc --noEmit- All sensitive configuration is managed via environment variables
- No secrets are committed to the repository
- API routes validate user authentication and authorization
- Database queries use Prisma ORM to prevent SQL injection
- NextAuth handles secure session management
- Soulbound NFTs verify investor/borrower status (can be disabled in development)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the Locale Network ecosystem.
For issues and questions:
- Open an issue on GitHub
- Contact the Locale Network team