FormZero is a benefits discovery assistant that helps people understand which public programs they may qualify for, what each program is worth, which documents they need, and where to apply next.
Try the deployed app: https://formzero-tan.vercel.app/
The project combines a Next.js frontend with a FastAPI backend:
- The frontend provides a warm chat-style intake flow, local U.S. benefits eligibility rules, document checklists, application ordering, English/Spanish support, and policy update summaries.
- The backend provides an API-first eligibility pipeline with FAISS-backed retrieval, citations, server-sent events, audit logging, intake analysis, service ingestion/search, and unclaimed-benefit calculations.
- Conversational intake for state, household size, income, children, pregnancy, elderly/disability status, student status, immigration status, and language.
- Rules-based screening for SNAP, Medicaid/CHIP, LIHEAP, WIC, Pell Grant, TANF, EITC, Lifeline, and SSI/SSDI.
- Confidence scores, benefit value estimates, reasons, official source links, deadlines, and application URLs.
- Document checklists with time estimates and dependency ordering, including cases where one approval helps unlock another program.
- English and Spanish user flows, including Spanish benefit-reason translation through Groq.
- Prompt-injection/adversarial-input guardrails for the benefits assistant.
- Policy update endpoint for current program changes.
- FastAPI backend with RAG over benefit-program text files for the U.S. and India.
- Streaming eligibility analysis through SSE with citations and audit ledger persistence.
- Optional Supabase storage for consented intake records.
- Next.js 16
- React 19
- TypeScript
- Tailwind CSS 4
- Groq OpenAI-compatible chat completions API
- FastAPI
- Pydantic / pydantic-settings
- FAISS
- LangChain community integrations
- Google Gemini / Google embeddings
- Supabase
- SlowAPI rate limiting
- Server-sent events
.
├── app/ # Next.js app router frontend and API routes
│ ├── api/
│ │ ├── chat/route.ts # Chat intake, Groq calls, profile parsing, eligibility response
│ │ └── updates/route.ts # Policy update API
│ ├── lib/
│ │ ├── documents.ts # Program document checklists and apply order
│ │ ├── eligibility.ts # Local U.S. benefits rules engine
│ │ ├── translate.ts # Spanish benefit-result translation
│ │ └── updates.ts # Policy update data
│ ├── layout.tsx
│ ├── page.tsx # Main FormZero experience
│ └── globals.css
├── backend/
│ ├── app/
│ │ ├── api/v1/ # FastAPI routers
│ │ ├── core/ # Settings, middleware, security
│ │ ├── db/ # Local DB and Supabase integrations
│ │ ├── models/ # Pydantic schemas
│ │ └── services/ # AI, email, vector-store services
│ ├── data/programs/ # Source program documents for RAG
│ ├── db/migrations/ # SQL migrations
│ ├── engine/ # Eligibility engine, audit ledger, unclaimed clock
│ ├── rag/ # Ingestion, retrieval, embeddings, FAISS store
│ ├── ingest_data.py
│ └── requirements.txt
├── package.json
├── requirements.txt
└── README.md
- Node.js 20 or newer
- npm
- Python 3.11 or newer
- A Groq API key for the frontend chat flow
- Optional: a Gemini API key for backend AI/RAG summaries
- Optional: Supabase credentials for consented backend persistence
- Optional: SMTP credentials for email services
Create a .env file in the project root for the Next.js app:
GROQ_API_KEY=your_groq_api_keyFor the backend, create backend/.env or keep these values in the root .env:
GEMINI_API_KEY=your_gemini_api_key
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SMTP_HOST=your_smtp_host
SMTP_PORT=587
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
SMTP_FROM_EMAIL=your_from_email
FAISS_INDEX_PATH=./data/faiss_indexOnly GROQ_API_KEY is required for the main frontend chat flow. Backend keys are needed for the corresponding backend services.
Install dependencies:
npm installStart the Next.js development server:
npm run devOpen:
http://localhost:3000
Useful scripts:
npm run dev # Start local development server
npm run build # Build production app
npm run start # Start production server
npm run lint # Run ESLintCreate and activate a virtual environment:
cd backend
python -m venv .venv
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtRun the FastAPI server:
uvicorn app.main:app --reloadOpen:
http://localhost:8000
Interactive API docs:
http://localhost:8000/docs
Base prefix:
/api/v1
Endpoints:
GET /api/v1/health- health check with environment and index status.POST /api/v1/services/ingest- index public-service documents into the vector store.POST /api/v1/services/search- search indexed services.POST /api/v1/intake/analyze- analyze a structured citizen profile and return matches, summary, and next steps.POST /api/v1/eligibility- stream eligibility events from a structured request body.GET /api/v1/eligibility/stream- stream eligibility events from query parameters.GET /api/v1/sources/{session_id}- retrieve audit citations for a previous session.GET /api/v1/unclaimed/{profile_id}- estimate unclaimed benefit value over time.
Example SSE request:
curl -N "http://localhost:8000/api/v1/eligibility/stream?query=I+am+a+farmer+in+Punjab+with+2+acres+of+land+and+annual+income+of+80000+rupees&country=india&session_id=test-123"Example unclaimed-benefit request:
curl "http://localhost:8000/api/v1/unclaimed/test-123?programs=pm_kisan,ujjwala&start_date=2022-01-01"POST /api/chat- main assistant endpoint. It collects the profile, calls Groq, extracts the profile block, runs local eligibility rules, translates Spanish results when needed, and returns benefits plus document checklists.GET /api/updates- returns policy updates. Supportsprogramsandlanguagequery parameters.
Example:
/api/updates?programs=SNAP%20(Food%20Assistance)&language=spanish
The backend includes text files under backend/data/programs/ for:
- India: PM-KISAN, Ujjwala, Ayushman Bharat, PMAY, National Scholarship Portal.
- U.S.: SNAP, Medicaid, LIHEAP, Section 8, SSI/SSDI, Pell Grant.
The frontend local rules cite official public sources through each returned benefit result.
- FormZero is a screening and navigation tool, not a final eligibility determination.
- Program rules can vary by state, household composition, and agency interpretation.
- Benefit values are estimates and should be confirmed through official agency portals.
- Some policy update values in
app/lib/updates.tsinclude a product note to verify numbers and dates before production use. - The backend can run without a FAISS index, but RAG-powered answers improve after ingestion/index loading.
No license file is currently included. Add one before distributing or accepting external contributions.