How krishnnavarun/ai-government-schema-eligibility-checker works
Purpose and Runtime
This is a single Next.js application for discovering government schemes, checking eligibility, applying/saving schemes, and receiving scheme-oriented chat assistance. It combines React UI pages with Next.js route handlers and a Prisma-backed database. Primary app entry/layout: client/app/layout.tsx, client/app/page.tsx.
Authentication Boundary
Authentication is implemented as API endpoints for registration, login, and current-user lookup. Shared cryptographic, JWT, and Prisma access code forms the server-side security/data boundary.
• client/app/api/auth/register/route.ts
• client/app/api/auth/login/route.ts
• client/app/api/auth/me/route.ts
• client/app/lib/crypto.ts
• client/app/lib/jwt.ts
• client/app/context/AuthContext.tsx
Scheme Catalog and User Actions
Scheme APIs provide the central domain operations: list schemes, submit applications, and retrieve saved schemes. These route handlers likely mediate persistence through Prisma and are consumed by scheme-facing pages/context.
• client/app/api/schemes/route.ts
• client/app/api/schemes/apply/route.ts
• client/app/api/schemes/saved/route.ts
• client/app/schemes/page.tsx
• client/app/context/SchemeContext.tsx
Eligibility Flow
Eligibility is a dedicated user journey: users navigate to an ID-specific eligibility page, which calls the eligibility API to evaluate a scheme against profile or supplied criteria. Profile collection is a key input boundary.
• client/app/eligibility/[id]/page.tsx
• client/app/api/schemes/eligibility/route.ts
• client/app/components/ProfileForm.tsx
Conversational Assistance
A separate chat page invokes the scheme chat API. This is the likely integration boundary for any conversational or AI-backed scheme guidance; the file tree does not identify the external provider.
• client/app/chat/page.tsx
• client/app/api/schemes/chat/route.ts
Persistence Model
Prisma defines the authoritative relational data model and migration history, with a seed script for initial data. All server-side database access should converge through the shared Prisma client rather than be instantiated in route handlers.
• client/prisma/schema.prisma
• client/prisma/migrations/20260612163359_init/migration.sql
• client/prisma/seed.js
• client/app/lib/prisma.ts
Presentation and State Flow
React pages represent public/authenticated journeys; reusable cards render scheme records, while context providers distribute auth and scheme state through the client tree. Typical control flow is page/component → context or API route → auth/JWT validation and Prisma persistence → rendered scheme/profile result.
• client/app/components/SchemeCard.tsx
• client/app/login/page.tsx
• client/app/register/page.tsx
• client/app/globals.css
Main entry points: prisma.ts Prisma client · AuthContext.tsx Auth state · SchemeContext.tsx Scheme state · layout.tsx App layout
Components 18
React UI
Next.js pages, components, and client state.
- App layout
client/app/layout.tsx - Scheme discovery
client/app/page.tsx - Login & registration
- Schemes page
client/app/schemes/page.tsx - Eligibility journey
client/app/eligibility/[id]/page.tsx - Scheme chat
client/app/chat/page.tsx - Scheme card
client/app/components/SchemeCard.tsx - Profile form · Collects eligibility inputs.
client/app/components/ProfileForm.tsx - Auth state
client/app/context/AuthContext.tsx - Scheme state
client/app/context/SchemeContext.tsx
Server APIs
Route handlers for domain operations.
- Authentication API · Registration, login, and current-user endpoints.
- Scheme actions API · Lists schemes, submits applications, and returns saved schemes.
- Eligibility API
client/app/api/schemes/eligibility/route.ts - Scheme chat API · Conversational guidance integration boundary.
client/app/api/schemes/chat/route.ts
Data & security
Shared authentication and Prisma persistence boundary.
- Password crypto
client/app/lib/crypto.ts - JWT utility
client/app/lib/jwt.ts - Prisma client · Shared server-side database client.
client/app/lib/prisma.ts - Relational database · Schema, migrations, and seed data define the authoritative catalog and user data.
client/prisma/schema.prisma
Connections 18
- App layout → Auth state: provides
- App layout → Scheme state: provides
- Scheme discovery → Scheme card: renders
- Schemes page → Scheme state: uses
- Scheme state → Scheme actions API: fetches actions
- Schemes page → Scheme card: renders
- Login & registration → Auth state: uses
- Auth state → Authentication API: auth requests
- Eligibility journey → Profile form: collects inputs
- Eligibility journey → Eligibility API: evaluates scheme
- Scheme chat → Scheme chat API: sends messages
- Authentication API → Password crypto: hashes passwords
- Authentication API → JWT utility: issues and validates
- Authentication API → Prisma client: reads and writes users
- Scheme actions API → Prisma client: reads and writes
- Eligibility API → Prisma client: reads scheme/profile data
- Scheme chat API → Prisma client: reads scheme data
- Prisma client → Relational database: persists through