Skip to content

M0izz/Rasta-Radar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

46 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒง๏ธ Rasta Radar

Know Before You Go โ€” Not After You're Stuck.

License: MIT PRs Welcome FastAPI React Gemini API

A hyperlocal waterlogging and commute advisory for Mumbai, built for the Gen AI Academy โ€” APAC Edition hackathon. Every monsoon, commuters find out a street is flooded only after they're stuck on it โ€” Rasta Radar tells you before you leave.

โญ If you find this useful or you're a fellow hackathon builder, consider starring the repo โ€” it helps it get seen. โญ

Live Demo ยท Report a Bug


๐Ÿ“– Table of Contents


๐Ÿš€ Vision

City-wide flood alerts tell you it's raining somewhere in Mumbai. They don't tell you whether your junction, on your route, is actually a problem right now.

Rasta Radar closes that gap โ€” combining live rainfall data, a curated database of historically known Mumbai flood spots, and tide timing into a transparent, explainable risk score. No black-box predictions: every score can be traced back to the exact rainfall, severity, and tide numbers that produced it.


๐ŸŒŸ Key Features

  • ๐Ÿ—บ๏ธ Live Risk Dashboard โ€” A color-coded map of known flood spots across Mumbai, ranked by current risk, with a "leave by" time for the ones that matter right now.
  • ๐Ÿ’ฌ Ask in Plain Language โ€” "Will Andheri Subway flood by 6pm?" โ€” answered by the Gemini API, grounded strictly in real risk data. It never invents a spot that isn't in the dataset.
  • โฑ๏ธ Forecast Slider โ€” Scrub forward through the next few hours of forecast rainfall to watch risk build across the evening, not just see a single snapshot.
  • ๐Ÿ”€ Route Comparison โ€” Pick two named routes and see which one passes fewer high-risk spots, with a plain-language recommendation.
  • โœ… Community Confirm/Deny โ€” Anyone nearby can mark a spot "still flooded" or "clear now," keeping the data grounded in what's actually happening on the ground.
  • ๐Ÿ” Transparent by Design โ€” The risk formula is shown in the open, not hidden behind an opaque model. See Risk Scoring Formula.

๐Ÿ—๏ธ Tech Stack

Layer Technology Purpose
Frontend React + Vite Fast, component-based UI
Mapping Leaflet.js Interactive risk map rendering
Backend FastAPI (Python) Risk scoring engine, REST API
Database Google Cloud BigQuery Persistent storage for community reports & flood logs
Weather Data Open-Meteo API Live + forecast rainfall for Mumbai
AI Gemini API Grounded natural-language ask bar
Hosting Vercel Unified frontend & backend deployment

๐Ÿ“ Architecture Diagram

graph TD
    Client([Commuter Browser])
    UI["React + Vite Frontend<br/>Dashboard ยท Spot Detail ยท Route Compare"]
    API["FastAPI Backend<br/>/api/spots /api/forecast /api/routes /api/ask"]
    Risk["Risk Scoring Module<br/>rainfall + severity + tide"]
    Meteo["Open-Meteo API<br/>(live rainfall)"]
    Spots["flood_spots.json<br/>(35 known spots)"]
    Tide["Tide Schedule<br/>(approximated)"]
    Gemini["Gemini API<br/>(NL ask bar)"]
    BigQuery["Google Cloud Platform<br/>(BigQuery DB for Community Reports)"]

    Client -->|Interacts with| UI
    UI -->|REST/JSON| API
    API --> Risk
    Risk --> Meteo
    Risk --> Spots
    Risk --> Tide
    API --> Gemini
    API -->|Read/Write Reports| BigQuery

    classDef ui fill:#1C7293,stroke:#fff,stroke-width:2px,color:#fff;
    classDef server fill:#5C7080,stroke:#fff,stroke-width:2px,color:#fff;
    classDef data fill:#F2F2F2,stroke:#212121,stroke-width:1px,color:#212121;

    class UI ui;
    class API,Risk server;
    class Meteo,Spots,Tide,Gemini,BigQuery data;
Loading

๐Ÿงฎ Risk Scoring Formula

risk_score = (rainfall_last_3h_mm ร— 0.6)
           + (historical_severity ร— 0.3 ร— 20)
           + (tide_proximity_bonus ร— 0.1 ร— 100)
  • Normalized to a 0โ€“100 scale
  • Low < 33 ยท Moderate 33โ€“66 ยท High > 66
  • tide_proximity_bonus = 1 if within ยฑ2 hours of Mumbai high tide, else 0

๐Ÿƒ Getting Started

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • A Gemini API key (optional โ€” enables the ask bar)
  • GCP Credentials (optional โ€” enables BigQuery community report persistence)

Backend

git clone https://github.com/M0izz/Rasta-Radar.git
cd Rasta-Radar/backend

pip install -r requirements.txt

# Optional: enables BigQuery persistence & Gemini ask bar
copy .env.example .env
# then edit .env and add your keys
uvicorn main:app --reload

Backend runs at http://localhost:8000

Frontend

cd ../frontend
npm install
npm run dev

Frontend runs at http://localhost:5173


๐Ÿ“ Project Structure

Rasta-Radar/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI app, route definitions
โ”‚   โ”œโ”€โ”€ risk_scoring.py      # Risk formula + leave-by logic
โ”‚   โ”œโ”€โ”€ gemini_service.py    # Gemini NL ask bar integration
โ”‚   โ”œโ”€โ”€ flood_spots.json     # 35 known Mumbai flood spots
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ””โ”€โ”€ .env.example
โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/      # Map, RiskCard, AskBar, AlertBanner, ForecastSlider
โ”‚       โ”œโ”€โ”€ pages/           # Dashboard, SpotDetail, RouteCompare
โ”‚       โ””โ”€โ”€ api/             # Fetch wrappers to the backend
โ””โ”€โ”€ vercel.json

โš ๏ธ Known Limitations

Being upfront about what this is โ€” and isn't โ€” matters more to us than looking polished:

  • Not a calibrated prediction model. The risk score is a transparent heuristic, not trained against historical flood outcomes.
  • Tide schedule is approximated from a reference date and a fixed ~12h25m period โ€” not synced with official IMD tide tables.
  • Route comparison uses labeled associations (which known spots a route passes near), not real turn-by-turn routing.

๐Ÿ—บ๏ธ Roadmap

  • Persistent storage for community confirm/deny votes (integrated with GCP BigQuery)
  • Real turn-by-turn routing (OSRM / Google Directions)
  • Sync tide schedule with official IMD data
  • Calibrate the risk model against historical flood outcomes as ground-truth data becomes available

๐Ÿค Contributing

Rasta Radar is open to contributions from the community!

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'feat: add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ›ก๏ธ License

This project is licensed under the MIT License โ€” see LICENSE for details.

Built for the Gen AI Academy โ€” APAC Edition hackathon.

About

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors