Inspiration
In Indian cities, "traffic time" is never just traffic. A Lucknow commute can be derailed by rain, a Bada Mangal bhandara blocking a lane, a Muharram procession in Old Lucknow, match-day crowds at Ekana Stadium, or a sudden police diversion near Charbagh. Navigation apps answer "what does the road look like right now?" — but the question commuters actually ask every morning is:
"When should I leave so I don't get late, and what hidden local factors should I worry about?"
We built Saarthi (Hindi for companion) to answer that question proactively, as an agent — not a chatbot.
What it does
Saarthi AI is a proactive commute-planning agent for Lucknow, India. Give it your origin, destination, arrival deadline, and travel mode, and it:
- Simulates the future, not the present — it sweeps multiple future departure times using TomTom's
departAtrouting to build an ETA curve, so instead of "28 minutes now" it says "leave by 8:10 AM; leaving at 8:30 crosses the risk threshold." - Fuses local risk signals in parallel — live traffic, rain forecasts, festivals, public events, and police advisories are checked simultaneously.
- Computes a deterministic 0–100 risk score from auditable factors before the LLM gets involved — Gemini narrates the verdict, but the risk math is never hidden inside the model.
- Remembers every commute — each plan is persisted to MongoDB Atlas, so Saarthi can answer "Which day is worst for my Charbagh commute?" from real history, not invented memory.
- Reasons over that memory with MongoDB MCP — the Ask Saarthi chat agent connects to the MongoDB MCP server and uses
find,aggregate, andlist-collectionstools to inspect actual stored commute data. - Streams its work live — tool progress is pushed over Server-Sent Events, so you watch the agent gather data instead of trusting hidden magic.
How we built it
- Agent orchestration: Google ADK (
LlmAgent+InMemoryRunner) drives the agent loop, with a configurable Gemini model chain and a Groq fallback. - Backend: FastAPI + Server-Sent Events on Python 3.11, streaming each tool step to the browser in real time.
- Data fusion tools: TomTom Routing (
departAtfuture-traffic sweeps + geocoding), Open-Meteo (weather), Calendarific + a curated Lucknow festival calendar, Ticketmaster (events), and a public-advisory search — all executed in parallel. - Risk engine: a deterministic formula combines traffic delay, rain, festivals, events, and advisories into a 0–100 score; Gemini then synthesizes the human-readable verdict.
- Memory (MongoDB Partner Track): MongoDB Atlas stores
commute_history(route, ETA, delay, risk, weather, festivals, events, timestamps) and anapi_cachecollection with TTL auto-expiry to avoid stale data and API overuse. The MongoDB MCP Server gives the chat agent direct, read-only tool access to those collections. - Frontend: Jinja2 templates, vanilla JavaScript, and Leaflet/OpenStreetMap for route visualization.
- Deployment: Dockerized and hosted on Hugging Face Spaces.
Challenges we ran into
- Predicting the future with present-tense APIs. Most traffic endpoints describe now; building a leave-by recommendation meant sweeping multiple
departAtsimulations and shaping them into a single ETA-vs-departure curve without blowing latency or rate limits. - Keeping the agent honest. LLMs happily invent traffic reasons. We solved it by computing the risk score deterministically from auditable inputs and limiting Gemini to explaining the result, never deciding it.
- Live-demo fragility. External APIs rate-limit and fail at the worst moments. We layered TTL caching in MongoDB, fallback LLM providers, deterministic fallback summaries, and clean SSE error frames so the app degrades safely instead of crashing on stage.
- Making MCP real, not decorative. Wiring the MongoDB MCP server into the chat agent — and proving it works — took a dedicated strict smoke test that verifies the server boots and exposes
find,aggregate, andlist-collectionsbefore we trust any memory-driven answer. - Encoding local knowledge. No global API knows that Bada Mangal bhandaras block lanes or that Charbagh has predictable station-rush peaks, so we built a curated Lucknow event-intelligence layer alongside the live feeds.
Accomplishments that we're proud of
- A commute agent that genuinely plans ahead — simulating departure windows instead of reporting current conditions.
- 121 passing unit tests plus dedicated MCP and chat smoke checks — the integration is testable, not a screenshot.
- MongoDB used three meaningful ways: durable agent memory, TTL-based API caching, and MCP tool access for the chat agent.
- Visible agency: every tool call streams to the UI, so judges can watch the agent work.
- A deployed, public, demo-safe app that survives API failures gracefully.
What we learned
- Agents earn trust through verifiability. Splitting deterministic computation (risk score) from LLM narration made answers explainable and debuggable.
- Memory is what separates an agent from a chatbot. Once commutes were persisted in MongoDB, follow-up questions like "which day is worst?" became real data queries via MCP instead of hallucinations.
- Design for failure first. Caching, fallbacks, and graceful degradation aren't polish — they're what makes a live agent demo possible.
- Local context beats global data. A small curated calendar of Lucknow-specific events added more predictive value than any single global API.
What's next for Saarthi AI
- Closing the loop: compare predicted vs. actual arrival times to continuously calibrate the risk formula per route.
- Proactive nudges: push "leave now" alerts when a planned window starts degrading.
- More cities: the architecture is city-agnostic — only the curated local-event layer needs swapping to launch in Kanpur, Varanasi, or Delhi.
- Richer MCP analytics: aggregation-powered insights like per-route weekly heatmaps and personal congestion profiles.
Built With
- calendarific
- fastapi
- geoapify
- google-adk
- google-gemini
- groq
- javascript
- jinja
- leaflet.js
- model-context-protocol
- mongodb
- mongodb-atlas
- open-meteo
- openstreetmap
- python
- server-sent-events
- ticketmaster
- tomtom
Log in or sign up for Devpost to join the conversation.