AWS Builder Center

From 'Application Rejected' to a Repairable Case: Building SevaFix on AWS

How SevaFix uses AWS to compare application answers, verified document facts, and versioned scheme policy—then turns vague failures into explainable, auditable next steps.

From "Application Rejected" to a Repairable Case: Building SevaFix on AWS

A rejected application should not become a dead end simply because the applicant was never told what went wrong.
Government-benefit applications rarely fail because a person did not care. They fail at the seams: a number in a form differs from a certificate, a document has expired, a name is written differently across records, or an important policy condition is buried in a long PDF.
The applicant may receive only "rejected", "returned", or "action required". Sometimes there is no usable reason at all.
That is the problem we built SevaFix to address for AWS Bharat Builds.
SevaFix is an evidence-first application companion. It helps a person prepare a new application, or reconstruct likely problems after an existing application is returned. It compares three things:
  1. what the applicant declared;
  1. what their reviewed documents actually support; and
  1. what a versioned, human-reviewed policy requires.
Generative AI explains the evidence. It does not decide eligibility.
The result is not a government verdict. It is an auditable preparation check that answers three practical questions:
  • What did SevaFix find?
  • Why does it matter?
  • What can the applicant do next?
Try the deployed application:  Open SevaFix on AWS 
Important: SevaFix does not submit applications, guarantee eligibility, or replace an authority's decision. Every identity, document, reference number, and status used in the demonstration is synthetic.



The real problem is not only eligibility—it is explainability

A basic eligibility checker asks a few questions and returns yes or no. That is useful, but it misses the harder operational failures:
  • the form and supporting document contain different values;
  • the uploaded file is stale, unreadable, or the wrong document type;
  • the applicant receives a rejection without a useful explanation;
  • scheme pages, guidelines, and FAQs change independently;
  • a confident AI response cannot show which rule or evidence supports it;
  • correcting a record erases the state that originally failed.
We therefore gave SevaFix a stricter design principle:
Every actionable finding must be reproducible from a versioned rule, a user-confirmed fact, or a cited policy source.
That principle changed the architecture. Instead of beginning with "a chatbot for schemes," we began with a case file, a document pipeline, and a deterministic validation engine. Generative AI sits near the end, where it is most useful: translating already-supported findings into plain language.



Two user journeys, one trusted evidence system

The product has two deliberately separate entry points.

Journey A: prepare a new application

The applicant selects a scheme, completes its structured form, uploads the required evidence, confirms extracted facts, and runs checks before continuing to the official portal.

Journey B: understand a returned application

The applicant reconstructs the submitted record, uploads the evidence they used, and optionally enters an official rejection message. That reason is helpful—but it is not required. SevaFix runs the same evidence checks and identifies the strongest supported issue without pretending to know the authority's internal decision.
Both journeys converge on one repair loop: upload evidence, confirm extracted facts, run deterministic checks, explain supported findings, and create a corrected version when necessary.
This separation matters. A person preparing an application needs guidance and prevention. A person facing a rejection needs diagnosis and recovery. The interface acknowledges that emotional and operational difference while reusing the same trusted backend.



The complete applicant workflow

The experience is designed so that the applicant always knows what is happening, which evidence is being used, and what remains unresolved.
In practice, the workflow is:
  1. Sign in. Amazon Cognito supports email/password authentication and Google federation.
  1. Choose a journey. Start a new application or understand one that was returned.
  1. Choose a scheme. The catalog exposes the schemes and support depth available in the current release.
  1. Complete the form. Fields are generated from a published scheme manifest rather than scattered across hard-coded pages.
  1. Upload evidence. The browser uploads directly to a private Amazon S3 bucket using a short-lived, checksum-bound URL.
  1. Review extraction. Amazon Textract proposes facts; the applicant confirms or corrects them.
  1. Run checks. Deterministic rules return  PASS ,  FAIL ,  REVIEW , or  BLOCKED .
  1. Freeze the reviewed record. Answers, evidence coordinates, policy version, and results become an immutable application version.
  1. Continue externally. The applicant uses the official portal and may record a redacted reference and dated status history in SevaFix.
  1. Diagnose. SevaFix explains supported inconsistencies whether or not an official rejection reason is available.
  1. Repair safely. A correction creates a new version; it never rewrites the frozen original.
  1. Run the checks again. The before-and-after record shows exactly what changed.



