# shreychauhan02/comment_sentiment_analysis_project architecture

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

- Interactive diagram: https://gitdiagram.com/shreychauhan02/comment_sentiment_analysis_project
- Repository: https://github.com/shreychauhan02/comment_sentiment_analysis_project

## Overview

This is a YouTube-comment sentiment product combining a Chrome extension, a local FastAPI analysis service, and an MLOps training pipeline. The user opens the extension on a video; the backend retrieves comments, analyzes sentiment and spam, and returns insights for display and CSV export. The documented training stages progress from ingestion through registration, with MLflow/Dagshub tracking. Source excerpts support the API’s YouTube and Gemini calls and the pipeline modules; some stage links and the extension-to-backend relationship are documented in the README rather than shown in sampled calls.

Main entry points: [`fastapi-backend/main.py`](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/fastapi-backend/main.py) (Analysis API), [`src/data/utils.py`](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/utils.py) (Pipeline utilities), [`src/model/model_building.py`](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_building.py) (Sentiment training), [`src/model/model_evaluation.py`](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_evaluation.py) (Model evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_extension["Extension UI<br/>[popup.js]"]
end

subgraph group_serving["Analysis Service"]
  node_api["Analysis API<br/>[main.py]"]
  node_spamtrain["Spam training"]
end

subgraph group_training["Model Pipeline"]
  node_ingestion["Data ingestion<br/>[data_ingestion.py]"]
  node_preprocessing["Text preprocessing"]
  node_features["TF-IDF features"]
  node_trainingmodel["Sentiment training<br/>[model_building.py]"]
  node_evaluation["Model evaluation"]
  node_helpers["Pipeline utilities<br/>[utils.py]"]
end

subgraph group_tracking["Model Operations"]
  node_registration["Model registration<br/>[register_model.py]"]
end

node_viewer(("YouTube viewer"))
node_youtube["YouTube comments"]
node_gemini["Gemini summary"]
node_mlflow[("MLflow / Dagshub")]

node_viewer -->|"opens"| node_extension
node_extension -->|"requests analysis"| node_api
node_api -->|"fetches comments"| node_youtube
node_api -.->|"requests summary"| node_gemini
node_api -->|"returns insights"| node_extension
node_spamtrain -.->|"trains spam model"| node_api
node_ingestion -->|"feeds pipeline"| node_preprocessing
node_preprocessing -->|"feeds pipeline"| node_features
node_features -->|"feeds pipeline"| node_trainingmodel
node_trainingmodel -->|"feeds pipeline"| node_evaluation
node_evaluation -->|"feeds pipeline"| node_registration
node_ingestion -->|"uses"| node_helpers
node_preprocessing -->|"uses"| node_helpers
node_features -->|"uses"| node_helpers
node_trainingmodel -->|"uses"| node_helpers
node_evaluation -->|"uses"| node_helpers
node_registration -->|"uses"| node_helpers
node_trainingmodel -->|"logs run"| node_mlflow
node_evaluation -->|"logs metrics"| node_mlflow
node_registration -->|"registers models"| node_mlflow
node_api -->|"loads registered model"| node_mlflow

click node_extension "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/extension/popup.js"
click node_api "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/fastapi-backend/main.py"
click node_spamtrain "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/fastapi-backend/train_spam_model.py"
click node_ingestion "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/data_ingestion.py"
click node_preprocessing "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/data_preprocessing.py"
click node_features "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/feature_extraction.py"
click node_trainingmodel "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_building.py"
click node_evaluation "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_evaluation.py"
click node_registration "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/register_model.py"
click node_helpers "https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/utils.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_extension,node_viewer toneBlue
class node_api,node_spamtrain,node_mlflow toneAmber
class node_ingestion,node_preprocessing,node_features,node_trainingmodel,node_evaluation,node_helpers toneMint
class node_registration toneRose
class node_youtube,node_gemini toneIndigo
```

## Components

### User Experience

- [Extension UI](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/extension/popup.js): `extension/popup.js`

### Analysis Service

- [Analysis API](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/fastapi-backend/main.py): `fastapi-backend/main.py`
- [Spam training](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/fastapi-backend/train_spam_model.py): `fastapi-backend/train_spam_model.py`

### Model Pipeline

- [Data ingestion](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/data_ingestion.py): `src/data/data_ingestion.py`
- [Text preprocessing](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/data_preprocessing.py): `src/data/data_preprocessing.py`
- [TF-IDF features](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/feature_extraction.py): `src/data/feature_extraction.py`
- [Sentiment training](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_building.py): `src/model/model_building.py`
- [Model evaluation](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/model/model_evaluation.py): `src/model/model_evaluation.py`
- [Pipeline utilities](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/utils.py): `src/data/utils.py`

### Model Operations

- [Model registration](https://github.com/shreychauhan02/comment_sentiment_analysis_project/blob/master/src/data/register_model.py): `src/data/register_model.py`

### Other components

- **YouTube viewer**
- **YouTube comments**
- **Gemini summary**
- **MLflow / Dagshub**

## Connections

- YouTube viewer → Extension UI: opens (evidence: `README.md`)
- Extension UI → Analysis API: requests analysis (evidence: `README.md`)
- Analysis API → YouTube comments: fetches comments (evidence: `fastapi-backend/main.py`)
- Analysis API → Gemini summary: requests summary (evidence: `fastapi-backend/main.py`)
- Analysis API → Extension UI: returns insights (evidence: `README.md`)
- Spam training → Analysis API: trains spam model
- Data ingestion → Text preprocessing: feeds pipeline (evidence: `README.md`)
- Text preprocessing → TF-IDF features: feeds pipeline (evidence: `README.md`)
- TF-IDF features → Sentiment training: feeds pipeline (evidence: `README.md`)
- Sentiment training → Model evaluation: feeds pipeline (evidence: `README.md`)
- Model evaluation → Model registration: feeds pipeline (evidence: `README.md`)
- Data ingestion → Pipeline utilities: uses (evidence: `src/data/data_ingestion.py`)
- Text preprocessing → Pipeline utilities: uses (evidence: `src/data/data_preprocessing.py`)
- TF-IDF features → Pipeline utilities: uses (evidence: `src/data/feature_extraction.py`)
- Sentiment training → Pipeline utilities: uses (evidence: `src/model/model_building.py`)
- Model evaluation → Pipeline utilities: uses (evidence: `src/model/model_evaluation.py`)
- Model registration → Pipeline utilities: uses (evidence: `src/data/register_model.py`)
- Sentiment training → MLflow / Dagshub: logs run (evidence: `src/model/model_building.py`)
- Model evaluation → MLflow / Dagshub: logs metrics (evidence: `src/model/model_evaluation.py`)
- Model registration → MLflow / Dagshub: registers models (evidence: `src/data/register_model.py`)
- Analysis API → MLflow / Dagshub: loads registered model (evidence: `fastapi-backend/main.py`)
