# arv-anshul/yt-comment-sentiment architecture

> Architecture diagram of the GitHub repository arv-anshul/yt-comment-sentiment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arv-anshul/yt-comment-sentiment
- Repository: https://github.com/arv-anshul/yt-comment-sentiment

## Overview

##### Main System Components

a. Frontend Layer
- Built with Vue.js and Vite
- Components for video URL input, comments display, and sentiment visualization
- UI components using shadcn/ui
- Key components:
- VideoUrlInputForm
- VideoComments
- SentimentPieChart
- YTVideoDetailsCard

b. Backend Layer
- FastAPI-based server
- YouTube data fetching capabilities
- Inference endpoint for sentiment analysis
- Routes for insights and analytics

c. ML Pipeline Layer
- Data ingestion
- Model building
- Model evaluation
- MLflow experiment tracking
- DVC pipeline management

##### Component Relationships and Data Flow

- Frontend → Backend API calls
- Backend → YouTube API interactions
- Backend → ML Model inference calls
- ML Pipeline → MLflow tracking
- DVC → Pipeline orchestration

##### External Services Integration

- YouTube Data API
- MLflow tracking server
- Model registry

##### Specific Implementation Details

Create sections showing:

a. ML Pipeline Flow:
**Data Ingestion → Text Vectorization (TfidfVectorizer) → Model Training (HistGradientBoostingClassifier) → Model Evaluation**

b. API Flow:
**Frontend Request → FastAPI Backend → Sentiment Prediction → Response with Results**

##### Technology Stack Representation

- Frontend: Vue.js, Tailwind CSS, shadcn/ui
- Backend: FastAPI, Python
- ML: scikit-learn, NLTK
- DevOps: DVC, MLflow
- Data Processing: Polars

##### Deployment Architecture

Containers/services:
- Frontend container (Nginx)
- Backend container (FastAPI)
- ML model serving
- Docker Compose orchestration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        VUE[Vue.js + Vite]
        VIF["VideoUrlInputForm"]:::frontend
        VC["VideoComments"]:::frontend
        SPC["SentimentPieChart"]:::frontend
        YTDC["YTVideoDetailsCard"]:::frontend
        UI["UI Components"]:::frontend
    end

    subgraph Backend
        API["FastAPI Server"]:::backend
        YTR["YouTube Routes"]:::backend
        UTIL["Backend Utilities"]:::backend
    end

    subgraph "ML Pipeline"
        DI["Data Ingestion"]:::ml
        MB["Model Building"]:::ml
        ME["Model Evaluation"]:::ml
        PARAM["ML Parameters"]:::ml
    end

    subgraph "Pipeline Management"
        DVC["DVC Pipeline"]:::infra
        MLFLOW["MLflow Tracking"]:::infra
    end

    subgraph "External Services"
        YTAPI["YouTube Data API"]:::external
        MTRACK["MLflow Server"]:::external
        MREG["Model Registry"]:::external
    end

    subgraph "Infrastructure"
        DFRONT["Frontend Docker"]:::infra
        DBACK["Backend Docker"]:::infra
        DCOMP["Docker Compose"]:::infra
    end

    VUE --> VIF & VC & SPC & YTDC
    VIF & VC & SPC & YTDC --> API
    API --> YTR
    YTR --> YTAPI
    YTR --> UTIL
    API --> DI
    DI --> MB
    MB --> ME
    ME --> MLFLOW
    DVC --> DI & MB & ME
    MLFLOW --> MTRACK
    MTRACK --> MREG

    %% Click events for component mapping
    click VIF "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/frontend/src/components/VideoUrlInputForm.vue"
    click VC "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/frontend/src/components/VideoComments.vue"
    click SPC "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/frontend/src/components/SentimentPieChart.vue"
    click YTDC "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/frontend/src/components/YTVideoDetailsCard.vue"
    click UI "https://github.com/arv-anshul/yt-comment-sentiment/tree/main/frontend/src/components/ui/"
    click API "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/backend/app.py"
    click YTR "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/backend/routes/youtube.py"
    click UTIL "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/backend/utils.py"
    click DI "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/ml/comment_sentiment/ingestion.py"
    click MB "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/ml/comment_sentiment/building.py"
    click ME "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/ml/comment_sentiment/evaluation.py"
    click PARAM "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/ml/params.py"
    click DVC "https://github.com/arv-anshul/yt-comment-sentiment/tree/main/.dvc/config"
    click DFRONT "https://github.com/arv-anshul/yt-comment-sentiment/tree/main/frontend/Dockerfile"
    click DBACK "https://github.com/arv-anshul/yt-comment-sentiment/tree/main/Dockerfile"
    click DCOMP "https://github.com/arv-anshul/yt-comment-sentiment/blob/main/docker-compose.yaml"

    %% Styling
    classDef frontend fill:#42b883,stroke:#35495e,color:white
    classDef backend fill:#009688,stroke:#00796b,color:white
    classDef ml fill:#ff6b6b,stroke:#c62828,color:white
    classDef infra fill:#4a90e2,stroke:#357abd,color:white
    classDef external fill:#9575cd,stroke:#673ab7,color:white

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        B["Backend Component"]:::backend
        M["ML Component"]:::ml
        I["Infrastructure"]:::infra
        E["External Service"]:::external
    end
```
