GrievanceFlow is a production-oriented, AWS-native grievance intelligence platform designed for high-scale public-service workflows. It supports multilingual voice/text intake, AI-powered triage, semantic de-duplication, policy-grounded auto-resolution, human-in-the-loop adjudication, hotspot analytics, and enterprise security controls.
Traditional grievance systems are highly manual and reactive. GrievanceFlow adds an intelligence layer that:
- accepts citizen complaints from WhatsApp and web channels;
- converts vernacular voice/text into structured grievance signals;
- identifies duplicates and clusters related incidents;
- auto-resolves low-risk informational cases with citation-backed responses;
- escalates high-risk/complex cases to officers with pre-drafted context;
- provides real-time analytics for operations and policy interventions.
flowchart LR
Citizen[Citizen WhatsApp/PWA] --> APIGW[API Gateway]
APIGW --> Intake[Lambda intake-api]
Intake --> SQS[SQS workflow queue]
SQS --> Worker[Lambda pipeline-worker]
Worker --> AI[Lambda ai-orchestrator]
Worker --> Dedup[Lambda dedup-engine]
Worker --> RAG[Lambda rag-resolver]
Worker --> Workflow[Lambda workflow-api]
Workflow --> DDB[(DynamoDB grievances)]
AI --> AWSAI[Transcribe + Translate + Comprehend]
RAG --> Bedrock[Bedrock KB + Model]
Workflow --> External[Lambda external-integration]
External --> CPGRAMS[CPGRAMS/State adapters]
Analytics[Lambda analytics-api] --> DDB
Dashboard[React Admin Dashboard] --> APIGW
infra/terraform/- all AWS infrastructure as code.services/intake-api/- webhook/PWA intake entrypoint.services/ai-orchestrator/- multilingual NLP orchestration + RAG resolver.services/dedup-engine/- similarity matching and cluster decisioning.services/workflow-api/- ticket lifecycle, SLA, officer actions.services/analytics-pipeline/- hotspot detection and operational aggregations.services/pipeline-worker/- queue consumer orchestration across AI/workflow services.services/external-integration/- downstream portal sync and fallback export.services/common/- shared runtime helpers (for example AWS SDK bootstrap).apps/admin-dashboard/- React frontend.policy/conftest/- policy-as-code guardrails.scripts/- deployment and verification scripts.docs/- ADRs, runbooks, governance, rollout docs.
Key detailed docs:
docs/ARCHITECTURE.md- C4-style architecture and runtime sequence diagrams.docs/RUNBOOK.md- on-call operations and incident procedures.README_HACKATHON.md- 48-hour low-cost build and demo playbook.
- Citizen submits grievance via WhatsApp webhook or PWA intake.
intake-apivalidates signature/idempotency and enqueues a workflow message.pipeline-workerconsumes queue messages.ai-orchestratorperforms translation, sentiment/entity extraction, categorization, urgency scoring.dedup-enginechecks semantic similarity and cluster linkage.rag-resolverattempts citation-backed Tier-1 resolution where eligible.workflow-apipersists/update tickets and handles SLA-tracked state transitions.external-integrationsyncs resolved/escalated cases to target systems.analytics-apisupports trend/hotspot views for operations dashboard.
GrievanceFlow follows zero-trust and defense-in-depth principles:
- Least privilege IAM: dedicated Lambda role per service in
infra/terraform/iam_lambda.tf. - Secrets management: webhook signing secrets in AWS Secrets Manager.
- Encryption:
- KMS-backed encryption for data stores where configured.
- encrypted CloudWatch log groups for Lambda/API logs.
- Perimeter controls:
- AWS WAF managed rule set + IP rate limiting.
- API throttling at stage/default route settings.
- Admin route auth:
- JWT authorizer support.
jwt_mandatory_modehard-fails Terraform if JWT config is required but missing.
Implemented infrastructure controls:
- AWS CloudTrail (multi-region, validation enabled).
- AWS Config recorder + delivery channel.
- GuardDuty detector.
- Security Hub enablement.
- IAM Access Analyzer.
- account-level S3 public access blocking.
- dedicated security logs bucket with lifecycle controls.
- SQS workflow queue + DLQ redrive policy.
- Lambda tracing via X-Ray.
- CloudWatch alarms:
- API 5xx
- intake Lambda errors
- DLQ message depth
- DynamoDB PITR + TTL support.
- Multi-region DR scaffolding:
- secondary provider alias
- optional DynamoDB replica region
- S3 replication scaffolding
- DR region variable controls
- Centralized logging via CloudWatch log groups (encrypted).
- Optional OpenTelemetry hooks:
otel_enabledotel_layer_arnotel_collector_endpoint
- Optional SIEM export path:
- CloudWatch log subscription filters
- Kinesis Firehose delivery stream
- export into security log bucket / SIEM pipeline
- Python lint/test workflow in
.github/workflows/ci.yml. - Terraform
init -backend=false+validate. - Conftest policy checks on workflow definitions.
.github/workflows/security.yml:- CodeQL
- tfsec
- pip-audit
- Trivy scans
.github/dependabot.ymlfor weekly updates across actions/pip/npm.
- Python 3.11+
- Node.js 20+
- Terraform 1.7+
- AWS CLI v2
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements-dev.txt./scripts/verify-aws-sdk.ps1If needed:
aws configure sso.\.venv\Scripts\python -m ruff check .
.\.venv\Scripts\python -m pytest -qcd apps/admin-dashboard
npm install
npm run dev./scripts/preflight-check.ps1Update infra/terraform/envs/<env>.tfvars with real values:
webhook_secretbedrock_kb_idbedrock_model_arncpgrams_endpoint(optional)admin_jwt_issuer+admin_jwt_audience(mandatory whenjwt_mandatory_mode = true)alarm_email- DR/OTEL/SIEM toggles as required
./scripts/deploy-all.ps1 -Environment dev./scripts/deploy-dev.ps1
./scripts/deploy-frontend.ps1dev- rapid iteration, permissive defaults.staging- production-like verification, JWT mandatory recommended.prod- strict controls, DR enabled, SIEM export enabled, JWT mandatory.
After deployment:
POST /pwa/intakereturns202.POST /webhooks/whatsappreturns202for valid payload/signature.GET /queue?status=OPENreturns200.GET /analytics/hotspotsreturns200.- Dashboard URL from Terraform output is reachable over HTTPS.
jwt_mandatory_mode- enforce JWT config presence.admin_jwt_issuer,admin_jwt_audience- admin auth config.dr_enabled,dr_region- disaster recovery scaffolding.otel_enabled,otel_layer_arn,otel_collector_endpoint- telemetry hooks.siem_export_enabled- SIEM export pipeline toggle.api_throttle_rate_limit,api_throttle_burst_limit- API throttling.
- Terraform validation fails with JWT check:
- set
admin_jwt_issuerandadmin_jwt_audience, or disablejwt_mandatory_mode.
- set
- Webhook requests rejected:
- verify
webhook_secretand signature header mapping.
- verify
- No dashboard data:
- verify
VITE_API_BASE, API route health, and auth mode.
- verify
- No SIEM export data:
- ensure
siem_export_enabled=trueand Firehose/log subscription resources are created.
- ensure
- AWS SDK/auth failures:
- run
aws sts get-caller-identityand refresh SSO credentials.
- run
- Serverless-first architecture.
- Human-in-the-loop for high-risk outcomes.
- Grounded AI responses with citations.
- Security and compliance by design.
- Observable and auditable operations.
- Configuration-driven hardening for enterprise deployments.
Before pushing to GitHub:
- Initialize git repository and set remote.
- Confirm
.gitignoreis in place (prevents.venv,node_modules,dist, Terraform state, and local env files). - Ensure no real secrets are present in tracked files:
infra/terraform/envs/*.tfvars.env*- scripts with inline tokens
- Run local checks:
.\.venv\Scripts\python -m ruff check ..\.venv\Scripts\python -m pytest -qnpm --prefix apps/admin-dashboard run build
- Push and verify GitHub Actions:
- CI (
.github/workflows/ci.yml) - Security (
.github/workflows/security.yml) - Secret scan (
.github/workflows/secret-scan.yml)
- CI (
Repository governance files included:
SECURITY.mdCONTRIBUTING.md.gitattributes.gitignore