This project addresses the "Golden Hour" latency in Nigeria's emergency response by creating a decentralized, peer-to-peer network. It fills the gap between an incident and the arrival of official services by mobilizing nearby verified volunteers.
# VanguardNet — Flutter Client
Decentralized emergency response platform. Victims broadcast SOS alerts; nearby volunteer responders receive dispatch notifications, navigate to the scene, and update response status in real time.
---
## Table of Contents
1. Overview
2. Architecture
3. Project Structure
4. Getting Started
5. Environment Configuration
6. API Reference
7. WebSocket Protocol
8. Roles & Navigation Flow
9. Known Issues & TODOs
---
## Overview
Two user roles share the same app binary, routed by role after login:
| Role | What they do |
|------|-------------|
| **Victim** | Long-press SOS → 5-step incident questionnaire → alert broadcast |
| **Volunteer / Responder** | Toggle online → receive dispatch → navigate to victim → update status |
Tech stack: Flutter · GetX · OpenStreetMap (`flutter_map`) · WebSocket · REST (`http` + `dio`)
---
## Architecture
### State Management
GetX throughout. Controllers hold `Rx ` observables; screens wrap reactive widgets in `Obx()`.
### Navigation
GetX named routes defined in `lib/core/routes/app_routes.dart`.
Two middleware classes guard routes:
- `AuthMiddleware` — redirects to `/auth` if no authenticated user
- `RoleBasedMiddleware` — redirects volunteers from `/home` to `/responder-home`
### Controller Lifecycle
Only `AuthController` is eagerly initialized (in `main()`). All other controllers are registered lazily via route bindings and created only when their screen is first navigated to:
| Controller | Route binding | Starts on init |
|---|---|---|
| `AuthController` | `main.dart` (eager) | Session check, 5-min token timer |
| `HomeController` | `/home` | GPS stream |
| `EmergencyController` | `/home` | GPS one-shot |
| `ResponderHomeController` | `/responder-home` | GPS stream, session timer |
### Services
| Service | HTTP client | Purpose |
|---|---|---|
| `BaseApiService` | `http` | Auth + emergency REST calls, secure token management |
| `SOSService` | `dio` | Responder-side SOS operations |
| `Web …