# brandsconnet-byte/video-rag-engine architecture

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

- Interactive diagram: https://gitdiagram.com/brandsconnet-byte/video-rag-engine
- Repository: https://github.com/brandsconnet-byte/video-rag-engine

## Overview

Video RAG Engine turns video into searchable scene indexes and exports matching clips. The principal workflow is scene detection, dual-model scene enrichment, LanceDB indexing, query search, then duration-based routing to clip extraction or editing; pro export produces EDL/XML. CLI, Flask, and Gradio interfaces expose parts of this workflow, and the README also documents batch queries and configurable processing. The pipeline and component relationships are supported by excerpts and README; some routing and export dispatch details are documented but not shown at their call sites.

Main entry points: [`src/pipeline.py`](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/pipeline.py) (Pipeline Orchestrator), [`src/export_manager.py`](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/export_manager.py) (Clip And EDL Export), [`main.py`](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/main.py) (CLI Commands), [`app.py`](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/app.py) (Flask API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_main_cli["CLI Commands<br/>[main.py]"]
  node_flask_ui["Flask API<br/>[app.py]"]
  node_gradio_ui["Gradio UI<br/>[gradio_app.py]"]
end

subgraph group_processing["Video Processing"]
  node_pipeline["Pipeline Orchestrator<br/>[pipeline.py]"]
  node_scene_detection["Scene Detection<br/>[scene_detector.py]"]
  node_ai_indexing["Dual AI Indexing"]
end

subgraph group_search["Index And Search"]
  node_vector_db[("Scene Index And Search<br/>[vector_database.py]")]
end

subgraph group_exports["Routing And Export"]
  node_router["Export Router"]
  node_export_manager["Clip And EDL Export<br/>[export_manager.py]"]
  node_ffmpeg["FFmpeg"]
  node_auto_editor["auto-editor"]
end

node_cli_user(("CLI User"))
node_web_user(("Web User"))

node_cli_user -->|"runs commands"| node_main_cli
node_main_cli -->|"invokes workflow"| node_pipeline
node_web_user -->|"uploads and searches"| node_flask_ui
node_flask_ui -->|"calls workflow"| node_pipeline
node_web_user -->|"uploads and searches"| node_gradio_ui
node_gradio_ui -->|"calls workflow"| node_pipeline
node_pipeline -->|"detects scenes"| node_scene_detection
node_pipeline -->|"enriches scenes"| node_ai_indexing
node_pipeline -->|"stores and searches"| node_vector_db
node_pipeline -->|"selects export route"| node_router
node_pipeline -->|"exports results"| node_export_manager
node_router -->|"dispatches export"| node_export_manager
node_export_manager -->|"extracts clips"| node_ffmpeg
node_export_manager -->|"edits segments"| node_auto_editor

click node_main_cli "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/main.py"
click node_flask_ui "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/app.py"
click node_gradio_ui "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/gradio_app.py"
click node_pipeline "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/pipeline.py"
click node_scene_detection "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/scene_detector.py"
click node_ai_indexing "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/dual_brain_processor.py"
click node_vector_db "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/vector_database.py"
click node_router "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/intelligent_router.py"
click node_export_manager "https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/export_manager.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_main_cli,node_flask_ui,node_gradio_ui,node_cli_user,node_web_user toneBlue
class node_pipeline,node_scene_detection,node_ai_indexing toneAmber
class node_vector_db toneMint
class node_router,node_export_manager,node_ffmpeg,node_auto_editor toneRose
```

## Components

### User Interfaces

- [CLI Commands](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/main.py): `main.py`
- [Flask API](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/app.py): `app.py`
- [Gradio UI](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/gradio_app.py): `gradio_app.py`

### Video Processing

- [Pipeline Orchestrator](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/pipeline.py): `src/pipeline.py`
- [Scene Detection](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/scene_detector.py): `src/scene_detector.py`
- [Dual AI Indexing](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/dual_brain_processor.py): `src/dual_brain_processor.py`

### Index And Search

- [Scene Index And Search](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/vector_database.py): `src/vector_database.py`

### Routing And Export

- [Export Router](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/intelligent_router.py): `src/intelligent_router.py`
- [Clip And EDL Export](https://github.com/brandsconnet-byte/video-rag-engine/blob/main/src/export_manager.py): `src/export_manager.py`
- **FFmpeg**
- **auto-editor**

### Other components

- **CLI User**
- **Web User**

## Connections

- CLI User → CLI Commands: runs commands (evidence: `main.py`)
- CLI Commands → Pipeline Orchestrator: invokes workflow (evidence: `main.py`)
- Web User → Flask API: uploads and searches (evidence: `app.py`)
- Flask API → Pipeline Orchestrator: calls workflow (evidence: `app.py`)
- Web User → Gradio UI: uploads and searches (evidence: `gradio_app.py`)
- Gradio UI → Pipeline Orchestrator: calls workflow (evidence: `gradio_app.py`)
- Pipeline Orchestrator → Scene Detection: detects scenes (evidence: `src/pipeline.py`)
- Pipeline Orchestrator → Dual AI Indexing: enriches scenes (evidence: `src/pipeline.py`)
- Pipeline Orchestrator → Scene Index And Search: stores and searches (evidence: `src/pipeline.py`)
- Pipeline Orchestrator → Export Router: selects export route (evidence: `README.md`)
- Pipeline Orchestrator → Clip And EDL Export: exports results (evidence: `README.md`)
- Export Router → Clip And EDL Export: dispatches export (evidence: `README.md`)
- Clip And EDL Export → FFmpeg: extracts clips (evidence: `src/export_manager.py`)
- Clip And EDL Export → auto-editor: edits segments (evidence: `src/export_manager.py`)
