rust-port/wifi-densepose-rs/crates/wifi-densepose-db/README.md
Database persistence layer for the WiFi-DensePose pose estimation system.
wifi-densepose-db implements the DataStore trait defined in wifi-densepose-core, providing
persistent storage for CSI frames, pose estimates, scan sessions, and alert history. The intended
backends are SQLx for relational storage (PostgreSQL and SQLite) and
Redis for real-time caching and pub/sub.
Status: This crate is currently a stub. The intended API surface is documented below.
PoseRepository, SessionRepository,
AlertRepository) implementing the core DataStore trait.sqlx::PgPool / sqlx::SqlitePool.| Flag | Default | Description |
|---|---|---|
postgres | no | Enable PostgreSQL backend |
sqlite | yes | Enable SQLite backend |
redis | no | Enable Redis caching layer |
// Intended usage (not yet implemented)
use wifi_densepose_db::{Database, PoseRepository};
use wifi_densepose_core::PoseEstimate;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let db = Database::connect("sqlite://data/wifi-densepose.db").await?;
db.run_migrations().await?;
let repo = PoseRepository::new(db.pool());
// Store a pose estimate
repo.insert(&pose_estimate).await?;
// Query recent poses
let recent = repo.find_recent(10).await?;
println!("Last 10 poses: {:?}", recent);
Ok(())
}
-- Core tables
CREATE TABLE csi_frames (
id UUID PRIMARY KEY,
session_id UUID NOT NULL,
timestamp TIMESTAMPTZ NOT NULL,
subcarriers BYTEA NOT NULL,
antenna_id INTEGER NOT NULL
);
CREATE TABLE pose_estimates (
id UUID PRIMARY KEY,
frame_id UUID REFERENCES csi_frames(id),
timestamp TIMESTAMPTZ NOT NULL,
keypoints JSONB NOT NULL,
confidence REAL NOT NULL
);
CREATE TABLE scan_sessions (
id UUID PRIMARY KEY,
started_at TIMESTAMPTZ NOT NULL,
ended_at TIMESTAMPTZ,
config JSONB NOT NULL
);
| Crate | Role |
|---|---|
wifi-densepose-core | DataStore trait definition |
wifi-densepose-config | Database connection configuration |
wifi-densepose-api | REST API (consumer) |
wifi-densepose-mat | Disaster detection (consumer) |
wifi-densepose-signal | CSI signal processing |
MIT OR Apache-2.0