Gram Mitra (Rural Connect) is an end-to-end rural empowerment and agricultural support platform connecting farmers and village communities with healthcare, veterinary services, government welfare schemes, grievance redressal, produce marketplaces, and AI-powered bilingual voice mentors.
This repository contains the complete application codebase, REST API services, database schemas, and the production-grade DevOps, Cloud, Kubernetes, CI/CD, SonarQube Code Quality, and Observability infrastructure powering the Gram-Mitra platform.
- π DevOps & Cloud Architecture Overview
- π οΈ DevOps & Platform Technology Stack
- βοΈ AWS Cloud Infrastructure
- βΈοΈ Kubernetes Cluster Architecture
- π³ Docker Containerization & Docker Hub
- π SonarQube Code Quality & Security Analysis
- π Jenkins CI/CD Automation Pipeline
- π Monitoring & Observability Stack (Prometheus & Grafana)
- ποΈ Database Architecture & Supabase PostgreSQL
- π Platform Application Modules
- π Repository & Directory Layout
- βοΈ Environment Configuration
- π‘ Complete REST API Reference
- π§ͺ Testing & Quality Assurance
- π Quick Start & Operations Runbook
- β Troubleshooting & FAQs
The Gram-Mitra backend is packaged as a containerized service published to Docker Hub (ak3806/gram-mitra-backend:latest), analyzed with SonarQube, orchestrated on a Kubernetes cluster hosted on an AWS EC2 instance, automated via a Jenkins CI/CD Pipeline, and monitored in real-time with Prometheus, Grafana, Alertmanager, and Node Exporter.
ββββββββββββββββββββββββββββββββββββββββββ
β Developer Workstation β
β GitHub Repository (Push) β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β Jenkins Server β
β (Automated CI/CD) β
β - SCM Checkout β
β - npm ci (Install Dependencies) β
β - npm test (Jest / Supertest Suite) β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β SonarQube β
β Code Quality & Security Scan β
β (Quality Gate Verification) β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β [Quality Gate Passed]
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β Docker Build & Package β
β ak3806/gram-mitra-backend:latest β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββ
β Docker Hub β
β Container Registry β
βββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AWS EC2 INSTANCE β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Kubernetes Cluster (kubeadm) β β
β β Container Network Interface (Flannel) β β
β β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β Gram-Mitra Backend Workload (Deployment: 2 Replicas) β β β
β β β β β β
β β β βββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ β β β
β β β β Pod 1: gram-mitra-backend β β Pod 2: gram-mitra-backend β β β β
β β β β (Port 5000 | Node.js/Exp) β β (Port 5000 | Node.js/Exp) β β β β
β β β ββββββββββββββββ¬βββββββββββββββ ββββββββββββββββ¬βββββββββββββββ β β β
β β ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββ β β
β β ββββββββββββββββββββ¬ββββββββββββββββββββ β β
β β βΌ β β
β β Kubernetes Service: NodePort 30442 β β
β β (Routes traffic to Pods on Port 5000) β β
β β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β Monitoring & Observability β β β
β β β β β β
β β β βββββββββββββββββββββββ Scrapes βββββββββββββββββββββββββββββββββ β β β
β β β β Node Exporter β ββββββββββββββΊ β Prometheus β β β β
β β β β kube-state-metrics β Metrics β (TSDB & Queries) β β β β
β β β βββββββββββββββββββββββ βββββββββββββββββ¬ββββββββββββββββ β β β
β β β β β β β
β β β βΌ β β β
β β β βββββββββββββββββββββββββββββββββ β β β
β β β β Grafana Dashboards β β β β
β β β β (Visualization & Alerts) β β β β
β β β βββββββββββββββββββββββββββββββββ β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββ΄ββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
β Supabase PostgreSQL β β External Public APIs β
β (Cloud Hosted DB & β β - data.gov.in Schemesβ
β Auth / Storage RLS) β β - Vapi AI Voice Web β
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
| Category | Technology | Version / Specification | Purpose |
|---|---|---|---|
| Source Control | GitHub | Git Distributed SCM | Source repository, branch protection, commit hooks |
| CI/CD Automation | Jenkins | Declarative Pipeline | Continuous Integration, automated testing, image builds, zero-downtime deployment |
| Code Quality / SAST | SonarQube | Static Analysis Engine | Code quality verification, vulnerability scanning, code smell detection & Quality Gate |
| Container Engine | Docker | Node 22-Alpine Multi-Stage | Lightweight, reproducible containerization of Node.js / Express backend |
| Image Registry | Docker Hub | ak3806/gram-mitra-backend |
Centralized container image storage and distribution |
| Cloud Provider | AWS EC2 | Ubuntu Linux Instance | High-availability cloud compute host for the Kubernetes cluster |
| Orchestration | Kubernetes | kubeadm v1.28+ |
High-availability container scheduling, auto-healing, and scaling |
| Pod Networking | Flannel CNI | 10.244.0.0/16 CIDR |
Layer 3 overlay network fabric for inter-pod routing |
| Package Manager | Helm | Helm v3 | Package management for monitoring charts (kube-prometheus-stack) |
| Metrics Engine | Prometheus | Core Server + Alertmanager | Pull-based timeseries scraping for CPU, memory, HTTP request latencies |
| Visualization | Grafana | Web UI Dashboards | Real-time monitoring panels for Kubernetes nodes, pods, and application metrics |
| Cluster Metrics | kube-state-metrics | v2.x | Generates health and deployment metrics from Kubernetes API objects |
| Host Metrics | Node Exporter | DaemonSet | Collects hardware and OS-level metrics from the EC2 host |
| Cluster CLI | kubectl | CLI | Primary administrative tool for manifest application and cluster management |
| Database | Supabase | PostgreSQL 15+ | Managed relational database with connection pooling and Row-Level Security |
| Application | Node.js / Express | Node.js 18+ / Express 4.21.2 | Layered RESTful backend with Helmet, CORS, and Morgan |
| Testing | Jest & Supertest | Jest 29.7 / Supertest 7.0 | Automated integration test coverage across all domain modules |
The infrastructure runs on an AWS EC2 instance configured as the host node for the Kubernetes cluster:
AWS Cloud
βββ EC2 Instance (Ubuntu Server)
βββ Container Runtime (containerd)
βββ Kubernetes Control Plane & Worker Node (Single-Node/Multi-Node Setup)
βββ Networking (Flannel Overlay CNI)
βββ Gram-Mitra Backend (Deployment with 2 Replicas, NodePort Service)
βββ Observability Stack (Prometheus, Grafana, Node Exporter, kube-state-metrics)
To allow external access to the application, monitoring tools, and management consoles, the following inbound rules are provisioned on AWS:
| Port / Range | Protocol | Source | Purpose |
|---|---|---|---|
22 |
TCP | SSH Admin IP | Secure shell server administration |
80 / 443 |
TCP | 0.0.0.0/0 |
Web HTTP/HTTPS reverse proxy traffic |
5000 |
TCP | Cluster Internal | Gram-Mitra container internal listener |
30442 |
TCP | 0.0.0.0/0 |
Kubernetes NodePort Service (Gram-Mitra Backend public endpoint) |
8080 |
TCP | Admin IP | Jenkins Web Dashboard |
9000 |
TCP | Admin IP | SonarQube Server Web Dashboard & API |
9090 |
TCP | Admin IP | Prometheus Server Dashboard |
3000 |
TCP | Admin IP | Grafana Metrics & Alerting Dashboard |
6443 |
TCP | Cluster Nodes | Kubernetes API Server endpoint |
The Kubernetes cluster was initialized using standard kubeadm with pod overlay networking:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16Cluster network routing is powered by Flannel CNI:
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.ymlAll production manifests are maintained in k8s/:
-
Deployment (
k8s/deployment.yaml):- Replicas: 2 pods for zero-downtime availability and load distribution.
- Container Image:
ak3806/gram-mitra-backend:latest - Resource Requests & Limits:
- Requests:
100mCPU,128MiRAM - Limits:
500mCPU,512MiRAM
- Requests:
- Health Probes:
- Readiness Probe: HTTP GET
/api/v1/healthon port 5000 (initial delay: 5s, period: 10s). - Liveness Probe: HTTP GET
/on port 5000 (initial delay: 10s, period: 15s).
- Readiness Probe: HTTP GET
- Configuration Mapping: Injects application settings from
ConfigMapand secrets fromSecret.
-
Service (
k8s/service.yaml):- Type:
NodePort - NodePort:
30442 - Port:
5000β TargetPort:5000 - Accessible on EC2 via
http://<EC2-PUBLIC-IP>:30442/api/v1/health.
- Type:
-
ConfigMap (
k8s/configmap.yaml):- Stores non-sensitive runtime configurations (
PORT=5000,NODE_ENV=production,APP_NAME,API_VERSION).
- Stores non-sensitive runtime configurations (
-
Secret (
k8s/secret.yaml):- Stores base64-encoded credentials (
SUPABASE_URL,SUPABASE_ANON_KEY,SUPABASE_SERVICE_ROLE_KEY,DATA_GOV_API_KEY,VAPI_PUBLIC_KEY,JWT_SECRET).
- Stores base64-encoded credentials (
The application utilizes a lightweight multi-stage Docker build based on node:22-alpine for minimal image footprint and fast startup times.
FROM node:22-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 5000
ENV NODE_ENV=production
ENV PORT=5000
CMD ["node", "src/server.js"]Local / Jenkins Node
β
βΌ
docker build -t ak3806/gram-mitra-backend:latest .
β
βΌ
docker login -u ak3806 -p <DOCKER_HUB_TOKEN>
β
βΌ
docker push ak3806/gram-mitra-backend:latest
β
βΌ
Kubernetes Nodes pull image on rollout
# Pull and run container directly from Docker Hub:
docker run -d \
--name gram-mitra-backend \
-p 5000:5000 \
--env-file .env \
ak3806/gram-mitra-backend:latestTo enforce clean code, high test coverage, and prevent security vulnerabilities, SonarQube is integrated into the development lifecycle and the Jenkins CI/CD pipeline.
The project configuration file sonar-project.properties specifies key scanning metrics:
sonar.projectKey=gram-mitra-backend
sonar.projectName=Gram Mitra Backend
sonar.projectVersion=1.0.0
# Source & Test Code Directories
sonar.sources=src
sonar.tests=tests
sonar.sourceEncoding=UTF-8
sonar.language=js
# Exclusions
sonar.exclusions=node_modules/**,coverage/**,k8s/**,logs/**,scratch/**
sonar.test.inclusions=tests/**/*.test.js,tests/**/*.spec.js
# Test Coverage & Execution Reports
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=test-report.xmlThe pipeline enforces a strict Quality Gate:
- Bugs: 0 Blocker or Critical bugs.
- Vulnerabilities: 0 High or Critical vulnerabilities (Security Rating: A).
- Security Hotspots: 100% reviewed.
- Code Smells & Technical Debt: Maintainability Rating: A.
- Duplication: Under 3% code duplication across modules.
- Coverage: Minimum 80% line and branch test coverage.
# Generate Jest coverage report
npm test -- --coverage
# Execute SonarQube Scanner CLI
sonar-scanner \
-Dsonar.host.url=http://<SONARQUBE-IP>:9000 \
-Dsonar.login=<SONARQUBE_TOKEN>Continuous Integration and Continuous Deployment are orchestrated via a declarative Jenkinsfile ensuring every commit undergoes strict automated testing and static quality gating before reaching production:
βββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββ
β 1. Checkout β βββΊ β 2. npm Dependencies β βββΊ β 3. Unit Test β βββΊ β 4. SonarQube Scan β
βββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββ βββββββββββ¬βββββββββββ
β
ββββββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββ β [Quality Gate OK]
β 8. Rollout Status OK β βββ β 7. K8s Manifests β βββ β 6. Docker Push β βββββ€
ββββββββββββββββββββββββ βββββββββββββββββββββ βββββββββββββββββββ β 5. Docker Build
- Stage 1: Checkout: Pulls latest commit from the active Git branch via SCM.
- Stage 2: Install Dependencies: Executes
npm cifor fast, reproducible dependency resolution. - Stage 3: Automated Testing: Executes
npm testrunning the Jest & Supertest integration suite with coverage tracking. - Stage 4: SonarQube Quality Analysis:
- Executes SonarQube Scanner using
withSonarQubeEnv('SonarQube-Server'). - Halts pipeline if the Quality Gate fails (
waitForQualityGate()), preventing buggy or vulnerable code from proceeding.
- Executes SonarQube Scanner using
- Stage 5: Docker Build: Packages the application into Docker image
ak3806/gram-mitra-backend:latest. - Stage 6: Registry Distribution: Pushes image to Docker Hub or loads directly into the local Kubernetes container runtime.
- Stage 7: Deploy to Kubernetes: Applies manifests (
configmap.yaml,secret.yaml,deployment.yaml,service.yaml) and triggers a rolling update:kubectl apply -f k8s/configmap.yaml kubectl apply -f k8s/secret.yaml kubectl apply -f k8s/deployment.yaml kubectl apply -f k8s/service.yaml kubectl rollout restart deployment/gram-mitra-backend
- Stage 8: Verification: Monitored by
kubectl rollout status deployment/gram-mitra-backend --timeout=120s. Automatically rolls back if pods fail readiness probes.
The production cluster is monitored using the Kubernetes-native Prometheus & Grafana observability stack installed via Helm:
# Helm installation of kube-prometheus-stack
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install monitoring prometheus-community/kube-prometheus-stack \
--namespace monitoring \
--create-namespace- Prometheus Server: Scrapes cluster metrics every 15 seconds, storing CPU, memory, network I/O, and HTTP request metrics in a time-series database.
- Node Exporter: Runs as a
DaemonSeton the EC2 instance collecting OS-level telemetry (load average, disk saturation, memory leaks). - kube-state-metrics: Monitors Kubernetes object states (pod restarts, pending pods, replica availability, deployment rollout progression).
- Grafana: Interactive visualization dashboards configured to monitor:
- Kubernetes Cluster Overview: Overall CPU and memory reservation across nodes.
- Pod Performance: Resource consumption of
gram-mitra-backendpods across the 2 replicas. - Network & Request Rates: HTTP status codes, latency, and traffic volume.
- Alertmanager: Triggers alerts for pod crash loops, memory threshold breaches (>80%), or probe failures.
Gram-Mitra utilizes PostgreSQL hosted on Supabase. All DDL scripts, relationship constraints, check validations, performance indexes, and automatic triggers are defined in src/db/schema.sql.
erDiagram
PROFILES ||--o{ VILLAGE_PROBLEMS : "reports"
PROFILES ||--o{ PROBLEM_UPDATES : "updates"
PROFILES ||--o{ PRODUCTS : "lists"
PROFILES ||--o{ ORDERS : "places as buyer"
PROFILES ||--o{ ORDERS : "fulfills as seller"
HOSPITALS ||--o{ HOSPITAL_SERVICES : "provides"
VILLAGE_PROBLEMS ||--o{ PROBLEM_UPDATES : "tracks history"
PRODUCTS ||--o{ ORDERS : "purchased in"
| Table | Primary Key | Description & Key Columns |
|---|---|---|
profiles |
id (UUID references auth.users) |
Extended user profiles (full_name, phone, email, age, state, district, village, profile_image_url). |
hospitals |
id (UUID) |
Human & veterinary facilities (name, type [human | animal], address, district, state, latitude, longitude, phone, is_emergency, is_active). |
hospital_services |
id (UUID) |
Clinical services (hospital_id FK, service_name, description, available). |
village_problems |
id (UUID) |
Grievance tickets (reported_by FK, title, description, category [water, road, electricity, agriculture, healthcare, sanitation, animal, other], status [reported, under_review, in_progress, resolved, rejected], priority [low, medium, high, urgent], coordinates). |
problem_updates |
id (UUID) |
Chronological status history (problem_id FK, updated_by FK, status, comment, image_url). |
products |
id (UUID) |
Farmer marketplace listings (seller_id FK, name, category, price, unit, quantity, is_available, district, state). |
orders |
id (UUID) |
Marketplace orders (product_id FK, buyer_id FK, seller_id FK, quantity, unit_price, total_price, status, payment_method, payment_status). |
ngos |
id (UUID) |
Accredited partner NGOs (name, category, phone, email, address, district, state, services, is_active). |
myths |
id (UUID) |
Myth vs Fact entries (title, myth, fact, explanation, category, language, source, is_verified). |
- π₯ Rural Healthcare & Veterinary Network:
- Dual directory of Human Hospitals (PHCs, CHCs, Civil Hospitals) and Veterinary Clinics.
- Real-time GPS radius search using Haversine formula calculation.
- 24/7 Emergency Facilities & National Helplines:
108(Ambulance),102(Mother & Child),104(Health Advice),1962(Veterinary Emergency),112(National All-in-One Emergency).
- π’ Village Grievance Redressal:
- Geotagged issue submission for rural infrastructure problems.
- Status transitions with full historical audit logs.
- ποΈ Government Schemes Integration:
- Live query integration with data.gov.in PM-KISAN dataset with resilient in-memory caching and fallbacks.
- Curated directory for PMAY-G, MGNREGA, PMFBY, Ayushman Bharat.
- πΎ Farmer Produce Marketplace:
- Direct farmer-to-buyer transactions.
- Real-time stock validation, automated inventory deduction, and cancellation inventory rollback.
- π€ Partner NGOs Directory:
- Search non-profits by domain (agriculture, water conservation, education, women empowerment).
- π‘ Myth vs Fact (Superstition Buster):
- Debunking rural misconceptions with verified medical, agricultural, and scientific citations.
- ποΈ AI Voice Mentor Assistant:
- Bilingual voice interface powered by Vapi Web SDK for low-literacy rural accessibility.
backend/
βββ src/
β βββ server.js # Entry point, HTTP listener & graceful shutdown handlers
β βββ app.js # Express application setup, security headers & route mounting
β βββ config/ # Environment & Supabase initialization
β βββ controllers/ # Request handlers & validation logic
β βββ routes/ # Express Router modular definitions (/api/v1)
β βββ services/ # Core business logic & external integrations
β βββ models/ # Database table schema constants
β βββ middleware/ # Auth (requireAuth/optionalAuth), Error Handler, 404
β βββ utils/ # Structured logger & standardized JSON formatters
β βββ db/
β β βββ schema.sql # PostgreSQL DDL (Tables, Indexes, Triggers)
β βββ scripts/
β βββ test-db.js # Supabase connectivity & schema check script
βββ tests/ # Jest & Supertest integration test suite
βββ k8s/ # Kubernetes production manifests
β βββ configmap.yaml # ConfigMap (runtime environment parameters)
β βββ deployment.yaml # Deployment (2 Replicas, Probes, Limits)
β βββ secret.yaml # K8s Secrets (Supabase, API tokens)
β βββ secret.example.template # Secret template for base64 encoding
β βββ service.yaml # NodePort Service (Port 5000 -> 30442)
βββ Dockerfile # Lightweight Node 22-Alpine container image
βββ docker-compose.yml # Local multi-container Docker runner
βββ docker-compose.jenkins.yml # Jenkins runner configuration
βββ Jenkinsfile # 8-stage automated CI/CD pipeline with SonarQube & K8s
βββ JENKINS_SETUP.md # Complete Jenkins setup & configuration guide
βββ sonar-project.properties # SonarQube code quality & SAST configuration
βββ .env.example # Environment variables template
βββ package.json # Project dependencies & npm scripts
Create .env in backend/ by copying .env.example:
# Server Configuration
PORT=5000
NODE_ENV=production
APP_NAME=Gram Mitra Backend
API_VERSION=v1
CORS_ORIGIN=*
# Database / Supabase Configuration
DATABASE_URL=postgresql://postgres:[PASSWORD]@db.[REF].supabase.co:5432/postgres
SUPABASE_URL=https://[YOUR-PROJECT].supabase.co
SUPABASE_ANON_KEY=[YOUR-ANON-KEY]
SUPABASE_SERVICE_ROLE_KEY=[YOUR-SERVICE-ROLE-KEY]
# Government Schemes API (data.gov.in)
DATA_GOV_API_KEY=[YOUR-DATA-GOV-KEY]
DATA_GOV_BASE_URL=https://api.data.gov.in/resource
DATA_GOV_RESOURCE_ID=388208c6-d82a-4190-90df-91aa2c326fec
DATA_GOV_CACHE_TTL_MS=600000
# Vapi AI Voice Agent
VAPI_PUBLIC_KEY=[YOUR-VAPI-KEY]
VAPI_ASSISTANT_ID=[YOUR-VAPI-ASSISTANT-ID]
VAPI_SERVER_SECRET=[YOUR-WEBHOOK-SECRET]All routes are mounted under /api/v1 (with / available for root health checks).
GET /β Root service verification (200 OK)GET /api/v1/healthβ System status, uptime, and memory diagnostics (200 OK)
POST /api/v1/auth/registerβ Register user with email/phone & profilePOST /api/v1/auth/loginβ Sign in and receive JWT tokenGET /api/v1/auth/meβ Fetch authenticated user profile (Bearer Auth)PUT /api/v1/auth/meβ Update user profile details (Bearer Auth)POST /api/v1/auth/logoutβ Invalidate user session (Bearer Auth)
GET /api/v1/healthcareβ Browse all facilities (filters:type,district,search,radius)GET /api/v1/healthcare/nearbyβ Real-time GPS search (lat,lng,radiusin km)GET /api/v1/healthcare/emergencyβ 24/7 facilities and national emergency helplinesGET /api/v1/healthcare/hospitalsβ List human hospitals, PHCs, & CHCsPOST /api/v1/healthcare/hospitalsβ Register a human hospitalGET /api/v1/healthcare/veterinaryβ List animal clinics & dispensariesPOST /api/v1/healthcare/veterinaryβ Register a veterinary facilityGET /api/v1/healthcare/services/catalogβ Curated rural health programs
POST /api/v1/village-problemsβ Report a village problem with coordinates & categoryGET /api/v1/village-problemsβ Query tickets (filters:status,priority,district,village)GET /api/v1/village-problems/statsβ Resolution rate & category statisticsPATCH /api/v1/village-problems/:id/statusβ Advance status (reportedβin_progressβresolved)GET /api/v1/village-problems/:id/historyβ Chronological audit trail of updates
GET /api/v1/schemesβ Live PM-KISAN village beneficiary records from data.gov.inGET /api/v1/schemes/catalogβ Flagship rural schemes catalog (PMAY-G, MGNREGA, PMFBY)GET /api/v1/schemes/statsβ Aggregated beneficiary metrics
GET /api/v1/marketplace/productsβ Browse produce with filters (category,price,district)POST /api/v1/marketplace/productsβ Publish new produce listingPOST /api/v1/marketplace/ordersβ Place order with atomic stock deductionPATCH /api/v1/marketplace/orders/:id/statusβ Advance order state (pendingβdelivered)DELETE /api/v1/marketplace/orders/:idβ Cancel order with automatic stock rollback
GET /api/v1/ngosβ Directory of non-profit partnersGET /api/v1/ngos/categoriesβ Categories with distribution metricsPOST /api/v1/ngosβ Register new partner NGO
GET /api/v1/superstitionsβ Myth vs Fact entriesGET /api/v1/superstitions/randomβ Random Myth of the DayPATCH /api/v1/superstitions/:id/verifyβ Verify entry with scientific citation
POST /api/v1/voice/sessionβ Initialize Vapi Web Call sessionGET /api/v1/voice/configβ Retrieve mentor configurationsPOST /api/v1/voice/webhookβ Vapi webhook listener for call reports & tool calls
Integration tests validate all endpoints and logic using Jest and Supertest:
# Run complete test suite
npm test
# Run tests with code coverage output for SonarQube
npm test -- --coverage
# Run a specific domain suite
npx jest tests/healthcare.test.js
npx jest tests/marketplace.test.js
npx jest tests/problem.test.js# 1. Install dependencies
npm install
# 2. Check Supabase connection
npm run db:check
# 3. Start development server with auto-reload
npm run dev# 1. Apply Kubernetes ConfigMap & Secrets
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secret.yaml
# 2. Deploy Gram-Mitra Backend (2 Replicas) & NodePort Service
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
# 3. Verify Rollout & Pod Status
kubectl get pods -l app=gram-mitra-backend -o wide
kubectl get service gram-mitra-backend-service
# 4. Access Backend via NodePort 30442
curl http://<AWS-EC2-PUBLIC-IP>:30442/api/v1/health- Check the Jenkins Console Output and your SonarQube project dashboard at
http://<SONARQUBE-IP>:9000. - Address any blocker/critical bugs or missing test coverage in your source code.
- Ensure
coverage/lcov.infois generated before scanner execution by runningnpm test -- --coverage.
- Run
kubectl describe pod <pod-name>andkubectl logs <pod-name>to inspect startup errors. - Ensure
k8s/secret.yamlhas valid base64-encoded strings forSUPABASE_URLandSUPABASE_ANON_KEY.
- Check your AWS EC2 Security Group inbound rules. Ensure port
30442is open for TCP traffic from0.0.0.0/0. - Verify the NodePort service is running:
kubectl get svc gram-mitra-backend-service.
- Verify the pods have proper labels (
app: gram-mitra-backend). - Add a
ServiceMonitoror pod annotation indeployment.yaml(prometheus.io/scrape: "true",prometheus.io/port: "5000").
- Project: Gram Mitra (Rural Connect)
- License: ISC
- Docker Image:
ak3806/gram-mitra-backend:latest - Data Source: Open Government Data (OGD) Platform India (data.gov.in)