# Module: Database layer (`src/Database`) ## Purpose PostgreSQL schema and Linq2DB mapping for annotations, media, detections, queue buffer, settings, and `detection_classes`. Underpins every HTTP module in `01_annotations.md`. ## Public interface - `AppDataConnection` — `ITable<>` for all mapped entities. - `DatabaseMigrator.Migrate` — embedded SQL: `CREATE TABLE IF NOT EXISTS` / `ALTER … IF NOT EXISTS`, seed detection classes. ## Entities (summary) - `Annotation`, `Media`, `Detection` — core annotation + YOLO row model (`time` stored as BIGINT ticks). - `AnnotationsQueueRecord` — failsafe outbox (`operation`, `annotation_ids`). - `SystemSettings` — includes `GenerateAnnotatedImage`, `SilentDetection` (suite §Annotated Image / Silent Detection). - `DirectorySettings` — `/data/...` roots consumed by `PathResolver`. - `DetectionClass`, `UserSettings`, `CameraSettings`. ## Dependencies Wire enums on columns. ## Consumers All services and `ClassesController`. ## Suite doc Annotation identity and ER-level behavior; cross-check `00_database_schema.md` in suite when entities evolve.