# avaneeshtkur/virallens--insight-engine architecture

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

- Interactive diagram: https://gitdiagram.com/avaneeshtkur/virallens--insight-engine
- Repository: https://github.com/avaneeshtkur/virallens--insight-engine

## Overview

ViralLens compares a YouTube video with an Instagram Reel, then lets users ask transcript- and engagement-focused questions. The principal flow is URL submission, parallel video data collection, engagement calculation and chunk indexing, followed by session-scoped retrieval and streamed local-LLM answers with source citations. The graph also includes the documented LangGraph retrieval implementation. The excerpts show both that graph and a direct chat path in the API; unsampled UI and backend wiring is included only where the README documents it.

Main entry points: [`backend/main.py`](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/main.py) (FastAPI routes), [`frontend/src/App.jsx`](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/App.jsx) (App session), [`backend/graph/nodes.py`](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/nodes.py) (Retrieve context), [`frontend/src/components/ChatPanel.jsx`](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/ChatPanel.jsx) (Chat panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["App session<br/>[App.jsx]"]
  node_input["URL input<br/>[InputBar.jsx]"]
  node_cards["Video cards<br/>[VideoCard.jsx]"]
  node_chat["Chat panel<br/>[ChatPanel.jsx]"]
  node_messages["Chat messages<br/>[ChatMessage.jsx]"]
  node_sse["SSE client<br/>[useSSE.js]"]
end

subgraph group_ingest["Video ingestion"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_youtube["YouTube fetch<br/>[youtube_service.py]"]
  node_instagram["Instagram fetch"]
  node_engagement["Engagement rate<br/>[engagement.py]"]
  node_chunker["Transcript chunking<br/>[chunker.py]"]
end

subgraph group_analysis["Retrieval and analysis"]
  node_embedder["Local embeddings<br/>[embedder.py]"]
  node_store[("Chroma vector store<br/>[vector_store.py]")]
  node_graph["Retrieval graph<br/>[graph.py]"]
  node_graphstate["Graph state<br/>[state.py]"]
  node_retrieval["Retrieve context<br/>[nodes.py]"]
  node_generation["Graph answer generation<br/>[nodes.py]"]
end

subgraph group_integrations["Local and platform services"]
  node_ollama["Ollama LLM"]
  node_platforms["Video platforms"]
end

node_user(("Video analyst"))

node_user -->|"submits URLs"| node_input
node_input -->|"reports analysis"| node_app
node_app -->|"requests ingestion"| node_api
node_api -->|"fetches video A"| node_youtube
node_api -->|"fetches video B"| node_instagram
node_youtube -->|"fetches data"| node_platforms
node_instagram -->|"fetches data"| node_platforms
node_api -->|"computes rates"| node_engagement
node_api -->|"chunks transcripts"| node_chunker
node_api -->|"gets embedder"| node_embedder
node_api -->|"indexes chunks"| node_store
node_api -->|"returns session data"| node_app
node_app -->|"displays videos"| node_cards
node_app -->|"opens session chat"| node_chat
node_chat -->|"renders messages"| node_messages
node_chat -->|"sends questions"| node_sse
node_sse -->|"streams chat request"| node_api
node_api -->|"retrieves chunks"| node_store
node_api -->|"streams completion"| node_ollama
node_graph -->|"dispatches retrieval"| node_retrieval
node_graph -->|"dispatches generation"| node_generation
node_retrieval -->|"gets embeddings"| node_embedder
node_retrieval -->|"searches chunks"| node_store
node_generation -->|"generates answer"| node_ollama
node_graphstate -->|"holds graph inputs"| node_retrieval
node_graphstate -->|"holds graph inputs"| node_generation

click node_app "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/App.jsx"
click node_input "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/InputBar.jsx"
click node_cards "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/VideoCard.jsx"
click node_chat "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/ChatPanel.jsx"
click node_messages "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/ChatMessage.jsx"
click node_sse "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/hooks/useSSE.js"
click node_api "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/main.py"
click node_youtube "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/youtube_service.py"
click node_instagram "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/instagram_service.py"
click node_engagement "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/utils/engagement.py"
click node_chunker "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/chunker.py"
click node_embedder "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/embedder.py"
click node_store "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/vector_store.py"
click node_graph "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/graph.py"
click node_graphstate "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/state.py"
click node_retrieval "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/nodes.py"
click node_generation "https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/nodes.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_app,node_input,node_cards,node_chat,node_messages,node_sse toneBlue
class node_api,node_youtube,node_instagram,node_engagement,node_chunker toneAmber
class node_embedder,node_store,node_graph,node_graphstate,node_retrieval,node_generation toneMint
class node_ollama,node_platforms toneRose
class node_user toneIndigo
```

## Components

### User interface

- [App session](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [URL input](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/InputBar.jsx): `frontend/src/components/InputBar.jsx`
- [Video cards](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/VideoCard.jsx): `frontend/src/components/VideoCard.jsx`
- [Chat panel](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/ChatPanel.jsx): `frontend/src/components/ChatPanel.jsx`
- [Chat messages](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/components/ChatMessage.jsx): `frontend/src/components/ChatMessage.jsx`
- [SSE client](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/frontend/src/hooks/useSSE.js): `frontend/src/hooks/useSSE.js`

### Video ingestion

- [FastAPI routes](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/main.py): `backend/main.py`
- [YouTube fetch](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/youtube_service.py): `backend/services/youtube_service.py`
- [Instagram fetch](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/instagram_service.py): `backend/services/instagram_service.py`
- [Engagement rate](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/utils/engagement.py): `backend/utils/engagement.py`
- [Transcript chunking](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/chunker.py): `backend/services/chunker.py`

### Retrieval and analysis

- [Local embeddings](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/embedder.py): `backend/services/embedder.py`
- [Chroma vector store](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/services/vector_store.py): `backend/services/vector_store.py`
- [Retrieval graph](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/graph.py): `backend/graph/graph.py`
- [Graph state](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/state.py): `backend/graph/state.py`
- [Retrieve context](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/nodes.py): `backend/graph/nodes.py`
- [Graph answer generation](https://github.com/avaneeshtkur/virallens--insight-engine/blob/main/backend/graph/nodes.py): `backend/graph/nodes.py`

### Local and platform services

- **Ollama LLM**
- **Video platforms**

### Other components

- **Video analyst**

## Connections

- Video analyst → URL input: submits URLs (evidence: `README.md`)
- URL input → App session: reports analysis (evidence: `frontend/src/App.jsx`)
- App session → FastAPI routes: requests ingestion (evidence: `README.md`)
- FastAPI routes → YouTube fetch: fetches video A (evidence: `backend/main.py`)
- FastAPI routes → Instagram fetch: fetches video B (evidence: `backend/main.py`)
- YouTube fetch → Video platforms: fetches data (evidence: `backend/services/youtube_service.py`)
- Instagram fetch → Video platforms: fetches data (evidence: `backend/services/instagram_service.py`)
- FastAPI routes → Engagement rate: computes rates (evidence: `backend/main.py`)
- FastAPI routes → Transcript chunking: chunks transcripts (evidence: `backend/main.py`)
- FastAPI routes → Local embeddings: gets embedder (evidence: `backend/main.py`)
- FastAPI routes → Chroma vector store: indexes chunks (evidence: `backend/main.py`)
- FastAPI routes → App session: returns session data (evidence: `README.md`)
- App session → Video cards: displays videos (evidence: `frontend/src/App.jsx`)
- App session → Chat panel: opens session chat (evidence: `frontend/src/App.jsx`)
- Chat panel → Chat messages: renders messages (evidence: `frontend/src/components/ChatPanel.jsx`)
- Chat panel → SSE client: sends questions (evidence: `frontend/src/components/ChatPanel.jsx`)
- SSE client → FastAPI routes: streams chat request (evidence: `README.md`)
- FastAPI routes → Chroma vector store: retrieves chunks (evidence: `backend/main.py`)
- FastAPI routes → Ollama LLM: streams completion (evidence: `README.md`)
- Retrieval graph → Retrieve context: dispatches retrieval (evidence: `backend/graph/graph.py`)
- Retrieval graph → Graph answer generation: dispatches generation (evidence: `backend/graph/graph.py`)
- Retrieve context → Local embeddings: gets embeddings (evidence: `backend/graph/nodes.py`)
- Retrieve context → Chroma vector store: searches chunks (evidence: `backend/graph/nodes.py`)
- Graph answer generation → Ollama LLM: generates answer (evidence: `backend/graph/nodes.py`)
- Graph state → Retrieve context: holds graph inputs (evidence: `backend/graph/nodes.py`)
- Graph state → Graph answer generation: holds graph inputs (evidence: `backend/graph/nodes.py`)
