# indranilpalit24/askfootage architecture

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

- Interactive diagram: https://gitdiagram.com/indranilpalit24/askfootage
- Repository: https://github.com/indranilpalit24/askfootage

## Overview

AskFootage indexes fixed-camera recordings, then answers natural-language questions from stored object tracks and returns ranked clips with timelines and measurable visual proof. The main workflow runs from the web search UI through the HTTP API and search use cases, which evaluate stored tracks and return clips, proofs, snapshots, and recording boxes for playback. Separate branches cover recording ingestion, camera/zone/library management, cost-capped perception, and the demo UI. Some subsystem links are based on README documentation or indexed imports; unsampled details are not asserted.

Main entry points: [`askfootage/application/search_relations.py`](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search_relations.py) (Track search), [`askfootage/application/search.py`](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search.py) (Question search), [`askfootage/interfaces/api/routes.py`](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/routes.py) (API routes), [`askfootage/application/ingest_video.py`](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/ingest_video.py) (Recording ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["Web screens"]
  node_webclient["API client<br/>[client.ts]"]
end

subgraph group_http["HTTP interface"]
  node_api["HTTP API<br/>[app.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_context["Service context<br/>[context.py]"]
end

subgraph group_usecases["Application workflows"]
  node_search["Question search<br/>[search.py]"]
  node_relationsearch["Track search"]
  node_ingest["Recording ingestion<br/>[ingest_video.py]"]
  node_concepts["Concept indexing<br/>[concepts.py]"]
  node_library["Library use cases<br/>[library.py]"]
end

subgraph group_analysis["Track analysis"]
  node_domainrelations["Relation rules<br/>[relations.py]"]
  node_trackmodel["Object tracks<br/>[tracks.py]"]
  node_vocabulary["Question vocabulary<br/>[vocabulary.py]"]
  node_stitching["Track stitching<br/>[stitching.py]"]
end

subgraph group_persistence["Storage and adapters"]
  node_libraryport["Library store port<br/>[library_store.py]"]
  node_trackport["Track store port<br/>[track_store.py]"]
  node_sqlite[("SQLite index<br/>[store.py]")]
  node_tracksqlite[("SQLite tracks<br/>[tracks.py]")]
  node_ffmpeg["Video preparation<br/>[ffmpeg.py]"]
  node_perception["SAM perception<br/>[sam.py]"]
  node_budget["Spend guard<br/>[budget.py]"]
end

node_person(("Footage user"))

node_person -->|"asks question"| node_web
node_web -->|"submits search"| node_webclient
node_webclient -->|"HTTP requests"| node_api
node_api -->|"registers routes"| node_routes
node_routes -->|"uses services"| node_context
node_routes -->|"calls search"| node_search
node_context -->|"wires use case"| node_search
node_search -->|"checks tracks"| node_relationsearch
node_relationsearch -->|"evaluates rules"| node_domainrelations
node_relationsearch -->|"reads tracks"| node_trackport
node_relationsearch -->|"reads question"| node_vocabulary
node_domainrelations -->|"evaluates trajectories"| node_trackmodel
node_relationsearch -->|"stitches tracks"| node_stitching
node_trackport -->|"implemented by"| node_tracksqlite
node_search -->|"reads library"| node_libraryport
node_libraryport -->|"implemented by"| node_sqlite
node_search -.->|"returns matches"| node_webclient
node_routes -->|"calls management"| node_library
node_ingest -->|"prepares video"| node_ffmpeg
node_ingest -->|"finds objects"| node_perception
node_ingest -->|"saves tracks"| node_trackport
node_concepts -->|"runs concepts"| node_perception
node_concepts -->|"caps spending"| node_budget
node_concepts -->|"stores results"| node_trackport
node_api -->|"exposes indexing"| node_ingest

click node_web "https://github.com/indranilpalit24/askfootage/tree/main/web/src/screens"
click node_webclient "https://github.com/indranilpalit24/askfootage/blob/main/web/src/api/client.ts"
click node_api "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/app.py"
click node_routes "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/routes.py"
click node_context "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/context.py"
click node_search "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search.py"
click node_relationsearch "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search_relations.py"
click node_ingest "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/ingest_video.py"
click node_concepts "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/concepts.py"
click node_library "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/library.py"
click node_domainrelations "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/relations.py"
click node_trackmodel "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/tracks.py"
click node_vocabulary "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/vocabulary.py"
click node_stitching "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/stitching.py"
click node_libraryport "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/ports/library_store.py"
click node_trackport "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/ports/track_store.py"
click node_sqlite "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/sqlite/store.py"
click node_tracksqlite "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/sqlite/tracks.py"
click node_ffmpeg "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/media/ffmpeg.py"
click node_perception "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/meta/sam.py"
click node_budget "https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/meta/budget.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_web,node_webclient,node_person toneBlue
class node_api,node_routes,node_context toneAmber
class node_search,node_relationsearch,node_ingest,node_concepts,node_library toneMint
class node_domainrelations,node_trackmodel,node_vocabulary,node_stitching toneRose
class node_libraryport,node_trackport,node_sqlite,node_tracksqlite,node_ffmpeg,node_perception,node_budget toneIndigo
```

## Components

### Web experience

- [Web screens](https://github.com/indranilpalit24/askfootage/tree/main/web/src/screens): `web/src/screens`
- [API client](https://github.com/indranilpalit24/askfootage/blob/main/web/src/api/client.ts): `web/src/api/client.ts`

### HTTP interface

- [HTTP API](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/app.py): `askfootage/interfaces/api/app.py`
- [API routes](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/routes.py): `askfootage/interfaces/api/routes.py`
- [Service context](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/interfaces/api/context.py): `askfootage/interfaces/api/context.py`

### Application workflows

- [Question search](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search.py): `askfootage/application/search.py`
- [Track search](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/search_relations.py): `askfootage/application/search_relations.py`
- [Recording ingestion](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/ingest_video.py): `askfootage/application/ingest_video.py`
- [Concept indexing](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/concepts.py): `askfootage/application/concepts.py`
- [Library use cases](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/application/library.py): `askfootage/application/library.py`

### Track analysis

- [Relation rules](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/relations.py): `askfootage/domain/relations.py`
- [Object tracks](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/tracks.py): `askfootage/domain/tracks.py`
- [Question vocabulary](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/vocabulary.py): `askfootage/domain/vocabulary.py`
- [Track stitching](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/domain/stitching.py): `askfootage/domain/stitching.py`

### Storage and adapters

- [Library store port](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/ports/library_store.py): `askfootage/ports/library_store.py`
- [Track store port](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/ports/track_store.py): `askfootage/ports/track_store.py`
- [SQLite index](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/sqlite/store.py): `askfootage/adapters/sqlite/store.py`
- [SQLite tracks](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/sqlite/tracks.py): `askfootage/adapters/sqlite/tracks.py`
- [Video preparation](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/media/ffmpeg.py): `askfootage/adapters/media/ffmpeg.py`
- [SAM perception](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/meta/sam.py): `askfootage/adapters/meta/sam.py`
- [Spend guard](https://github.com/indranilpalit24/askfootage/blob/main/askfootage/adapters/meta/budget.py): `askfootage/adapters/meta/budget.py`

### Other components

- **Footage user**

## Connections

- Footage user → Web screens: asks question
- Web screens → API client: submits search (evidence: `web/src/app/App.tsx`)
- API client → HTTP API: HTTP requests
- HTTP API → API routes: registers routes (evidence: `askfootage/interfaces/api/app.py`)
- API routes → Service context: uses services (evidence: `askfootage/interfaces/api/routes.py`)
- API routes → Question search: calls search (evidence: `askfootage/interfaces/api/routes.py`)
- Service context → Question search: wires use case (evidence: `askfootage/interfaces/api/context.py`)
- Question search → Track search: checks tracks (evidence: `askfootage/application/search.py`)
- Track search → Relation rules: evaluates rules (evidence: `askfootage/application/search_relations.py`)
- Track search → Track store port: reads tracks (evidence: `askfootage/application/search_relations.py`)
- Track search → Question vocabulary: reads question (evidence: `askfootage/application/search_relations.py`)
- Relation rules → Object tracks: evaluates trajectories (evidence: `askfootage/domain/relations.py`)
- Track search → Track stitching: stitches tracks (evidence: `askfootage/application/search_relations.py`)
- Track store port → SQLite tracks: implemented by (evidence: `askfootage/ports/track_store.py`)
- Question search → Library store port: reads library (evidence: `askfootage/application/search.py`)
- Library store port → SQLite index: implemented by (evidence: `askfootage/ports/library_store.py`)
- Question search → API client: returns matches
- API routes → Library use cases: calls management (evidence: `askfootage/interfaces/api/routes.py`)
- Recording ingestion → Video preparation: prepares video (evidence: `askfootage/application/ingest_video.py`)
- Recording ingestion → SAM perception: finds objects (evidence: `askfootage/application/ingest_video.py`)
- Recording ingestion → Track store port: saves tracks (evidence: `askfootage/application/ingest_video.py`)
- Concept indexing → SAM perception: runs concepts (evidence: `askfootage/application/concepts.py`)
- Concept indexing → Spend guard: caps spending (evidence: `askfootage/application/concepts.py`)
- Concept indexing → Track store port: stores results (evidence: `askfootage/application/concepts.py`)
- HTTP API → Recording ingestion: exposes indexing (evidence: `askfootage/interfaces/api/app.py`)
