Quick Start
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js 18+
- npm, yarn, or pnpm
- A Supabase project
1. Clone and Install
git clone https://github.com/akshtjain/loan-pilot.git
cd loan-pilot
npm install
2. Environment Configuration
Create a .env.local file in the root directory and add your Supabase credentials. You will also need to configure your preferred AI provider (e.g., OpenAI or Anthropic) for document extraction.
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# AI Provider Configuration (depending on your lib/ai/provider setup)
OPENAI_API_KEY=your_openai_key
# OR
ANTHROPIC_API_KEY=your_anthropic_key
3. Database Setup
LoanPilot relies on specific database schemas and a secure signup function. Ensure your Supabase instance has the following tables:
profilesorganizationsloan_applicationsloan_documentsbank_statement_analysisfinancial_statement_analysis
Note: The application uses a custom RPC
handle_new_user_signupduring the registration process to automatically link users to organizations. Ensure this function is deployed in your Supabase SQL editor before attempting to sign up.
4. Run the Development Server
npm run dev
Open http://localhost:3000 in your browser.
5. Usage Workflow
- Register: Navigate to
/signupto create a new organization and admin account. - Create Application: Start a new loan application from the dashboard.
- Upload Documents: Use the document uploader to attach PDFs (Bank Statements, GST Returns, or Financial Statements).
- Analyze: Trigger the AI analysis. The system will process the documents via the
/api/analyze/*endpoints and generate:- Bank Analysis: Cash flow metrics, fraud flags, and EMI detection.
- Financial Analysis: Balance sheet and P&L ratios.
- Reconciliation: Cross-referencing between Bank, GST, and Financial data.
- Generate Credit Memo: Access the automated Credit Memo section to see a synthesized risk assessment based on all analyzed data.
API Quick Reference
If you are interacting with the backend programmatically, the primary analysis endpoints are:
| Endpoint | Method | Purpose |
| :--- | :--- | :--- |
| /api/documents/upload | POST | Uploads files to storage and creates DB records. |
| /api/analyze/bank-statement | POST | Processes bank PDFs for transactions and health scores. |
| /api/analyze/financial-statement | POST | Extracts P&L and Balance Sheet data. |
| /api/analyze/reconciliation | POST | Compares data across different document types. |
| /api/analyze/credit-memo | POST | Generates a final credit assessment memo. |