# girirag/sentiment-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/girirag/sentiment-analysis
- Repository: https://github.com/girirag/sentiment-analysis

## Overview

This is a video sentiment-analysis and clip-highlights platform. Users upload videos or start live streams; background processing produces transcripts, translated segments, sentiment timelines and keywords for display/export. A second workflow matches uploaded datasets against analyzed segments and generates downloadable clips. The graph includes documented capabilities whose route or frontend details were not sampled; those links are omitted where source evidence is unavailable.

Main entry points: [`backend/app/tasks/celery_tasks.py`](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/tasks/celery_tasks.py) (Background task worker), [`backend/app/api/routes/video.py`](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/video.py) (Video and stream routes), [`backend/app/services/firebase_service.py`](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/firebase_service.py) (Firebase data service), [`backend/app/api/routes/clips.py`](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/clips.py) (Clip job routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["SvelteKit interface<br/>[+page.svelte]"]
  node_upload_ui["Video upload<br/>[+page.svelte]"]
  node_analysis_ui["Analysis views<br/>[+page.svelte]"]
  node_live_ui["Live stream views<br/>[+page.svelte]"]
  node_clips_ui["Clip browser<br/>[+page.svelte]"]
end

subgraph group_api["API and orchestration"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_video_routes["Video and stream routes<br/>[video.py]"]
  node_analysis_routes["Analysis and export routes<br/>[analysis.py]"]
  node_clip_routes["Clip job routes<br/>[clips.py]"]
  node_ws_routes["Realtime updates<br/>[websocket.py]"]
  node_auth["Token verification<br/>[dependencies.py]"]
  node_tasks["Background task worker<br/>[celery_tasks.py]"]
end

subgraph group_analysis["Video analysis"]
  node_video_process["Video processing<br/>[video_processor.py]"]
  node_transcribe["Speech transcription<br/>[transcriber.py]"]
  node_translate["Language translation<br/>[translator.py]"]
  node_sentiment["Sentiment timeline"]
  node_keywords["Keyword tracking<br/>[keyword_tracker.py]"]
  node_stream["Stream handling<br/>[stream_handler.py]"]
end

subgraph group_clips["Clip highlights"]
  node_dataset["Dataset parsing<br/>[dataset_parser.py]"]
  node_matching["Semantic matching"]
  node_extractor["Clip extraction<br/>[clip_extractor.py]"]
end

subgraph group_data["Persistence and integrations"]
  node_firebase[("Firebase data service")]
  node_youtube["YouTube discovery<br/>[youtube_service.py]"]
  node_twitter["Twitter discovery<br/>[twitter_service.py]"]
  node_youtube_api["YouTube API"]
  node_twitter_api["Twitter API"]
end

node_viewer(("Video analyst"))

node_viewer -->|"uses"| node_web
node_web -->|"opens"| node_upload_ui
node_upload_ui -->|"uploads video"| node_video_routes
node_video_routes -->|"verifies token"| node_auth
node_video_routes -->|"stores video"| node_firebase
node_video_routes -->|"queues processing"| node_tasks
node_tasks -->|"loads and saves results"| node_firebase
node_tasks -->|"processes video"| node_video_process
node_tasks -->|"transcribes audio"| node_transcribe
node_tasks -->|"translates text"| node_translate
node_tasks -->|"analyzes segments"| node_sentiment
node_tasks -->|"extracts keywords"| node_keywords
node_analysis_ui -->|"requests results"| node_analysis_routes
node_analysis_routes -->|"reads analysis"| node_firebase
node_video_routes -.->|"starts stream"| node_stream
node_ws_routes -->|"reads updates"| node_firebase
node_live_ui -->|"receives updates"| node_ws_routes
node_clip_routes -->|"verifies token"| node_auth
node_clip_routes -->|"checks video"| node_firebase
node_clip_routes -->|"queues clip job"| node_tasks
node_tasks -->|"parses dataset"| node_dataset
node_tasks -->|"matches segments"| node_matching
node_tasks -->|"extracts clips"| node_extractor
node_tasks -->|"saves clip results"| node_firebase
node_clips_ui -->|"browses and downloads"| node_clip_routes
node_youtube -->|"searches videos"| node_youtube_api
node_twitter -->|"searches videos"| node_twitter_api
node_api_app -->|"mounts routes"| node_video_routes
node_api_app -->|"mounts routes"| node_analysis_routes
node_api_app -->|"mounts routes"| node_clip_routes
node_api_app -->|"mounts routes"| node_ws_routes

click node_web "https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/%2Bpage.svelte"
click node_upload_ui "https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/upload/%2Bpage.svelte"
click node_analysis_ui "https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/analysis/%5Bid%5D/%2Bpage.svelte"
click node_live_ui "https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/live/%2Bpage.svelte"
click node_clips_ui "https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/videos/%5Bid%5D/clips/%2Bpage.svelte"
click node_api_app "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/main.py"
click node_video_routes "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/video.py"
click node_analysis_routes "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/analysis.py"
click node_clip_routes "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/clips.py"
click node_ws_routes "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/websocket.py"
click node_auth "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/dependencies.py"
click node_tasks "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/tasks/celery_tasks.py"
click node_video_process "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/video_processor.py"
click node_transcribe "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/transcriber.py"
click node_translate "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/translator.py"
click node_sentiment "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/sentiment_analyzer.py"
click node_keywords "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/keyword_tracker.py"
click node_stream "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/stream_handler.py"
click node_dataset "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/dataset_parser.py"
click node_matching "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/semantic_matcher.py"
click node_extractor "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/clip_extractor.py"
click node_firebase "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/firebase_service.py"
click node_youtube "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/youtube_service.py"
click node_twitter "https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/twitter_service.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_upload_ui,node_analysis_ui,node_live_ui,node_clips_ui toneBlue
class node_api_app,node_video_routes,node_analysis_routes,node_clip_routes,node_ws_routes,node_auth,node_tasks toneAmber
class node_video_process,node_transcribe,node_translate,node_sentiment,node_keywords,node_stream toneMint
class node_dataset,node_matching,node_extractor toneRose
class node_firebase,node_youtube,node_twitter,node_youtube_api,node_twitter_api,node_viewer toneIndigo
```

## Components

### Web experience

- [SvelteKit interface](https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/%2Bpage.svelte): `frontend/src/routes/+page.svelte`
- [Video upload](https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/upload/%2Bpage.svelte): `frontend/src/routes/upload/+page.svelte`
- [Analysis views](https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/analysis/%5Bid%5D/%2Bpage.svelte): `frontend/src/routes/analysis/[id]/+page.svelte`
- [Live stream views](https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/live/%2Bpage.svelte): `frontend/src/routes/live/+page.svelte`
- [Clip browser](https://github.com/girirag/sentiment-analysis/blob/main/frontend/src/routes/videos/%5Bid%5D/clips/%2Bpage.svelte): `frontend/src/routes/videos/[id]/clips/+page.svelte`

### API and orchestration

- [FastAPI application](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/main.py): `backend/app/main.py`
- [Video and stream routes](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/video.py): `backend/app/api/routes/video.py`
- [Analysis and export routes](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/analysis.py): `backend/app/api/routes/analysis.py`
- [Clip job routes](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/clips.py): `backend/app/api/routes/clips.py`
- [Realtime updates](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/routes/websocket.py): `backend/app/api/routes/websocket.py`
- [Token verification](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/api/dependencies.py): `backend/app/api/dependencies.py`
- [Background task worker](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/tasks/celery_tasks.py): `backend/app/tasks/celery_tasks.py`

### Video analysis

- [Video processing](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/video_processor.py): `backend/app/services/video_processor.py`
- [Speech transcription](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/transcriber.py): `backend/app/services/transcriber.py`
- [Language translation](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/translator.py): `backend/app/services/translator.py`
- [Sentiment timeline](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/sentiment_analyzer.py): `backend/app/services/sentiment_analyzer.py`
- [Keyword tracking](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/keyword_tracker.py): `backend/app/services/keyword_tracker.py`
- [Stream handling](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/stream_handler.py): `backend/app/services/stream_handler.py`

### Clip highlights

- [Dataset parsing](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/dataset_parser.py): `backend/app/services/dataset_parser.py`
- [Semantic matching](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/semantic_matcher.py): `backend/app/services/semantic_matcher.py`
- [Clip extraction](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/clip_extractor.py): `backend/app/services/clip_extractor.py`

### Persistence and integrations

- [Firebase data service](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/firebase_service.py): `backend/app/services/firebase_service.py`
- [YouTube discovery](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/youtube_service.py): `backend/app/services/youtube_service.py`
- [Twitter discovery](https://github.com/girirag/sentiment-analysis/blob/main/backend/app/services/twitter_service.py): `backend/app/services/twitter_service.py`
- **YouTube API**
- **Twitter API**

### Other components

- **Video analyst**

## Connections

- Video analyst → SvelteKit interface: uses (evidence: `README.md`)
- SvelteKit interface → Video upload: opens (evidence: `README.md`)
- Video upload → Video and stream routes: uploads video (evidence: `README.md`)
- Video and stream routes → Token verification: verifies token (evidence: `backend/app/api/routes/video.py`)
- Video and stream routes → Firebase data service: stores video (evidence: `backend/app/api/routes/video.py`)
- Video and stream routes → Background task worker: queues processing (evidence: `backend/app/api/routes/video.py`)
- Background task worker → Firebase data service: loads and saves results (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Video processing: processes video (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Speech transcription: transcribes audio (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Language translation: translates text (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Sentiment timeline: analyzes segments (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Keyword tracking: extracts keywords (evidence: `backend/app/tasks/celery_tasks.py`)
- Analysis views → Analysis and export routes: requests results (evidence: `README.md`)
- Analysis and export routes → Firebase data service: reads analysis (evidence: `backend/app/api/routes/analysis.py`)
- Video and stream routes → Stream handling: starts stream
- Realtime updates → Firebase data service: reads updates (evidence: `backend/app/api/routes/websocket.py`)
- Live stream views → Realtime updates: receives updates (evidence: `README.md`)
- Clip job routes → Token verification: verifies token (evidence: `backend/app/api/routes/clips.py`)
- Clip job routes → Firebase data service: checks video (evidence: `backend/app/api/routes/clips.py`)
- Clip job routes → Background task worker: queues clip job (evidence: `backend/app/api/routes/clips.py`)
- Background task worker → Dataset parsing: parses dataset (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Semantic matching: matches segments (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Clip extraction: extracts clips (evidence: `backend/app/tasks/celery_tasks.py`)
- Background task worker → Firebase data service: saves clip results (evidence: `backend/app/tasks/celery_tasks.py`)
- Clip browser → Clip job routes: browses and downloads (evidence: `README.md`)
- YouTube discovery → YouTube API: searches videos (evidence: `backend/app/services/youtube_service.py`)
- Twitter discovery → Twitter API: searches videos (evidence: `backend/app/services/twitter_service.py`)
- FastAPI application → Video and stream routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Analysis and export routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Clip job routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Realtime updates: mounts routes (evidence: `backend/app/main.py`)
