Skip to content

SafeVixAI

License Code of Conduct Issues Stars

AI Emergency Response + DriveLegal + RoadWatch — Three Problem Statements, One App

IIT Madras Road Safety Hackathon 2026 | Team Submission Total infrastructure cost: Rs. 0 — 100% free and open source

Metric Value
Features 25/25 COMPLETE
Unit Tests 2,829 passing — Backend 1,365 / Chatbot 892 / Frontend 572
E2E Tests 45/55 passing (10 infra limitations)
LLM Providers 9-provider fallback chain
Services 3 (frontend :3000, backend :8000, chatbot :8010)

What SafeVixAI Does

Module What it does Works Offline?
Emergency Locator Find nearest hospital/police/ambulance using GPS Yes — 25 Indian cities
AI Chatbot Answer traffic law + first aid questions Yes — Phi-3 Mini in browser
Challan Calculator Exact MVA 2019 fines with state overrides Yes — DuckDB-Wasm
Road Reporter Report potholes, auto-routes to NHAI/PWD/PMGSY Yes — offline queue

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • Git

Backend

cd backend
python -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # Linux/Mac
pip install -r requirements.txt
cp .env.example .env            # Fill in your keys
uvicorn main:app --reload --port 8000

Verify: http://localhost:8000/health

Chatbot Service

cd chatbot_service
python -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # Linux/Mac
pip install -r requirements.txt
cp .env.example .env            # Fill in your LLM keys
uvicorn main:app --reload --port 8010

Verify: http://localhost:8010/health

Frontend

cd frontend
npm install
cp .env.local.example .env.local   # Fill in your keys
npm run dev

Verify: http://localhost:3000


Project Structure

SafeVixAI/
├── backend/           FastAPI Python 3.11 + PostgreSQL/PostGIS (port 8000)
├── chatbot_service/   FastAPI Agentic RAG Chatbot + 9 LLM providers (port 8010)
├── frontend/          Next.js 15 + React 19 TypeScript PWA (port 3000)
├── docs/              Complete technical documentation
├── chatbot_docs/      Documentation specifically for Chatbot Service
├── scripts/           Global data pipeline scripts
│   ├── app/           DB-dependent scripts (seed_emergency, seed_nhp_hospitals)
│   └── data/          Pure Python scripts — no DB needed (fetchers, extractors)
└── .github/           GitHub Actions CI/CD

Data Intelligence

The "Intelligence Layer" of SafeVixAI (3.3GB of pre-trained models, road damage datasets, and legal archives) is hosted on the Hugging Face Dataset Hub for high-performance delivery.

Explore the SafeVixAI Dataset Hub

Research Notebooks — Open in Colab

Run all notebooks through Google Colab for the easiest setup — free T4 GPU, no local install needed.

# Notebook What It Produces Open in Colab
1 YOLOv8 Pothole Detector Training ONNX road damage model Open In Colab
2 ChromaDB RAG Vectorstore Build ChromaDB index for legal RAG Open In Colab
3 Accident EDA & Hotspot Generator Blackspot seed CSV + heatmap Open In Colab
4 Roads Data Processing Sampled PMGSY GeoJSON Open In Colab
5 Risk Model ONNX Training Risk scoring ONNX model Open In Colab

Scripts Architecture

All script folders follow the same app/ vs data/ split:

Folder app/ data/
scripts/ 5 files (DB seeders) 16 files (fetchers, extractors, verifiers)
backend/scripts/ 12 files (DB/Redis/PostGIS loaders) 22 files (pure data transforms)
chatbot_service/scripts/ 2 files (DB wrapper) 7 files (Pro Overpass fetchers)

data/ scripts run standalone with no database. app/ scripts require a live backend stack.

The data/ scripts are also mirrored on the Hugging Face Dataset Hub so researchers can reproduce the dataset without cloning the full app.

Read docs/Agent.md first — it gives a complete overview of the entire application.


Tech Stack

Backend: FastAPI, SQLAlchemy, PostGIS, Redis, DuckDB, Overpass/Nominatim

Chatbot Service: FastAPI, ChromaDB, LangChain, 9 LLM providers (Groq, Gemini, Sarvam AI, etc.), IndicSeamless Speech

Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS, MapLibre GL, WebLLM, DuckDB-Wasm, Transformers.js

Infra: Vercel, Render.com, Supabase, Upstash, GitHub Actions — all free tier


Security Hardening

Layer Protection File
CORS Fail-fast RuntimeError if wildcard * in production backend/core/config.py, chatbot_service/config.py
Auth JWT Bearer tokens + guest auth + service-to-service API key backend/api/v1/auth.py, frontend/lib/store.ts
LLM Safety 12-pattern prompt injection guard + SafetyChecker chatbot_service/providers/base.py, agent/safety_checker.py
LLM Timeout asyncio.wait_for() on every provider call chatbot_service/providers/router.py
Error Boundary Global React error boundary prevents white-screen crashes frontend/app/error.tsx
Env Validation Frontend throws at import if any NEXT_PUBLIC_* URL is missing frontend/lib/public-env.ts
Theme External script (no dangerouslySetInnerHTML) frontend/public/theme-init.js
ALLOWED_HOSTS Host header validation middleware backend/middleware/allowed_hosts.py

Documentation

File Contents
docs/Agent.md START HERE — complete app overview for new developers
docs/PRD.md Product requirements and evaluation criteria
docs/Features.md Every feature with technical details
docs/Architecture.md System diagrams and data flows
docs/Database.md All 7 tables with column definitions
docs/API.md All 30 endpoints with request/response examples
docs/TechStack.md All technologies with versions and purposes
docs/UIUX.md Design system, colors, component specs
docs/AI_Instructions.md How each AI layer works
docs/Security.md Auth, privacy, API security, rate limiting
docs/Deployment.md Step-by-step deployment guide
Hugging Face Hub Intelligence Layer (Models, Data, Notebooks)
SETUP.md Full installation and run guide

Live Demo

  • Frontend: https://safevixai.vercel.app
  • Backend API: https://safevixai-api.onrender.com/docs

Contributing

We welcome contributions! See CONTRIBUTING.md to get started.

License

MIT License — see LICENSE for details.


IIT Madras Road Safety Hackathon 2026