How ayushptl1810/hackanovatcet-2026 works
1. Purpose and Runtime Entry Points
Haqq is a civic-tech platform that matches Indian citizens to welfare schemes through a React web portal and Twilio phone hotline. The backend is a FastAPI application started from backend/main.py; the browser SPA starts at frontend/src/main.jsx and is composed by frontend/src/App.jsx.
2. API and Channel Boundary
FastAPI route modules separate citizen, scheme, assistant, identity/KYC, location, and voice webhook interfaces. Web and IVR channels should converge on shared services rather than duplicate matching logic.
• backend/routes/citizen_routes.py
• backend/routes/schemes_routes.py
• backend/routes/voice_routes.py
The frontend API client in frontend/src/api.js is the browser-to-backend boundary. Major user surfaces include dashboard, scheme browsing/wizard, assistant, autofill, and face gate components.
3. Identity, Authentication, and Verified Profile
Citizen/operator access uses JWT sessions and PIN-oriented authentication; security/config are centralized in core modules. KYC and DigiLocker retrieval enrich the citizen profile used by matching and application autofill.
• backend/services/auth_service.py
• backend/core/security.py
• backend/routes/kyc_routes.py
DigiLocker is provider-based: route code delegates through a factory/interface, allowing mock, sandbox, or MeriPehchaan implementations selected by configuration.
• backend/services/digilocker/base.py
• backend/services/digilocker/factory.py
• backend/services/digilocker/meripehchaan_provider.py
4. Scheme Data Lifecycle
Scheme records are persisted through SQLAlchemy models and exposed through a cache-backed search/matching layer. Ingestion scrapes or imports source data, extracts/enriches eligibility rules, then scheduler-driven refreshes atomically replace cached scheme datasets.
• backend/db/models.py
• backend/services/ingestion.py
• backend/services/scheme_cache.py
Source-specific acquisition and repair tooling are isolated from serving paths.
• backend/scraper/myscheme_scraper.py
• backend/scraper/ingest_openny_dataset.py
• backend/services/scheduler.py
5. Discovery, Eligibility, and AI Reasoning
The central decision pipeline accepts a citizen profile or stated need, retrieves candidate schemes via filters/semantic search, evaluates structured eligibility, resolves incompatible benefits, and returns ranked/explainable matches.
• backend/services/semantic.py
• backend/services/eligibility.py
• backend/services/conflict_graph.py
Unstructured scheme text is converted into rules by extraction services, while assistant endpoints use the profile and matching context for grounded conversation/explanations.
• backend/services/rule_extractor.py
• backend/services/extractor.py
• backend/routes/assistant_routes.py
Groq-hosted LLM capability and sentence-transformer/scikit-learn-style semantic search are material external AI dependencies.
6. Voice, Messaging, and Assisted Access
Twilio Voice webhooks implement multilingual IVR: DTMF or spoken input is processed through Sarvam ASR, shared semantic/eligibility services produce results, and Sarvam/Twilio TTS responds. Registered callers can be identified from their phone number.
• backend/routes/voice_routes.py
• backend/services/sarvam_service.py
• backend/services/scheme_matching_service.py
The same locator service supports web and hotline CSC lookup; notification utilities integrate Twilio SMS and WhatsApp.
• backend/services/csc_locator_service.py
• backend/routes/locate_routes.py
• backend/utils/notifications.py
7. Infrastructure and Client Experience
Backend runtime dependencies are FastAPI/Uvicorn, SQLite via SQLAlchemy, Redis cache, APScheduler, and external Twilio, Sarvam, Groq, DigiLocker/MeriPehchaan, and KYC sandbox APIs. The Vite/React 19 frontend provides localized citizen flows, including scheme discovery and assisted application generation.
• frontend/src/components/SchemeBrowser.jsx
• frontend/src/components/Assistant.jsx
• frontend/src/components/AutofillAgent.jsx
Main entry points: main.py FastAPI runtime · scheme_matching_service.py Scheme matching · voice_routes.py Twilio voice webhook · scheme_cache.py Scheme cache
Components 22
Web client
- React SPA
frontend/src/main.jsx - App composition
frontend/src/App.jsx - Citizen flows · Discovery, assistant, and autofill surfaces.
frontend/src/components/SchemeBrowser.jsx - API client
frontend/src/api.js
Backend API
- FastAPI runtime
backend/main.py - Citizen and scheme APIs
backend/routes/citizen_routes.py - Assistant API
backend/routes/assistant_routes.py - KYC API
backend/routes/kyc_routes.py - Twilio voice webhook
backend/routes/voice_routes.py - Auth and JWT/PIN
backend/services/auth_service.py - DigiLocker providers · Selects mock, sandbox, or MeriPehchaan retrieval.
backend/services/digilocker/factory.py
Matching and data
- Scheme matching · Shared profile/need-to-ranked-schemes pipeline.
backend/services/scheme_matching_service.py - Semantic retrieval
backend/services/semantic.py - Eligibility and conflicts
backend/services/eligibility.py - Scheme cache
backend/services/scheme_cache.py - Scheme database
backend/db/models.py - Ingestion and refresh · Imports, extracts rules, and refreshes serving data.
backend/services/ingestion.py - Refresh scheduler
backend/services/scheduler.py
External providers
- Sarvam ASR/TTS
- Twilio Voice/SMS
- Groq and embedding models
- DigiLocker/MeriPehchaan
Connections 26
- React SPA → App composition
- App composition → Citizen flows
- Citizen flows → API client: requests
- API client → FastAPI runtime: HTTP
- FastAPI runtime → Citizen and scheme APIs
- FastAPI runtime → Assistant API
- FastAPI runtime → KYC API
- FastAPI runtime → Twilio voice webhook: webhook
- Citizen and scheme APIs → Auth and JWT/PIN: sessions
- Citizen and scheme APIs → Scheme matching: discover
- Assistant API → Scheme matching: grounded context
- KYC API → DigiLocker providers: profile enrichment
- DigiLocker providers → DigiLocker/MeriPehchaan: retrieve documents
- Twilio voice webhook → Sarvam ASR/TTS: speech input/output
- Twilio voice webhook → Scheme matching: shared matching
- Twilio voice webhook → Twilio Voice/SMS: IVR response
- Scheme matching → Semantic retrieval: retrieve candidates
- Scheme matching → Eligibility and conflicts: evaluate and rank
- Semantic retrieval → Scheme cache: search dataset
- Eligibility and conflicts → Scheme cache: scheme rules
- Scheme cache → Scheme database: persisted records
- Ingestion and refresh → Scheme database: upsert schemes
- Ingestion and refresh → Scheme cache: atomic refresh
- Refresh scheduler → Ingestion and refresh: scheduled refresh
- Semantic retrieval → Groq and embedding models: embeddings
- Assistant API → Groq and embedding models: LLM reasoning