Real-time Indian Road Hazard Detection & Crowdsourced Mapping Platform
SadakAI is a comprehensive road hazard detection and mapping platform designed specifically for Indian roads. It uses computer vision (YOLOv8) to detect potholes, cracks, speed breakers, and waterlogging from images uploaded by users.
- πΊοΈ Interactive Map - View all reported hazards on an interactive Leaflet map
- πΈ Image Detection - Upload images for AI-powered hazard detection
- π Statistics Dashboard - Comprehensive stats and trends visualization
- π Report Generation - Export hazard data as CSV reports
- π± Mobile-First - Fully responsive PWA design
- π Advanced Filtering - Filter by severity, type, and status
- π€ YOLOv8 Model - State-of-the-art object detection
- ποΈ PostgreSQL + PostGIS - Geospatial database for location data
- βοΈ Cloudflare R2 - S3-compatible object storage
- π³ Docker - Containerized deployment
- β‘ FastAPI - High-performance async backend
- π Next.js 14 - Modern React frontend
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (Next.js 14) β
β Dashboard β Map View β Upload β Reports β Stats β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β REST API
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β BACKEND (FastAPI) β
β /detect β /hazards β /reports β /stats β /upload β
βββββββββββββ¬βββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββ
β β β
ββββββΌβββββ βββββΌβββββββββ βββββββΌβββββββ
β YOLOv8 β β PostgreSQL β β Cloudflare β
β Model β β + PostGIS β β R2 Storage β
βββββββββββ ββββββββββββββ ββββββββββββββ
SadakAI/
βββ model/ # Machine Learning
β βββ data/ # Dataset configuration
β βββ notebooks/ # Training notebooks (Colab)
β βββ scripts/ # Dataset preparation scripts
β βββ weights/ # Trained model weights
β
βββ api/ # Backend API (FastAPI)
β βββ config.py # Configuration settings
β βββ main.py # Application entry point
β βββ models/ # Database models & schemas
β βββ routers/ # API endpoints
β βββ services/ # Business logic
β βββ seed.py # Demo data seeder
β βββ requirements.txt # Python dependencies
β
βββ dashboard/ # Frontend (Next.js 14)
β βββ src/
β β βββ app/ # App router pages
β β βββ components/ # React components
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utilities & API client
β βββ package.json
β
βββ docker-compose.yml # Docker orchestration
βββ .env.example # Environment variables template
βββ README.md # This file
- Python 3.11+
- Node.js 18+
- PostgreSQL 15+ (with PostGIS extension)
- Docker & Docker Compose (optional)
git clone https://github.com/your-username/SadakAI.git
cd SadakAIcd api
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment variables
cp .env.example .env
# Run the API server
uvicorn api.main:app --reloadThe API will be available at http://localhost:8000
- API Documentation:
http://localhost:8000/docs - Health Check:
http://localhost:8000/health
cd dashboard
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Run development server
npm run devThe frontend will be available at http://localhost:3000
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down| Method | Endpoint | Description |
|---|---|---|
| POST | /api/detect |
Upload image for hazard detection |
| POST | /api/detect/batch |
Batch detection for multiple images |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/hazards |
List all hazards (paginated) |
| GET | /api/hazards/{id} |
Get hazard details |
| PATCH | /api/hazards/{id} |
Update hazard status |
| DELETE | /api/hazards/{id} |
Delete hazard (soft delete) |
| GET | /api/hazards/nearby |
Get hazards near a location |
| GET | /api/hazards/bbox |
Get hazards in bounding box |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/stats/overview |
Get overview statistics |
| GET | /api/stats/trends |
Get hazard trends over time |
| GET | /api/stats/worst-roads |
Get worst areas by hazard count |
Create a .env file in the api/ directory:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/sadakai
# Cloudflare R2 Storage (optional)
R2_ENDPOINT=https://your-account.r2.cloudflarestorage.com
R2_ACCESS_KEY=your_access_key
R2_SECRET_KEY=your_secret_key
R2_BUCKET=sadakai-images
# API
API_KEY=your_api_key_here
MODEL_PATH=model/weights/best.pt
# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000The model is trained on publicly available road damage datasets:
| Dataset | Source | Description |
|---|---|---|
| RDD2022 | IEEE Big Data Cup | 47,000+ images |
| Indian Pothole Dataset | Roboflow Universe | 1,500+ Indian potholes |
| Speed Breaker Dataset | Roboflow Universe | 500+ speed breakers |
- Download datasets from the sources above
- Place images in
model/data/images/{train,val,test}/ - Run dataset preparation:
python model/scripts/prepare_dataset.py
- Open
model/notebooks/train.ipynbin Google Colab - Run the training notebook with T4 GPU
- Download trained weights to
model/weights/best.pt
pothole- Road potholescrack- Road cracksspeed_breaker- Speed breakerswaterlogging- Water accumulation
- π GPS Location - Auto-detect current location
- πΈ Camera Capture - Take photos directly
- π Clipboard Paste - Paste images from clipboard
- πΌοΈ Photo Library - Select from gallery
cd api
pytestcd dashboard
npm test# Frontend
cd dashboard
npm run build
# Backend
cd api
pip install -r requirements.txt
gunicorn api.main:app -w 4 -k uvicorn.workers.UvicornWorker| Service | Purpose | Free Tier |
|---|---|---|
| Vercel | Frontend | β |
| Railway/Render | Backend | β |
| Neon/Supabase | PostgreSQL | β |
| Cloudflare R2 | Storage | β |
See DEPLOYMENT.md for detailed deployment instructions.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for details.
This project is licensed under the MIT License - see LICENSE for details.
- Ultralytics for YOLOv8
- Road Damage Dataset creators
- OpenStreetMap for map tiles
- All contributors and testers
- Author: Roki Roy
- Email: rokiroydev@gmail.com
- GitHub: https://github.com/RoyRoki/SadakAI
- Website: https://rokiroy.in
Made with β€οΈ for safer Indian roads