A concrete demonstration: one bad certificate, one repairable failure

To test the full workflow, we created a synthetic applicant named Aarav Mehta and a fictional document set for the PM-USP Central Sector Scheme of Scholarship for College and University Students.
The application declares:
Field
Synthetic value
Applicant
Aarav Mehta
Application type
Fresh
Annual family income
INR 350,000
Course mode
Regular
Academic gap
No
Conflicting scholarship
No
Board percentile
Qualifying value
Institution and admission evidence
Present
Four synthetic PDF documents accompany the application:
  • Class XII marksheet;
  • family income certificate;
  • admission and institution evidence; and
  • identity-consistency evidence.
Three documents agree with the form. The deliberately faulty income certificate says INR 900,000, while the application says INR 350,000.
That creates two different policy questions:
Question
Comparison
Result
Does the declared income satisfy the policy ceiling?
INR 350,000 vs. INR 450,000 ceiling
 PASS 
Does the application match the certificate?
INR 350,000 vs. INR 900,000 evidence
 FAIL 
Keeping those checks separate is essential. The expected value for the document-consistency rule is the value declared in the application—INR 350,000—not the policy ceiling of INR 450,000 and not the faulty certificate's INR 900,000.

First run

Outcome
Count
Passed
12
Needs fixing
1
Needs review
0
Blocked
0
Finding: The declared family income does not match the confirmed certificate value. Evidence: the application says INR 350,000 while the certificate says INR 900,000. Recommended action: review the declaration or replace the supporting certificate.
The official-reason field is intentionally blank. SevaFix still identifies the contradiction, while clearly labelling it as the strongest supported issue—not an official explanation from the authority.
The user then creates a corrected application version, replaces the faulty certificate with one showing INR 350,000, confirms the new extraction, and reruns the rules.

Corrected run

Outcome
Count
Passed
13
Needs fixing
0
Needs review
0
Blocked
0
The first failure remains in history. The new result does not erase it; it proves that a specific repair resolved a specific inconsistency.
That before-and-after result is the product in one sentence:
SevaFix turns a vague failure into a specific, testable repair.



AWS architecture: use the right kind of intelligence at each layer

Service responsibilities

Concern
AWS service
Why it fits
Web application
Amazon ECS with AWS Fargate
A conventional, persistent runtime for the Next.js frontend
Container images
Amazon ECR
Versioned image storage and vulnerability scanning
Authentication
Amazon Cognito
User pools, email/password login, and Google federation
API boundary
Amazon API Gateway
JWT validation, routing, throttling, and a stable HTTP contract
Domain operations
AWS Lambda
Independent, burst-friendly application and policy workflows
Case and audit data
Amazon DynamoDB
Low-latency access patterns with immutable version records
Documents and policy artifacts
Amazon S3
Encrypted object storage, lifecycle controls, and versioning
Durable document orchestration
AWS Step Functions
Visible state, retries, polling, and failure routing
Document extraction
Amazon Textract
Managed OCR and queried field extraction
Policy retrieval
Amazon Bedrock Knowledge Bases
Managed chunking, embeddings, and semantic retrieval
Plain-language diagnosis
Amazon Bedrock
Constrained generation over redacted findings and retrieved context
Security and operations
AWS KMS, CloudWatch, X-Ray, SQS
Encryption, observability, tracing, and dead-letter handling

Why use a container for the web tier and Lambda for the backend?

The Next.js application benefits from a stable web runtime. Backend traffic is bursty, document processing is asynchronous, and separate functions reduce the blast radius of validation, diagnosis, policy review, notifications, and deletion. This hybrid keeps the interface responsive while durable workflows continue independently.



The document pipeline: candidate facts, not automatic truth

