Files
ruvnet--RuView/v2/crates/wifi-densepose-mat/src/api/mod.rs
T
rUv f49c722764 chore(repo): rename rust-port/wifi-densepose-rs → v2/ (flatten to one level) (#427)
The Rust port lived two directories deep (rust-port/wifi-densepose-rs/)
without any sibling under rust-port/ that warranted the extra level.
Move the whole workspace up to v2/ to match v1/ (Python) at the same
depth and shorten every cd / build command across the repo.

git mv preserves history for all tracked files. 60 files updated for
path references (CI workflows, ADRs, docs, scripts, READMEs, internal
.claude-flow state). Two manual fixes for relative-cd paths in
CLAUDE.md and ADR-043 that became wrong after the depth change
(cd ../.. → cd ..).

Validated:
- cargo check --workspace --no-default-features → clean (after target/
  nuke; the gitignored target/ was carried by the OS rename and had
  hard-coded old paths in build scripts)
- cargo test --workspace --no-default-features → 1,539 passed, 0 failed,
  8 ignored (same totals as pre-rename)
- ESP32-S3 on COM7 → still streaming live CSI (cb #40300, RSSI -64 dBm)

After-merge follow-up: contributors should `rm -rf v2/target` once and
let cargo regenerate from the new path.
2026-04-25 21:28:13 -04: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)
}