Skip to main content

Architecture

Locale Lending implements a multi-layer system combining traditional web infrastructure with blockchain and off-chain computation.

System Overview​

Locale Lending Architecture
LOCALE LENDING
Frontend
  • Next.js 15
  • React 19
  • wagmi/viem
Backend
  • API Routes
  • Prisma ORM
  • NextAuth
Blockchain
  • Arbitrum L2
  • Solidity 0.8.22
  • OpenZeppelin
Off-Chain Computation
Cartesi RollupsCircom ZK CircuitsPlaid Integration

Technology Stack​

Frontend​

TechnologyPurpose
Next.js 15React framework with App Router
React 19UI component library
TypeScriptType safety
Tailwind CSSStyling
shadcn/uiComponent library
TanStack QueryData fetching and caching
wagmi/viemWeb3 integration

Backend​

TechnologyPurpose
Next.js API RoutesREST endpoints
Prisma ORMDatabase access
PostgreSQLPrimary database
NextAuth.jsAuthentication
Alchemy Account KitWallet abstraction

Blockchain​

TechnologyPurpose
Solidity 0.8.22Smart contract language
FoundryDevelopment and testing
OpenZeppelinSecurity standards
Arbitrum L2Deployment network

Off-Chain Systems​

TechnologyPurpose
Cartesi RollupsVerifiable computation
CircomZero-knowledge circuits
snarkjsProof generation
PlaidBank data integration

Smart Contract Architecture​

Six core contracts deployed on Arbitrum:

ContractPurpose
SimpleLoanPoolLending operations and loan management
StakingPoolInvestor capital management
PoolVaultAsset custody and accounting
BorrowerCredentialKYC verification NFTs
InvestorCredentialAccreditation NFTs
ProofVerifierZK proof validation

Cartesi DApp Handlers​

The Cartesi rollup processes:

  • Borrower Registration — Identity verification
  • Loan Creation — Application processing
  • Transaction Sync — Plaid data ingestion
  • DSCR Calculation — Creditworthiness computation
  • Rate Adjustment — Dynamic interest rates

Data Flow​

Bank Data Flow​

Plaid API → HTTPS Gateway → JSON Processing →
Reclaim Protocol → ZK Proof → Arbitrum → SQLite Storage

Loan Application Flow​

User Application → KYC Verification → Bank Connection →
DSCR Calculation → Rate Determination → Loan Approval → Fund Disbursement

API Architecture​

The platform exposes 33+ REST endpoints organized by domain:

DomainEndpointsAuth Required
PoolsPool listing, details, statsNo
PortfolioInvestor positions, historyYes
LoansApplications, repaymentsYes
AdminPool management, user adminYes (Admin)
WebhooksPlaid eventsSignature

Rate Limiting​

Endpoint TypeLimit
Public APIs100 requests/minute
Authenticated200 requests/minute
Webhooks1000 requests/minute
Admin50 requests/minute

Security Layers​

Application Security​

  • Session-based authentication with JWT
  • CSRF protection
  • httpOnly cookies
  • Input validation with Zod schemas

Smart Contract Security​

  • Role-based access control (RBAC)
  • UUPS upgradeable pattern
  • Emergency pause capability
  • Multi-sig admin controls

Data Security​

  • AES-256 encryption at rest
  • TLS 1.3 in transit
  • Zero-knowledge proofs for sensitive data
  • No raw financial data stored on-chain

Next Steps​