Documents contain sensitive information and can take seconds to process. SevaFix therefore avoids sending files through the frontend server or holding an API request open while OCR completes.
The upload contract checks file type, size, and checksum. Object keys contain opaque identifiers—not names, email addresses, scheme answers, or official application numbers. Download links expire quickly and are not retained in browser storage.
Step Functions makes asynchronous work explicit. It can poll Textract, retry transient failures, preserve processing state, and route unsupported or low-confidence extraction to user review rather than silently accepting it.



Deterministic checks first; AI explanation second

This is the most important technical boundary in SevaFix.
The language model does not determine whether an application passes a rule. A deterministic engine evaluates explicit operators over versioned application fields and confirmed evidence.
A simplified rule has the following contract:
Rule property
Value
Rule ID
 fresh-income-certificate-match 
Severity
 BLOCKING 
Applies when
Application type equals  FRESH 
Declared field
 student.familyAnnualIncomeINR 
Evidence field
 document.annualIncomeINR 
Assertion
The declared and documented income values must be equal
Policy source
 pmusp-csss-guidelines 
Given the same application version, evidence set, policy version, and rule-engine version, this check produces the same result. Those coordinates are stored with every validation run so the finding can be reproduced later.
The AI layer receives a redacted package containing:
  • already-computed findings;
  • the values that produced them;
  • reviewed policy passages retrieved for those findings;
  • permitted source references; and
  • strict instructions about uncertainty and prohibited claims.
Its job is deliberately narrow:
  • explain the contradiction in plain language;
  • distinguish evidence from inference;
  • cite only the source records supplied to it;
  • recommend the next repair action; and
  • never change a  PASS  into a  FAIL , or vice versa.
If the model or retrieval layer is unavailable, the deterministic result and reviewed fallback explanation remain available. "AI unavailable" must never become "application unverifiable."



Why embeddings help—and why they are not authoritative

Policy information rarely lives in one clean database row. It is scattered across guidelines, FAQs, announcements, circulars, and scheme pages. Exact keyword matching can miss a relevant paragraph when an applicant and a policy use different language.
Embeddings help retrieve passages by meaning. For example, family earnings, parental income, and income ceiling may refer to the same concept even when the exact words differ.
SevaFix uses Amazon Bedrock Knowledge Bases for managed ingestion, chunking, service-managed embeddings, and semantic retrieval over reviewed policy artifacts. Retrieved passages provide context for explanation; they are not executable law.
Only a reviewed policy manifest can publish a deterministic rule. That boundary protects against:
  1. retrieving a semantically similar passage from the wrong scheme;
  1. ranking a superseded document above the active version;
  1. converting ambiguous prose into a rule nobody approved; and
  1. presenting model confidence as policy certainty.
Every policy claim therefore retains source identity, page or section when available, verification timestamp, content hash, effective dates, and policy version.



Policy data is a product, not a seed script

The catalog contains ten scheme records, with PM-USP carrying the deepest end-to-end implementation for the demonstration. A scheme record may be visible in the catalog before every automated check is supported; the interface must show that coverage honestly.
Each scheme package can define:
  • scheme identity, authority, official portal, and grievance links;
  • supported application types;
  • form schema and conditional fields;
  • required and conditional documents;
  • reviewed source artifacts and extracted claims;
  • deterministic rules, severity, and remediation copy;
  • benefit schedules where applicable; and
  • effective dates, verification state, and coverage depth.
The publication lifecycle is intentionally conservative: sources are discovered, fetched, hashed, compared, reviewed, versioned, and only then published. Newer approved versions supersede older ones without deleting their history, and controlled rollback remains possible.
If two official pages disagree about a deadline, SevaFix records the conflict and refuses to publish an executable deadline rule until a reviewer resolves it. That is slower than scraping the newest sentence directly into production—and intentionally so.



DynamoDB: model a case file, not a mutable form

SevaFix uses one on-demand DynamoDB table per environment. Related records share an application partition, while secondary indexes support user listings, work queues, and operational access patterns.
Representative keys include:
Record
Partition key
Sort key
Application metadata
 APP#<appId> 
 META 
Immutable application version
 APP#<appId> 
 VER#<number> 
