Building Haqdaar: Serverless Citizen App with AWS
How we built a serverless citizen-service platform on AWS using Cedar Policy, AWS Lambda, and Amazon DynamoDB for zero-hallucination eligibility.
Every year, millions of eligible citizens—farmers, students, daily-wage workers, and low-income families—miss out on life-changing government benefits. The reason is rarely a lack of schemes; it is bureaucratic opacity, fragmented portals, complex eligibility criteria, and missed deadlines.
While AI chatbots have become popular for public services, they pose a serious danger in government welfare: hallucination. A citizen cannot afford an AI guessing whether they qualify for emergency financial aid or an examination exemption.
To solve this, we built Haqdaar—an intelligent, citizen-service platform built on AWS that replaces AI guesswork with deterministic policy verification.
The Core Philosophy: "Zero LLM Guesswork"
Instead of letting a language model guess eligibility, Haqdaar enforces a strict architectural boundary:
- AI for natural citizen interaction: Voice assistance and multilingual summaries in English, Kannada, and Hindi.
- Deterministic rules for eligibility: Every rule is an official, gazette-backed policy evaluated by AWS's open-source Cedar Policy Language.
If a farmer inputs their land holding, annual income, and state, the decision is mathematically verifiable and completely explainable.
Architecture on AWS
We architected Haqdaar as a scalable, cost-effective serverless system in the AWS
ap-south-1 (Mumbai) region using AWS SAM (Serverless Application Model):- Amazon API Gateway: Managed regional REST API exposing
/opportunities,/evaluate, and/chat.
- haqdaar-orchestrator (AWS Lambda - Node.js 20 ESM): Handles incoming requests, session state, and DynamoDB data querying.
- haqdaar-rules (AWS Lambda - Python 3.12): Houses the Cedar policy engine in a secure execution sandbox.
- Amazon S3: Stores policy files (
.cedarand.cedarschema) and hosts the static web frontend.
- Amazon DynamoDB:
-
haqdaar-opportunities: 15 verified government schemes, scholarships, and recruitment exams.
-
haqdaar-sessions: Manages session lifecycle with automatic 24-hour Time-to-Live (TTL).
-
haqdaar-eval-log: Immutable audit log recording every eligibility determination.
How We Built It on AWS
1. AWS Cedar Policy Language (AWS Open Source)
We integrated AWS's open-source Cedar policy language (
cedar-policy ). Official government eligibility criteria are codified into .cedar policies and schemas. When a citizen submits their profile, the policy engine matches facts deterministically against official requirements—producing a 100% auditable record without hallucination.2. AWS Lambda Decoupled Microservices
We decoupled routing and policy evaluation across two distinct Lambda runtimes: Node.js 20 ESM for fast web request orchestration and Python 3.12 for our Cedar policy engine.
3. Amazon DynamoDB for High-Throughput Persistence
DynamoDB's native Time-to-Live (TTL) feature automatically expires citizen conversational sessions after 24 hours without custom cleanup jobs, while sub-10ms queries ensure instantaneous scheme search.
What We Learned & What's Next
Building on AWS Serverless enabled us to take an idea from local development to a production-grade, globally accessible public service within hours. The serverless model means Haqdaar runs completely within the AWS Free Tier during normal loads, scaling seamlessly when new welfare schemes or competitive examination results are announced.
Our next step is integrating Amazon Bedrock with AWS Strands for multi-agent document analysis, allowing citizens to upload certificates directly and verify them against official requirements.
Live Application & Endpoints:
- Live Deployed App: https://haqdaar-frontend-497746198229.s3.ap-south-1.amazonaws.com/index.html
- API Gateway Endpoint: https://v35bf2tpmb.execute-api.ap-south-1.amazonaws.com/prod
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article