# maheshwaree-02/narrative-tracker architecture

> Architecture diagram of the GitHub repository maheshwaree-02/narrative-tracker, 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/maheshwaree-02/narrative-tracker
- Repository: https://github.com/maheshwaree-02/narrative-tracker

## Overview

Narrative Migration Tracker analyzes how narratives move from news to YouTube. Its principal workflow collects platform posts, preprocesses and embeds them, discovers narrative clusters, matches clusters across platforms, infers migration and coordination, then produces explanations and analytical views. The README also documents sentiment analysis, temporal and network analysis, Granger causality, and dashboard capabilities. Source excerpts and the index support several internal connections; README-documented stages fill in high-level workflow links where implementation details were not shown.

Main entry points: [`src/pipeline/runner.py`](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/pipeline/runner.py) (Pipeline Runner), [`src/dashboard/app.py`](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/app.py) (Analytics Dashboard), [`src/collectors`](https://github.com/maheshwaree-02/narrative-tracker/tree/main/src/collectors) (Platform Collectors), [`src/detection/migration.py`](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/detection/migration.py) (Migration Detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Collection and Preparation"]
  node_collectors["Platform Collectors"]
  node_posts["Post Records<br/>[post.py]"]
  node_storage[("Post Database<br/>[db.py]")]
  node_preprocess["Text Preparation<br/>[pipeline.py]"]
end

subgraph group_analysis["Narrative Analysis"]
  node_embeddings["Semantic Embeddings<br/>[engine.py]"]
  node_sentiment["Sentiment Analysis"]
  node_clusterer["Narrative Clustering"]
  node_dynamic["Dynamic Topics<br/>[dynamic_topics.py]"]
  node_lineage["Narrative Lineage<br/>[lineage_tracker.py]"]
  node_narratives["Narrative Models<br/>[narrative.py]"]
  node_matching["Cross-Platform Matching<br/>[cross_platform.py]"]
  node_migration["Migration Detection<br/>[migration.py]"]
  node_migration_models["Migration Models<br/>[migration.py]"]
  node_coordination["Coordination Detection<br/>[coordination.py]"]
  node_coord_models["Coordination Models<br/>[coordination.py]"]
  node_temporal["Temporal Analysis<br/>[temporal.py]"]
  node_network["Network Analysis<br/>[network.py]"]
  node_causality["Granger Causality"]
end

subgraph group_insights["Explanations and Reports"]
  node_explainer["Narrative Explainer<br/>[narrator.py]"]
  node_llm["LLM Client<br/>[llm_client.py]"]
  node_reports["Report Generation<br/>[report.py]"]
  node_runner["Pipeline Runner<br/>[runner.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_dashboard["Analytics Dashboard<br/>[app.py]"]
  node_overview["Overview View<br/>[overview.py]"]
  node_timeline["Timeline View<br/>[timeline.py]"]
  node_network_view["Network View<br/>[network.py]"]
  node_analysis_view["Analysis View<br/>[analysis.py]"]
  node_api["Analytics API<br/>[main.py]"]
end

node_researcher(("Analyst"))
node_news[("News Dataset")]
node_youtube["YouTube API"]

node_researcher -->|"explores results"| node_dashboard
node_news -->|"supplies articles"| node_collectors
node_youtube -->|"supplies transcripts"| node_collectors
node_collectors -.->|"creates records"| node_posts
node_collectors -.->|"stores posts"| node_storage
node_storage -.->|"provides posts"| node_runner
node_runner -->|"processes posts"| node_preprocess
node_preprocess -->|"cleans records"| node_posts
node_runner -->|"generates vectors"| node_embeddings
node_runner -->|"clusters posts"| node_clusterer
node_clusterer -->|"creates clusters"| node_narratives
node_runner -->|"tracks topics"| node_dynamic
node_runner -->|"matches clusters"| node_matching
node_matching -.->|"supplies matches"| node_migration
node_runner -->|"detects migration"| node_migration
node_migration -->|"builds events"| node_migration_models
node_runner -->|"detects coordination"| node_coordination
node_coordination -->|"builds assessments"| node_coord_models
node_runner -->|"analyzes timing"| node_temporal
node_runner -->|"builds networks"| node_network
node_migration -.->|"maps migration"| node_network
node_runner -->|"generates explanations"| node_explainer
node_explainer -->|"requests generation"| node_llm
node_explainer -->|"provides explanation"| node_reports
node_runner -->|"validates influence"| node_causality
node_runner -->|"analyzes framing"| node_sentiment
node_dashboard -->|"routes view"| node_overview
node_dashboard -->|"routes view"| node_timeline
node_dashboard -->|"routes view"| node_network_view
node_dashboard -->|"routes view"| node_analysis_view
node_api -.->|"serves analysis"| node_runner

click node_collectors "https://github.com/maheshwaree-02/narrative-tracker/tree/main/src/collectors"
click node_posts "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/post.py"
click node_storage "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/collectors/db.py"
click node_preprocess "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/preprocessing/pipeline.py"
click node_embeddings "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/embeddings/engine.py"
click node_sentiment "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/05b_sentiment_analysis.py"
click node_clusterer "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/narrative_clusterer.py"
click node_dynamic "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/dynamic_topics.py"
click node_lineage "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/lineage_tracker.py"
click node_narratives "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/narrative.py"
click node_matching "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/matching/cross_platform.py"
click node_migration "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/detection/migration.py"
click node_migration_models "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/migration.py"
click node_coordination "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/detection/coordination.py"
click node_coord_models "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/coordination.py"
click node_temporal "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/analysis/temporal.py"
click node_network "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/analysis/network.py"
click node_causality "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/12_granger_causality.py"
click node_explainer "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/narrator.py"
click node_llm "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/llm_client.py"
click node_reports "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/report.py"
click node_runner "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/pipeline/runner.py"
click node_dashboard "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/app.py"
click node_overview "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/overview.py"
click node_timeline "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/timeline.py"
click node_network_view "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/network.py"
click node_analysis_view "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/analysis.py"
click node_api "https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/api/main.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_collectors,node_posts,node_storage,node_preprocess toneBlue
class node_embeddings,node_sentiment,node_clusterer,node_dynamic,node_lineage,node_narratives,node_matching,node_migration,node_migration_models,node_coordination,node_coord_models,node_temporal,node_network,node_causality,node_news toneAmber
class node_explainer,node_llm,node_reports,node_runner,node_youtube toneMint
class node_dashboard,node_overview,node_timeline,node_network_view,node_analysis_view,node_api toneRose
class node_researcher toneIndigo
```

## Components

### Collection and Preparation

- [Platform Collectors](https://github.com/maheshwaree-02/narrative-tracker/tree/main/src/collectors): `src/collectors`
- [Post Records](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/post.py): `src/models/post.py`
- [Post Database](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/collectors/db.py): `src/collectors/db.py`
- [Text Preparation](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/preprocessing/pipeline.py): `src/preprocessing/pipeline.py`

### Narrative Analysis

- [Semantic Embeddings](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/embeddings/engine.py): `src/embeddings/engine.py`
- [Sentiment Analysis](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/05b_sentiment_analysis.py): `src/05b_sentiment_analysis.py`
- [Narrative Clustering](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/narrative_clusterer.py): `src/clustering/narrative_clusterer.py`
- [Dynamic Topics](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/dynamic_topics.py): `src/clustering/dynamic_topics.py`
- [Narrative Lineage](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/clustering/lineage_tracker.py): `src/clustering/lineage_tracker.py`
- [Narrative Models](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/narrative.py): `src/models/narrative.py`
- [Cross-Platform Matching](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/matching/cross_platform.py): `src/matching/cross_platform.py`
- [Migration Detection](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/detection/migration.py): `src/detection/migration.py`
- [Migration Models](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/migration.py): `src/models/migration.py`
- [Coordination Detection](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/detection/coordination.py): `src/detection/coordination.py`
- [Coordination Models](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/models/coordination.py): `src/models/coordination.py`
- [Temporal Analysis](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/analysis/temporal.py): `src/analysis/temporal.py`
- [Network Analysis](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/analysis/network.py): `src/analysis/network.py`
- [Granger Causality](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/12_granger_causality.py): `src/12_granger_causality.py`

### Explanations and Reports

- [Narrative Explainer](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/narrator.py): `src/explainer/narrator.py`
- [LLM Client](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/llm_client.py): `src/explainer/llm_client.py`
- [Report Generation](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/explainer/report.py): `src/explainer/report.py`
- [Pipeline Runner](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/pipeline/runner.py): `src/pipeline/runner.py`

### User Interfaces

- [Analytics Dashboard](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/app.py): `src/dashboard/app.py`
- [Overview View](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/overview.py): `src/dashboard/pages/overview.py`
- [Timeline View](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/timeline.py): `src/dashboard/pages/timeline.py`
- [Network View](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/network.py): `src/dashboard/pages/network.py`
- [Analysis View](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/dashboard/pages/analysis.py): `src/dashboard/pages/analysis.py`
- [Analytics API](https://github.com/maheshwaree-02/narrative-tracker/blob/main/src/api/main.py): `src/api/main.py`

### Other components

- **Analyst**
- **News Dataset**
- **YouTube API**

## Connections

- Analyst → Analytics Dashboard: explores results
- News Dataset → Platform Collectors: supplies articles
- YouTube API → Platform Collectors: supplies transcripts
- Platform Collectors → Post Records: creates records (evidence: `src/collectors/youtube.py`)
- Platform Collectors → Post Database: stores posts
- Post Database → Pipeline Runner: provides posts (evidence: `src/pipeline/runner.py`)
- Pipeline Runner → Text Preparation: processes posts (evidence: `src/pipeline/runner.py`)
- Text Preparation → Post Records: cleans records (evidence: `src/preprocessing/pipeline.py`)
- Pipeline Runner → Semantic Embeddings: generates vectors (evidence: `src/pipeline/runner.py`)
- Pipeline Runner → Narrative Clustering: clusters posts (evidence: `src/pipeline/runner.py`)
- Narrative Clustering → Narrative Models: creates clusters (evidence: `src/clustering/narrative_clusterer.py`)
- Pipeline Runner → Dynamic Topics: tracks topics (evidence: `src/pipeline/runner.py`)
- Pipeline Runner → Cross-Platform Matching: matches clusters (evidence: `src/pipeline/runner.py`)
- Cross-Platform Matching → Migration Detection: supplies matches
- Pipeline Runner → Migration Detection: detects migration (evidence: `src/pipeline/runner.py`)
- Migration Detection → Migration Models: builds events (evidence: `src/detection/migration.py`)
- Pipeline Runner → Coordination Detection: detects coordination (evidence: `src/pipeline/runner.py`)
- Coordination Detection → Coordination Models: builds assessments (evidence: `src/detection/coordination.py`)
- Pipeline Runner → Temporal Analysis: analyzes timing (evidence: `src/pipeline/runner.py`)
- Pipeline Runner → Network Analysis: builds networks (evidence: `src/pipeline/runner.py`)
- Migration Detection → Network Analysis: maps migration
- Pipeline Runner → Narrative Explainer: generates explanations (evidence: `src/pipeline/runner.py`)
- Narrative Explainer → LLM Client: requests generation (evidence: `src/explainer/narrator.py`)
- Narrative Explainer → Report Generation: provides explanation (evidence: `src/pipeline/runner.py`)
- Pipeline Runner → Granger Causality: validates influence
- Pipeline Runner → Sentiment Analysis: analyzes framing
- Analytics Dashboard → Overview View: routes view (evidence: `src/dashboard/app.py`)
- Analytics Dashboard → Timeline View: routes view (evidence: `src/dashboard/app.py`)
- Analytics Dashboard → Network View: routes view (evidence: `src/dashboard/app.py`)
- Analytics Dashboard → Analysis View: routes view (evidence: `src/dashboard/app.py`)
- Analytics API → Pipeline Runner: serves analysis