Document metadata
 APP#<appId> 
 DOC#<documentId> 
Confirmed fact
 APP#<appId> 
 FACT#<version>#<factId> 
Validation run
 APP#<appId> 
 RUN#<runId> 
Check result
 APP#<appId> 
 CHECK#<runId>#<ruleId> 
Timeline event
 APP#<appId> 
 EVENT#<timestamp>#<id> 
Repair case
 APP#<appId> 
 REPAIR#<repairId> 
Policy version
 SCHEME#<schemeId> 
 POLICY#<effectiveFrom>#<versionId> 
Large binaries and raw OCR responses remain in S3. DynamoDB stores their coordinates, hashes, state, ownership, and searchable metadata.
The immutable version is what makes repair trustworthy. When a certificate is replaced, SevaFix does not rewrite history and pretend that the first run never happened. It creates a new version, runs a new validation, and preserves the relationship between the failed and corrected records.



Authentication, authorization, and privacy

Amazon Cognito User Pools handles authentication. Applicants can sign in using email/password or federate through Google. API Gateway validates JWTs, while the backend still enforces per-record ownership and role boundaries for applicants, policy reviewers, and administrators.
Security is layered rather than delegated to one service: authenticated identity, JWT validation, object-level ownership checks, least-privilege service roles, encryption, bounded audit logs, and a user-requested deletion workflow.
Key safeguards include:
  • S3 Block Public Access and HTTPS-only bucket policies;
  • AWS KMS encryption for S3 and DynamoDB, with key rotation;
  • opaque object keys and short-lived signed URLs;
  • checksum validation and explicit upload limits;
  • personal-data redaction before model calls;
  • no document contents or identifying values in CloudWatch metrics;
  • DynamoDB point-in-time recovery and retained data resources; and
  • a deletion worker that removes Cognito identity data, table records, and versioned personal objects.
For bank readiness, SevaFix stores only a yes/no response. It does not request or store an Aadhaar number or bank-account number.



What fought back—and what it taught us

A useful build story includes the parts that resisted.

1. Root credentials cannot assume a deployment role

Our first AWS CLI setup attempted to assume a role while using root credentials. AWS correctly rejected it. The durable fix was to create a dedicated IAM deployment user, use that identity as the source profile, and assume a scoped deployment role. Root was removed from the development workflow.
Lesson: bootstrap identity is architecture. Treat it as deliberately as application code.

2. Model access was not uniform across APIs and Regions

Direct access to the initially planned Titan embedding and Nova model path was blocked for the account. Retrying requests could not change an entitlement boundary.
We separated the two capabilities. A managed Bedrock Knowledge Base performs service-managed policy embedding and retrieval, while the diagnosis path uses an available foundation model through Amazon Bedrock. Deterministic checks continue to work if the generative path is unavailable.
Lesson: do not make one model, entitlement, or Region a single point of failure. Design retrieval, generation, and deterministic validation as independent capabilities.

3. OAuth callback URLs form a redirect graph

Google redirects to Cognito, and Cognito redirects back to the application. Localhost, the deployed ECS origin, Cognito callback configuration, the Google OAuth client, and frontend environment values had to agree exactly.
Lesson: authentication configuration is a graph of exact redirect relationships, not one checkbox.

4. Infrastructure success is not user-journey success

The ECS service existed before every browser origin and callback was updated. API and S3 CORS also needed the exact HTTPS origin, without a trailing-slash mismatch.
Lesson: deployment is complete only when the real browser journey works—not when a stack merely reaches  CREATE_COMPLETE .

5. "Latest evidence" must be explicit

During the repair demonstration, replacing the faulty certificate initially left validation reading the older document record. We corrected document ordering and selection so that current, confirmed evidence wins while previous versions remain auditable.
Lesson: event history and active state are different access patterns. Model both.

6. Navigation must follow the active validation run

The result page showed 13 passing checks, while a sidebar still displayed a cross from the previous run. The fix was to derive progress state from the latest completed validation for the active application version.
Lesson: a stale status icon can destroy trust even when the backend is correct.



Failure behavior is part of the product

