AWS Builder Center
Building Bharat-JanSeva AI with AWS Strands SDK & Ollama

Building Bharat-JanSeva AI with AWS Strands SDK & Ollama

Learn how we built Bharat-JanSeva AI, an offline welfare navigator using AWS Strands SDK, Ollama LLM, and SQLite with zero cloud cost.

1. About the Project

Over 60% of rural Indian citizens miss out on government welfare benefits simply because eligibility criteria are complex, application portals are in unfamiliar languages, or language barriers get in the way. On top of that, vulnerable citizens regularly fall victim to middleman scams—paying ₹500 to ₹1,000 in unauthorized "processing fees" or sharing sensitive OTPs for services that are officially 100% free.
To solve this, I built Bharat-JanSeva AI—an offline-first, vernacular government scheme navigator and real-time anti-fraud defender designed for small farmers, traditional artisans, low-income households, and rural citizens.
It instantly matches users to the official schemes they qualify for, provides native multi-lingual voice guidance in Indian languages, and flags middleman scams in real-time before anyone loses money.



2. Tech Stack & Architecture

The system was designed around three main constraints: ₹0 Cloud Cost (Build It Track), Offline-First Resilience, and Multi-Lingual Audio Accessibility.
  • UI / UX Layer: Built with Streamlit for an executive, card-based interface with visual document checklists and audio playback.
  • Local Inference Engine: Ollama ( qwen2.5:0.5b ) running 100% locally on  localhost  for open-source AI reasoning.
  • Dual-Engine SQLite Layer ( janseva_data.db ):
  •  response_cache : Hashes query inputs to load instant responses in <0.1 seconds.
  •  fraud_logs : Records flagged middleman scams, locations, and fees into a permanent audit trail.
  • Vernacular Audio: gTTS and pyttsx3 for synthesizing speech in Hindi, Telugu, Tamil, Kannada, and English.
+-----------------------------------------------------------------------+
| Streamlit UI / UX |
| - Multi-Lingual Prompt Input - Vernacular Audio Guidance (gTTS) |
+-----------------------------------+-----------------------------------+
|
v
+-----------------------------------------------------------------------+
| AWS Strands Agents SDK |
| - Guardrails & Safety Prompts - Custom Python Tool Routers |
+-----------------+-----------------------------------+-----------------+
| |
v v
+-----------------------------------+ +-------------------------------+
| @tool search_schemes | | @tool evaluate_fraud_risk |
| - Acreage & Keyword Matching | | - Scam Alerts & Incident Logs |
+-----------------+-----------------+ +-----------------+-------------+
| |
+-----------------+-----------------+
|
v
+-----------------------------------------------------------------------+
| Dual SQLite Engine & Local Ollama Model |
| - qwen2.5:0.5b via Ollama (100% Offline LLM Reasoning) |
| - SQLite Caching (<0.1s load time) & Real-Time Fraud Audit Logs |
+-----------------------------------------------------------------------+
  • 3. How You Have Used AWS
For AI agent orchestration, I integrated the open-source AWS Strands Agents SDK ( strands ).
from strands import Agent, tool
from strands.models.ollama import OllamaModel

@tool
def search_schemes(occupation_keyword: str, land_acres: float = 0.0) -\> str:
"""Searches official government schemes using dynamic keywords and land acreage limits."""
# Custom python logic matching schemes from verified JSON storage
pass

@tool
def evaluate_fraud_risk(fee_demanded: float, asking_for_otp_or_passcode: bool, location: str = "Unknown", user_query: str = "") -\> str:
"""Evaluates fraud risk and logs suspicious entries to the SQLite audit database."""
if fee_demanded \> 0 or asking_for_otp_or_passcode:
db.log_fraud(user_query, fee_demanded, location, "HIGH_RISK")
return f"🚨 RED FLAG SCAM ALERT: Official government applications are 100% FREE. The requested fee of ₹{fee_demanded} is illegal. Never share OTPs!"
return "✅ SAFE: Application is 100% free through official government portals."
SDK Agent Initialization: Configured the Agent class from strands to handle decision loops, system prompt guardrails (PII redaction and out-of-scope refusals), and tool invocation.

Local Endpoint Binding: Bound the AWS Strands Agent to a local OllamaModel host running qwen2.5:0.5b, allowing full agentic tool-calling workflows to run offline with ₹0 cloud cost.

  • 4. Learning & Growth Building Bharat-JanSeva AI provided key insights into AI engineering and edge deployment:
Tool Calling Precision: I learned how to structure function signatures and docstrings using the AWS Strands SDK so that smaller local models can perform accurate tool routing without input syntax errors.
Prompt Hardening: Engineered strict system prompts to prevent jailbreaks, enforce PII redaction, and keep the agent strictly focused on social welfare.
Offline Social Impact: Proved that impactful, multi-lingual AI solutions can operate locally on modest hardware to defend vulnerable citizens against financial scams.
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