GramSetu AI is an offline-first, client-side application designed to support rural communities with tools for sanitation audits, water quality analysis, document translation, and local developmental planning. It performs all core computations—including computer vision inference and OCR text extraction—directly inside the user's browser, eliminating the need for constant cloud connectivity or server-side data processing.
Rural digitization initiatives frequently fail due to intermittent or non-existent internet connectivity. Applications that rely on cloud-based APIs for image processing, machine learning inference, and database synchronization become unusable when network coverage drops.
In rural health and sanitation monitoring, capturing photos of water sources or official local documents raises security and privacy concerns if the media must be uploaded to third-party cloud servers.
GramSetu AI addresses these issues by running all data processing local to the device. By executing models inside the browser sandbox using WebAssembly (WASM) and WebGL:
- Citizens and local administrators do not require active internet connection to run audits or analyze water test strips.
- No raw images, document text, or local metadata ever leave the user's browser, guaranteeing data privacy.
- The application runs on standard low-spec mobile and desktop hardware with zero server-side maintenance costs.
GramSetu AI is divided into four core operational modules:
An on-device computer vision workflow used to identify public litter, open sewers, and waste heaps.
- Camera Capture: Captures snapshots via the device camera or accepts local image uploads.
- YOLOv8 Inference: Runs a local YOLOv8-nano model (
public/models/yolov8n.onnx) via ONNX Runtime Web. - Scoring Engine: Evaluates cleanliness indices based on detected object counts and the bounding box area coverage.
- Report Generation: Builds and exports structured PDF audit reports locally using
jsPDF.
An colorimetric strip analysis tool for chemical water testing.
- Alignment Guide: Displays an on-screen alignment overlay to ensure correct strip placement.
- Pad Crop & Extraction: Crops the camera frame to the alignment region, isolates individual test pads, and computes the average RGB/HSL values of each pad.
- Reference Matcher: Compares average colors against reference color databases using Euclidean color distance calculation.
- Recommendations: Outputs safety assessments (e.g. for pH, Chlorine, Nitrate) and treatment recommendations.
An OCR and text simplification engine designed to translate and explain official government notices.
- Local OCR: Extracts raw text from images using
Tesseract.jsrunning inside a Web Worker. - Text Preprocessing: Upscales low-resolution images and applies adaptive contrast stretching to improve character recognition rates on skewed photos.
- Local LLM Integration: Communicates with a local Ollama server hosting the
llama3.2:3bmodel to simplify bureaucratic language and translate text between English and Kannada.
A community roadmap dashboard that maps local cleanliness metrics and tasks.
- Checklist Manager: Tracks village sanitation tasks, dynamically recalculating the overall village cleanliness score upon task completion.
- Campaign Tracker: Registers volunteers for local cleanup campaigns.
- Ward Leaderboard: Lists ward rankings based on audited cleanliness scores to encourage community participation.
- Frontend Framework: Next.js 16 (App Router)
- View Layer: React 19
- Language: TypeScript 5
- Styling: Tailwind CSS 4
- Icons: Lucide React
- AI Runtime: ONNX Runtime Web (WASM / WebGL)
- OCR Library: Tesseract.js (Web Workers)
- Document Export: jsPDF
d:\GramSetu AI
├── app/ # Next.js App Router folders
│ ├── (dashboard)/ # Central landing portal page
│ ├── settings/ # User preference controls
│ ├── swachh-audit/ # Sanitation audit module sandbox
│ ├── jaldrishti/ # Water testing module sandbox
│ ├── gramlipi/ # Document simplifier module sandbox
│ └── swachhsankalp/ # Planning & community dashboard sandbox
├── components/ # Shared UI library
│ ├── cards/ # Dashboard and stat cards
│ ├── common/ # Containers and page headers
│ ├── layout/ # Sidebar, navbar, and shell structures
│ └── ui/ # Button, card, and loading skeleton primitives
├── constants/ # Global routes, themes, and modules mappings
├── contexts/ # React context state managers (Theme, GlobalState)
├── hooks/ # Shared custom React hooks
├── public/ # Static assets
│ └── models/ # Local model weight caches
└── utils/ # Core helper utilities (cn, formatting)
GramSetu AI relies on zero cloud services for machine learning, image processing, or data persistence.
- Model Loading: When a user opens an AI module, the model (e.g. YOLOv8 ONNX file or Tesseract language training set) is requested from the local web server. The browser caches these assets.
- Inference Boundary: The model runs entirely within the browser's sandbox. Raw pixel arrays are read from HTML5 canvas components and passed to WASM/WebGL memory buffers. No image data is transmitted over the network.
- Data Storage: Audit history, checklists, ward scores, and campaign lists are stored in
window.localStorageinside the user's browser profile.
- Node.js: Version
20.xor later. - npm: Version
10.xor later. - Ollama: Required locally for the GramLipi text translation module.
- Clone the repository:
git clone https://github.com/Partha-Shankar/GramSetu_AI.git cd GramSetu_AI - Install the dependencies:
npm install
- ONNX Model Setup:
Because large model files are excluded from Git, the repository does not contain the pre-trained YOLOv8 ONNX weights in
public/models/.- Mock Inference Fallback: If the model weights are not present, the application automatically runs using a Mock Inference Adapter. Bounding boxes and scores will still render for testing, but without running active neural network inference.
- Real Inference Setup: If you have downloaded the
yolov8n.onnxmodel (e.g. from Hugging Face or another source), place the model file directly in thepublic/models/folder:Verify that the file is namedpublic/models/yolov8n.onnxyolov8n.onnxexactly, matching the configuration inapp/swachh-audit/services/detection/modelLoader.ts.
- Start the Next.js development server:
npm run dev
- Open
http://localhost:3000in your web browser.
To run translation and simplification in GramLipi, configure a local Ollama server:
- Download Ollama from ollama.com.
- Pull the required model:
ollama pull llama3.2:3b
- Run Ollama with browser origin access enabled:
- Windows (PowerShell):
$env:OLLAMA_ORIGINS="http://localhost:3000" ollama serve
- macOS / Linux:
OLLAMA_ORIGINS="http://localhost:3000" ollama serve
- Windows (PowerShell):
Generate the production compile bundle:
npm run buildNote
Additional screenshots of the camera capture flows, JalDrishti color analysis scans, and audit reports can be viewed inside the public/screenshots/ folder.
A video walkthrough of the application is available here: YouTube Video Walkthrough.
This project is open-source and distributed under the MIT License.