SevaFix does not collapse every problem into a red cross.
Status
Meaning
User action
 PASS 
The current data and confirmed evidence satisfy this check
Continue
 FAIL 
A reproducible contradiction or unmet rule exists
Correct the form or evidence
 REVIEW 
Evidence is ambiguous, low-confidence, or policy interpretation needs attention
Confirm details or seek review
 BLOCKED 
Required evidence, policy version, or processing state is unavailable
Supply the missing dependency or retry later
This distinction matters. An unreadable certificate is not proof that the applicant fails an income condition. A missing source is not permission for the model to guess. Uncertainty must remain visible.



Verification: prove the story instead of merely narrating it

The repository includes multiple layers of verification:
  • 42 backend tests covering handlers, rules, access patterns, and API contracts;
  • frontend linting and an optimized production build;
  • infrastructure build and deployment validation;
  • a live API smoke test using a disposable Cognito identity;
  • a full Playwright browser journey against the deployed site;
  • ECR container-image scanning; and
  • machine-readable test evidence for the demonstration run.
The end-to-end browser run verified:
Verification point
Result
Scheme catalog
10 schemes available
Faulty evidence run
12 passed, 1 failed, 0 review, 0 blocked
Diagnosis without an official reason
Passed
Immutable repair draft
Passed
Corrected evidence run
13 passed, 0 failed, 0 review, 0 blocked
Final browser status
Passed
No real citizen data and no government submission were used.

Trust invariants we test

  1. A validation result always references an application version and policy version.
  1. Raw OCR never becomes confirmed evidence without an explicit confirmation path.
  1. A diagnosis cannot introduce a failure absent from structured findings.
  1. Correcting an application creates a new immutable version.
  1. Users cannot access another user's application or document.
  1. Removing the AI layer does not remove deterministic results.
  1. The active UI state follows the latest completed run for the active version.



Cost posture

Most backend components scale with use: Lambda, API Gateway, DynamoDB on-demand, S3, Step Functions, Textract, and Bedrock. The continuously running ECS/Fargate web service and its load-balancing layer form the main development baseline.
We constrain the footprint through:
  • bounded CloudWatch log retention;
  • S3 lifecycle rules for incomplete and noncurrent uploads;
  • on-demand DynamoDB capacity;
  • short-lived signed URLs;
  • asynchronous processing rather than oversized synchronous functions; and
  • optional expensive capabilities behind deployment flags.
Before serving public traffic, we would add AWS Budgets alerts, load-tested concurrency limits, explicit per-user document quotas, anomaly detection, and cost allocation by environment.



What we would build next

SevaFix is a working system, but responsible expansion matters more than a long feature list.
Our next steps are to:
  1. deepen reviewed rules and evidence contracts across every catalog scheme;
  1. publish a transparent coverage matrix for each scheme;
  1. add multilingual explanations while retaining original-language citations;
  1. build a reviewer queue for policy diffs, conflicts, and expiring evidence;
  1. add an accessible assisted-service mode for community workers;
  1. evaluate extraction and diagnosis quality against a larger synthetic benchmark;
  1. add privacy-safe notification preferences; and
  1. test recovery behavior under OCR, model, and regional service failures.
The most important non-goal remains unchanged: SevaFix should never imply that it is an official government portal or that a green check guarantees approval.



Closing thought

The most valuable role for generative AI in a public-service workflow may not be generating more content. It may be making a carefully constrained evidence trail understandable.
SevaFix uses AWS to preserve the complete trail: what the applicant declared, what the confirmed evidence supports, which policy version was applied, which deterministic rule fired, what the model was allowed to explain, and what changed in the correction. Together, those records produce an auditable next step.
When an applicant sees only "rejected," the system cannot invent certainty. But it can replace a dead end with a grounded next step—and preserve enough evidence for that next step to be challenged, corrected, and trusted.
What other high-friction public-service journey would benefit from an evidence-first repair loop?



Further reading



Built for AWS Bharat Builds. All identities, documents, reference numbers, and application events described here are synthetic. Scheme policies can change; applicants should verify current requirements on the relevant official portal.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article