# ashe206/videolog architecture

> Architecture diagram of the GitHub repository ashe206/videolog, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashe206/videolog
- Repository: https://github.com/ashe206/videolog

## Overview

VideoLog turns uploaded or CLI-provided video into tracked identities, appearance and zone events, stored analytics, annotated playback, and natural-language answers. In the web workflow, the API accepts a video and starts serialized processing; tracking samples frames, then re-identification and event derivation feed persistence and rendering. Chat questions go through the reasoning layer to query stored data. The graph follows shown calls and documented capabilities; unsampled UI, SQL-agent internals, and some persistence wiring are represented only where the README or excerpts support them.

Main entry points: [`api/main.py`](https://github.com/ashe206/videolog/blob/main/api/main.py) (Web API), [`main.py`](https://github.com/ashe206/videolog/blob/main/main.py) (CLI entry), [`detection/tracking.py`](https://github.com/ashe206/videolog/blob/main/detection/tracking.py) (Object tracking), [`reasoning/agent.py`](https://github.com/ashe206/videolog/blob/main/reasoning/agent.py) (SQL reasoning agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Video Processing"]
  node_sampler["Frame sampler<br/>[sampler.py]"]
  node_tracker["Object tracking<br/>[tracking.py]"]
end

subgraph group_analytics["Identity And Events"]
  node_reid["Track re-identification<br/>[merge.py]"]
  node_embedder["Appearance embeddings<br/>[embedder.py]"]
  node_gallery["Lost-track gallery<br/>[gallery.py]"]
  node_appearance["Appearance events<br/>[events.py]"]
  node_zone["Zone state analysis<br/>[state_machine.py]"]
  node_geometry["Zone geometry<br/>[geometry.py]"]
end

subgraph group_storage["Data And Queries"]
  node_schema["Database schema<br/>[schema.py]"]
  node_writer["Data writer<br/>[writer.py]"]
  node_sqlite[("SQLite analytics store<br/>[schema.py]")]
  node_agent["SQL reasoning agent<br/>[agent.py]"]
  node_prompts["SQL prompt rules<br/>[prompts.py]"]
  node_client["DeepSeek client<br/>[client.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_api["Web API<br/>[main.py]"]
  node_frontend["Web UI<br/>[index.html]"]
  node_cli["CLI entry<br/>[main.py]"]
  node_jobs["Job status and lock<br/>[jobs.py]"]
end

subgraph group_playback["Video Playback"]
  node_renderer["Annotated renderer<br/>[visualize.py]"]
end

node_user(("Video analyst"))
node_deepseek["DeepSeek service"]

node_user -->|"uploads video"| node_api
node_user -->|"runs analysis"| node_cli
node_frontend -->|"uses endpoints"| node_api
node_api -->|"reads video metadata"| node_sampler
node_api -->|"starts tracking"| node_tracker
node_tracker -->|"samples frames"| node_sampler
node_tracker -->|"extracts embeddings"| node_embedder
node_api -->|"remaps identities"| node_reid
node_reid -->|"matches lost tracks"| node_gallery
node_api -->|"derives appearances"| node_appearance
node_api -->|"analyzes zone activity"| node_zone
node_zone -->|"checks containment"| node_geometry
node_api -->|"initializes tables"| node_schema
node_api -->|"writes detections and events"| node_writer
node_writer -->|"inserts records"| node_sqlite
node_schema -->|"defines tables"| node_sqlite
node_api -->|"renders annotated video"| node_renderer
node_api -->|"tracks processing status"| node_jobs
node_api -->|"creates query client"| node_client
node_api -->|"runs question analysis"| node_agent
node_agent -->|"uses SQL examples"| node_prompts
node_agent -->|"queries stored analytics"| node_sqlite
node_client -->|"calls model service"| node_deepseek
node_cli -->|"reads video metadata"| node_sampler
node_cli -->|"starts tracking"| node_tracker
node_cli -->|"remaps identities"| node_reid
node_cli -->|"derives appearances"| node_appearance
node_cli -->|"analyzes zone activity"| node_zone
node_cli -->|"initializes tables"| node_schema
node_cli -->|"writes records"| node_writer

click node_api "https://github.com/ashe206/videolog/blob/main/api/main.py"
click node_frontend "https://github.com/ashe206/videolog/blob/main/frontend/index.html"
click node_cli "https://github.com/ashe206/videolog/blob/main/main.py"
click node_sampler "https://github.com/ashe206/videolog/blob/main/detection/sampler.py"
click node_tracker "https://github.com/ashe206/videolog/blob/main/detection/tracking.py"
click node_reid "https://github.com/ashe206/videolog/blob/main/reid/merge.py"
click node_embedder "https://github.com/ashe206/videolog/blob/main/reid/embedder.py"
click node_gallery "https://github.com/ashe206/videolog/blob/main/reid/gallery.py"
click node_appearance "https://github.com/ashe206/videolog/blob/main/db/events.py"
click node_zone "https://github.com/ashe206/videolog/blob/main/zones/state_machine.py"
click node_geometry "https://github.com/ashe206/videolog/blob/main/zones/geometry.py"
click node_schema "https://github.com/ashe206/videolog/blob/main/db/schema.py"
click node_writer "https://github.com/ashe206/videolog/blob/main/db/writer.py"
click node_sqlite "https://github.com/ashe206/videolog/blob/main/db/schema.py"
click node_agent "https://github.com/ashe206/videolog/blob/main/reasoning/agent.py"
click node_prompts "https://github.com/ashe206/videolog/blob/main/reasoning/prompts.py"
click node_client "https://github.com/ashe206/videolog/blob/main/reasoning/client.py"
click node_renderer "https://github.com/ashe206/videolog/blob/main/detection/visualize.py"
click node_jobs "https://github.com/ashe206/videolog/blob/main/api/jobs.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sampler,node_tracker toneBlue
class node_reid,node_embedder,node_gallery,node_appearance,node_zone,node_geometry toneAmber
class node_schema,node_writer,node_sqlite,node_agent,node_prompts,node_client toneMint
class node_api,node_frontend,node_cli,node_jobs toneRose
class node_renderer,node_user,node_deepseek toneIndigo
```

## Components

### Video Processing

- [Frame sampler](https://github.com/ashe206/videolog/blob/main/detection/sampler.py): `detection/sampler.py`
- [Object tracking](https://github.com/ashe206/videolog/blob/main/detection/tracking.py): `detection/tracking.py`

### Identity And Events

- [Track re-identification](https://github.com/ashe206/videolog/blob/main/reid/merge.py): `reid/merge.py`
- [Appearance embeddings](https://github.com/ashe206/videolog/blob/main/reid/embedder.py): `reid/embedder.py`
- [Lost-track gallery](https://github.com/ashe206/videolog/blob/main/reid/gallery.py): `reid/gallery.py`
- [Appearance events](https://github.com/ashe206/videolog/blob/main/db/events.py): `db/events.py`
- [Zone state analysis](https://github.com/ashe206/videolog/blob/main/zones/state_machine.py): `zones/state_machine.py`
- [Zone geometry](https://github.com/ashe206/videolog/blob/main/zones/geometry.py): `zones/geometry.py`

### Data And Queries

- [Database schema](https://github.com/ashe206/videolog/blob/main/db/schema.py): `db/schema.py`
- [Data writer](https://github.com/ashe206/videolog/blob/main/db/writer.py): `db/writer.py`
- [SQLite analytics store](https://github.com/ashe206/videolog/blob/main/db/schema.py): `db/schema.py`
- [SQL reasoning agent](https://github.com/ashe206/videolog/blob/main/reasoning/agent.py): `reasoning/agent.py`
- [SQL prompt rules](https://github.com/ashe206/videolog/blob/main/reasoning/prompts.py): `reasoning/prompts.py`
- [DeepSeek client](https://github.com/ashe206/videolog/blob/main/reasoning/client.py): `reasoning/client.py`

### User Interfaces

- [Web API](https://github.com/ashe206/videolog/blob/main/api/main.py): `api/main.py`
- [Web UI](https://github.com/ashe206/videolog/blob/main/frontend/index.html): `frontend/index.html`
- [CLI entry](https://github.com/ashe206/videolog/blob/main/main.py): `main.py`
- [Job status and lock](https://github.com/ashe206/videolog/blob/main/api/jobs.py): `api/jobs.py`

### Video Playback

- [Annotated renderer](https://github.com/ashe206/videolog/blob/main/detection/visualize.py): `detection/visualize.py`

### Other components

- **Video analyst**
- **DeepSeek service**

## Connections

- Video analyst → Web API: uploads video (evidence: `README.md`)
- Video analyst → CLI entry: runs analysis (evidence: `README.md`)
- Web UI → Web API: uses endpoints (evidence: `README.md`)
- Web API → Frame sampler: reads video metadata (evidence: `api/main.py`)
- Web API → Object tracking: starts tracking (evidence: `api/main.py`)
- Object tracking → Frame sampler: samples frames (evidence: `detection/tracking.py`)
- Object tracking → Appearance embeddings: extracts embeddings (evidence: `detection/tracking.py`)
- Web API → Track re-identification: remaps identities (evidence: `api/main.py`)
- Track re-identification → Lost-track gallery: matches lost tracks (evidence: `reid/merge.py`)
- Web API → Appearance events: derives appearances (evidence: `api/main.py`)
- Web API → Zone state analysis: analyzes zone activity (evidence: `api/main.py`)
- Zone state analysis → Zone geometry: checks containment (evidence: `zones/state_machine.py`)
- Web API → Database schema: initializes tables (evidence: `api/main.py`)
- Web API → Data writer: writes detections and events (evidence: `api/main.py`)
- Data writer → SQLite analytics store: inserts records (evidence: `db/writer.py`)
- Database schema → SQLite analytics store: defines tables (evidence: `db/schema.py`)
- Web API → Annotated renderer: renders annotated video (evidence: `api/main.py`)
- Web API → Job status and lock: tracks processing status (evidence: `api/main.py`)
- Web API → DeepSeek client: creates query client (evidence: `api/main.py`)
- Web API → SQL reasoning agent: runs question analysis (evidence: `api/main.py`)
- SQL reasoning agent → SQL prompt rules: uses SQL examples (evidence: `reasoning/agent.py`)
- SQL reasoning agent → SQLite analytics store: queries stored analytics (evidence: `README.md`)
- DeepSeek client → DeepSeek service: calls model service (evidence: `README.md`)
- CLI entry → Frame sampler: reads video metadata (evidence: `main.py`)
- CLI entry → Object tracking: starts tracking (evidence: `main.py`)
- CLI entry → Track re-identification: remaps identities (evidence: `main.py`)
- CLI entry → Appearance events: derives appearances (evidence: `main.py`)
- CLI entry → Zone state analysis: analyzes zone activity (evidence: `main.py`)
- CLI entry → Database schema: initializes tables (evidence: `main.py`)
- CLI entry → Data writer: writes records (evidence: `main.py`)
