About
## The problem it solves
# π Wave-Safe
> **A Unified Platform for Smarter Coastal Travel and Safety**
Wave-Safe is a unified web-based coastal safety and intelligence platform that combines real-time ocean and weather intelligence, trip planning, emergency coordination, and rescue tracking into one coastal travel experience.
## π₯ Team
**Team Name:** LazyCoders
- **Arvind Kumar** β Team Leader
- **Om Kushwaha** - **Rishabh Pal**
---
## π¨ Problem Statement
India has over **7,500 km of coastline**, but there is no unified digital platform that provides tourists with real-time beach safety intelligence and coordinated emergency response.
### Current Challenges
- No simple real-time **Safe / Caution / Unsafe** signal for beaches.
- Visitors may lack current information about ocean conditions, rip-current risks, and official hazard advisories.
- Emergency assistance can depend on a chain of separate phone calls.
- Hospitals, lifeguards, police, coast guard, rescue posts, and jurisdictions operate through disconnected records.
- There is no single system to automatically identify and coordinate the appropriate responder for an incident.
- Existing ocean and weather data is available, but it is not converted into one simple decision for a beach visitor.
---
## π‘ Solution
**Wave-Safe** bridges the gap between **real-time risk awareness and emergency response**.
The platform is designed as a travel website first, with safety intelligence integrated throughout the user's journey.
### Predict β Plan β Protect β Track
- **Predict:** Calculate a live beach safety verdict from ocean and weather data.
- **Plan:** Identify risky travel windows and suggest safer alternatives.
- **Protect:** Provide one-tap SOS with location sharing and coordinated emergency dispatch.
- **Track:** Provide live rescue tracking, acknowledgements, and ETAs.
---
## β¨ Features
### π’ Live Beach Safety
Provides a live:
- **SAFE**
- **CAUTION** - **UNSAFE**
verdict for beaches using real ocean and weather data.
### ποΈ Smart Trip Planning
- Evaluates risk across planned time windows.
- Flags potentially dangerous slots.
- Suggests safer alternative beaches.
### π One-Tap SOS
A single SOS trigger can share the user's exact location with:
- 112 / emergency response
- Nearest hospital - Coast guard / marine police - Lifeguard post
### π Emergency Dispatch & Tracking
Tracks an incident through:
```text
Created β Dispatched β Acknowledged β En Route β Arrived β Resolved ```
### πΊοΈ Hospital & Authority Routing
- Capability-filtered hospital matching.
- Jurisdiction-matched authority routing.
- Defined response roles.
- Parallel emergency dispatch.
### π Live Rescue Tracking
- Location pings.
- ETA tracking.
- Stale-session detection.
- Rescue progress visibility.
### π Notifications
- SMS notifications.
- Web Push notifications.
- Localized templates.
- English fallback.
### π΄ Offline Support
- Offline-capable Progressive Web App.
- Local action queue.
- Automatic synchronization after reconnect.
### π Authentication
- Phone + OTP login.
- Defined OTP expiry.
### π’ Admin & Operations
- Beach management.
- Jurisdiction management.
- Hospital management.
- Incident dashboards.
- Acknowledgement dashboards.
- Risk-rule tuning.
- Log export.
### π Data Ingestion & Risk Engine
- INCOIS + SACHET connectors.
- Manual beach closures.
- Data normalization and unit conversion.
- Redis-based deduplication.
- Risk scoring.
- Time-series hazard outlook.
---
## π§ Risk Engine
The Risk Engine combines multiple inputs into an explainable risk score.
### Inputs
- Wave height
- Current speed - Wind - Tide - Water quality - Forecast trend - Lifeguard coverage
### Risk Formula
```text
R = Ο( Ξ£ wα΅’zα΅’ + Ξ£ wα΅’β±Όzα΅’zβ±Ό + Ξ»βΞtrend + Ξ»βΞtide ) ```
### Risk Classification
| Risk Score | Verdict |
|---:|---| | `R < 0.33` | π’ SAFE | | `0.33 β 0.66` | π‘ CAUTION | | `R β₯ 0.66` | π΄ UNSAFE |
Active **tsunami, storm surge, or evacuation** conditions override normal scoring and force:
```text
R = 1 β UNSAFE ```
---
## π οΈ Tech Stack
### Frontend
- **React**
- **Next.js (SSR)** - **Mapbox GL JS / Google Maps API** - **Progressive Web App (PWA)**
### Backend
- **Python**
- **FastAPI** - **REST APIs** - **WebSockets** - **Celery**
### Database & Storage
- **PostgreSQL 16**
- **PostGIS** - **Redis 7** - **S3-compatible object storage**
### Infrastructure & DevOps
- **Docker**
- **Kubernetes** - **Kafka / RabbitMQ** - **GitHub Actions CI/CD** - **AWS / GCP**
### External APIs & Data Sources
- **INCOIS** β Ocean & advisory data
- **SACHET** β CAP / RSS alerts - **112 ERSS** β Emergency di
## Challenges we ran into
# The Bug That Almost Slipped Into Production
**Project:** WaveSafe β Coastal Safety Platform **Where it hit:** `POST /v1/admin/beaches` **Found during:** Final Swagger E2E testing, hours before deployment
## The Crash
```
psycopg2.errors.InvalidParameterValue: Geometry type (Point) does not match column type (Polygon) ```
A clean 500. Not a validation error β a raw database exception leaking straight to the client.
## Why It Happened
Swagger's auto-generated example payload showed a generic GeoJSON `Point`. Following it felt natural β but the `beaches` table stores each beach as a **Polygon** (a boundary, not a pin drop). The API had no validation layer checking the GeoJSON `type` before handing it to PostGIS. The request sailed straight through FastAPI β SQLAlchemy β Postgres, where the *database* finally said no β the hard way.
## The Fix
**Immediate:** Rebuilt the payload as a proper closed-ring Polygon (5 coordinate pairs, first == last). Confirmed the endpoint logic itself was fine β it was purely an input-shape problem.
**Real fix (queued, non-blocking):** Add a Pydantic validator on the GeoJSON `type` field so bad input returns a clean `422` before it ever touches the DB.
## The Pattern
This wasn't a one-off. The same root cause β **the database was the only validation layer** β surfaced twice more in the same session:
| Endpoint | Expected | Got |
|---|---|---| | `admin/beaches` | 422 (wrong geometry) | 500 crash | | `admin/activity-thresholds` | 409 (duplicate key) | 500 crash | | `safezone/guidance` | 422 (empty-string UUID) | 500 crash |
All three: the app layer trusted the input and let Postgres be the bouncer. Postgres did its job perfectly β data integrity held. But the *caller* got a stack trace instead of a sentence.
## The Takeaway
> A database constraint enforcing correctness is not the same as an API > validating input. One protects your data. The other protects your users > from a 500 page.
None of the three were blockers β all admin/internal-only, zero impact on the core user flow (SOS trigger β dispatch β tracking), which stayed clean through every test. But they're first on the list for the next patch.
Team
From the public Devfolio project page. Votes, swipes and the judge score are hackfeed's own.





