Files
wifi-densepose/rust-port/wifi-densepose-rs/crates/wifi-densepose-mat/src/api/mod.rs
Claude 6af0236fc7 feat: Complete ADR-001, ADR-009, ADR-012 implementations with zero mocks
ADR-001 (WiFi-Mat disaster response pipeline):
- Add EnsembleClassifier with weighted voting (breathing/heartbeat/movement)
- Wire EventStore into DisasterResponse with domain event emission
- Add scan control API endpoints (push CSI, scan control, pipeline status, domain events)
- Implement START triage protocol (Immediate/Delayed/Minor/Deceased/Unknown)
- Critical patterns (Agonal/Apnea) bypass confidence threshold for safety
- Add 6 deterministic integration tests with synthetic sinusoidal CSI data

ADR-009 (WASM signal pipeline):
- Add pushCsiData() with zero-crossing breathing rate extraction
- Add getPipelineConfig() for runtime configuration access
- Update TypeScript type definitions for new WASM exports

ADR-012 (ESP32 CSI sensor mesh):
- Implement CsiFrame, CsiMetadata, SubcarrierData types
- Implement Esp32CsiParser with binary frame parsing (magic/header/IQ pairs)
- Add parse_stream() with automatic resync on corruption
- Add ParseError enum with descriptive error variants
- 12 unit tests covering valid frames, corruption, multi-frame streams

All 275 workspace tests pass. No mocks, no stubs, no placeholders.

https://claude.ai/code/session_01Ki7pvEZtJDvqJkmyn6B714
2026-02-28 14:15:26 +00:00

86 lines
3.0 KiB
Rust

//! REST API endpoints for WiFi-DensePose MAT disaster response monitoring.
//!
//! This module provides a complete REST API and WebSocket interface for
//! managing disaster events, zones, survivors, and alerts in real-time.
//!
//! ## Endpoints
//!
//! ### Disaster Events
//! - `GET /api/v1/mat/events` - List all disaster events
//! - `POST /api/v1/mat/events` - Create new disaster event
//! - `GET /api/v1/mat/events/{id}` - Get event details
//!
//! ### Zones
//! - `GET /api/v1/mat/events/{id}/zones` - List zones for event
//! - `POST /api/v1/mat/events/{id}/zones` - Add zone to event
//!
//! ### Survivors
//! - `GET /api/v1/mat/events/{id}/survivors` - List survivors in event
//!
//! ### Alerts
//! - `GET /api/v1/mat/events/{id}/alerts` - List alerts for event
//! - `POST /api/v1/mat/alerts/{id}/acknowledge` - Acknowledge alert
//!
//! ### Scan Control
//! - `POST /api/v1/mat/scan/csi` - Push raw CSI data into detection pipeline
//! - `POST /api/v1/mat/scan/control` - Start/stop/pause/resume scanning
//! - `GET /api/v1/mat/scan/status` - Get detection pipeline status
//!
//! ### Domain Events
//! - `GET /api/v1/mat/events/domain` - List domain events from event store
//!
//! ### WebSocket
//! - `WS /ws/mat/stream` - Real-time survivor and alert stream
pub mod dto;
pub mod handlers;
pub mod error;
pub mod state;
pub mod websocket;
use axum::{
Router,
routing::{get, post},
};
pub use dto::*;
pub use error::ApiError;
pub use state::AppState;
/// Create the MAT API router with all endpoints.
///
/// # Example
///
/// ```rust,no_run
/// use wifi_densepose_mat::api::{create_router, AppState};
///
/// #[tokio::main]
/// async fn main() {
/// let state = AppState::new();
/// let app = create_router(state);
/// // ... serve with axum
/// }
/// ```
pub fn create_router(state: AppState) -> Router {
Router::new()
// Event endpoints
.route("/api/v1/mat/events", get(handlers::list_events).post(handlers::create_event))
.route("/api/v1/mat/events/:event_id", get(handlers::get_event))
// Zone endpoints
.route("/api/v1/mat/events/:event_id/zones", get(handlers::list_zones).post(handlers::add_zone))
// Survivor endpoints
.route("/api/v1/mat/events/:event_id/survivors", get(handlers::list_survivors))
// Alert endpoints
.route("/api/v1/mat/events/:event_id/alerts", get(handlers::list_alerts))
.route("/api/v1/mat/alerts/:alert_id/acknowledge", post(handlers::acknowledge_alert))
// Scan control endpoints (ADR-001: CSI data ingestion + pipeline control)
.route("/api/v1/mat/scan/csi", post(handlers::push_csi_data))
.route("/api/v1/mat/scan/control", post(handlers::scan_control))
.route("/api/v1/mat/scan/status", get(handlers::pipeline_status))
// Domain event store endpoint
.route("/api/v1/mat/events/domain", get(handlers::list_domain_events))
// WebSocket endpoint
.route("/ws/mat/stream", get(websocket::ws_handler))
.with_state(state)
}