# saanvisanjay13/benefai-legal-intelligence architecture

> Architecture diagram of the GitHub repository saanvisanjay13/benefai-legal-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saanvisanjay13/benefai-legal-intelligence
- Repository: https://github.com/saanvisanjay13/benefai-legal-intelligence

## Overview

BenefAI is a beneficiary-intake and AI-assisted verification web app. The implemented flow collects applicant details, stores a beneficiary record, submits it to a server route for Groq scoring, and returns the result; the route also updates the record and writes an audit log. Audit and dashboard views provide oversight, though the dashboard excerpt uses hard-coded sample metrics. The README describes additional capabilities whose implementation is not present in the supplied tree, so they are shown as documented but unverified subsystems.

Main entry points: [`app/api/verify/route.ts`](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/api/verify/route.ts) (Verification route), [`lib/supabase.ts`](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/lib/supabase.ts) (Supabase client), [`components/IntakeForm.tsx`](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/components/IntakeForm.tsx) (Beneficiary form), [`app/page.tsx`](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/page.tsx) (Intake page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Intake"]
  node_home["Intake page<br/>[page.tsx]"]
  node_intake_form["Beneficiary form<br/>[IntakeForm.tsx]"]
end

subgraph group_verification["Verification and storage"]
  node_verify_api["Verification route<br/>[route.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
end

subgraph group_oversight["Oversight"]
  node_audit_page["Audit log<br/>[page.tsx]"]
  node_dashboard["Metrics dashboard<br/>[page.tsx]"]
end

subgraph group_documented["Documented extensions"]
  node_duplicate["Duplicate detection"]
  node_eligibility["Scheme eligibility"]
  node_letters["Multilingual letters"]
  node_document_ocr["Document OCR"]
  node_satellite["Satellite checks"]
  node_whatsapp["WhatsApp alerts"]
  node_batch["Batch CSV scoring"]
  node_fraud_viz["Fraud visualizations"]
  node_voice["Voice verification"]
  node_realtime["Realtime monitoring"]
end

node_applicant(("Applicant"))
node_groq["Groq API"]
node_supabase_db[("Supabase database")]

node_applicant -.->|"opens"| node_home
node_home -->|"renders"| node_intake_form
node_intake_form -->|"inserts applicant"| node_supabase_client
node_supabase_client -.->|"stores record"| node_supabase_db
node_intake_form -->|"posts details"| node_verify_api
node_verify_api -->|"requests score"| node_groq
node_verify_api -->|"updates record"| node_supabase_client
node_verify_api -->|"writes audit entry"| node_supabase_client
node_verify_api -->|"returns decision"| node_intake_form
node_audit_page -->|"reads audit logs"| node_supabase_client
node_dashboard -.->|"displays sample metrics"| node_applicant
node_applicant -.->|"screened for duplicates"| node_duplicate
node_applicant -.->|"checked for schemes"| node_eligibility
node_eligibility -.->|"explained in letters"| node_letters
node_applicant -.->|"documents processed"| node_document_ocr
node_applicant -.->|"address assessed"| node_satellite
node_applicant -.->|"notified"| node_whatsapp
node_applicant -.->|"bulk scored"| node_batch
node_fraud_viz -.->|"visualizes risk"| node_applicant
node_applicant -.->|"verified by voice"| node_voice
node_realtime -.->|"monitors changes"| node_supabase_db

click node_home "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/page.tsx"
click node_intake_form "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/components/IntakeForm.tsx"
click node_verify_api "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/api/verify/route.ts"
click node_supabase_client "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/lib/supabase.ts"
click node_audit_page "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/audit/page.tsx"
click node_dashboard "https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/dashboard/page.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_intake_form toneBlue
class node_verify_api,node_supabase_client,node_supabase_db toneAmber
class node_audit_page,node_dashboard,node_groq toneMint
class node_duplicate,node_eligibility,node_letters,node_document_ocr,node_satellite,node_whatsapp,node_batch,node_fraud_viz,node_voice,node_realtime toneRose
class node_applicant toneIndigo
```

## Components

### Intake

- [Intake page](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/page.tsx): `app/page.tsx`
- [Beneficiary form](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/components/IntakeForm.tsx): `components/IntakeForm.tsx`

### Verification and storage

- [Verification route](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/api/verify/route.ts): `app/api/verify/route.ts`
- [Supabase client](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/lib/supabase.ts): `lib/supabase.ts`

### Oversight

- [Audit log](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/audit/page.tsx): `app/audit/page.tsx`
- [Metrics dashboard](https://github.com/saanvisanjay13/benefai-legal-intelligence/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`

### Documented extensions

- **Duplicate detection**
- **Scheme eligibility**
- **Multilingual letters**
- **Document OCR**
- **Satellite checks**
- **WhatsApp alerts**
- **Batch CSV scoring**
- **Fraud visualizations**
- **Voice verification**
- **Realtime monitoring**

### Other components

- **Applicant**
- **Groq API**
- **Supabase database**

## Connections

- Applicant → Intake page: opens
- Intake page → Beneficiary form: renders (evidence: `app/page.tsx`)
- Beneficiary form → Supabase client: inserts applicant (evidence: `components/IntakeForm.tsx`)
- Supabase client → Supabase database: stores record (evidence: `README.md`)
- Beneficiary form → Verification route: posts details (evidence: `components/IntakeForm.tsx`)
- Verification route → Groq API: requests score (evidence: `app/api/verify/route.ts`)
- Verification route → Supabase client: updates record (evidence: `app/api/verify/route.ts`)
- Verification route → Supabase client: writes audit entry (evidence: `app/api/verify/route.ts`)
- Verification route → Beneficiary form: returns decision (evidence: `components/IntakeForm.tsx`)
- Audit log → Supabase client: reads audit logs (evidence: `app/audit/page.tsx`)
- Metrics dashboard → Applicant: displays sample metrics
- Applicant → Duplicate detection: screened for duplicates (evidence: `README.md`)
- Applicant → Scheme eligibility: checked for schemes (evidence: `README.md`)
- Scheme eligibility → Multilingual letters: explained in letters (evidence: `README.md`)
- Applicant → Document OCR: documents processed (evidence: `README.md`)
- Applicant → Satellite checks: address assessed (evidence: `README.md`)
- Applicant → WhatsApp alerts: notified (evidence: `README.md`)
- Applicant → Batch CSV scoring: bulk scored (evidence: `README.md`)
- Fraud visualizations → Applicant: visualizes risk (evidence: `README.md`)
- Applicant → Voice verification: verified by voice (evidence: `README.md`)
- Realtime monitoring → Supabase database: monitors changes (evidence: `README.md`)
