# prayesh13/youtube-comments-analysis architecture

> Architecture diagram of the GitHub repository prayesh13/youtube-comments-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prayesh13/youtube-comments-analysis
- Repository: https://github.com/prayesh13/youtube-comments-analysis

## Overview

##### Project type and purpose
- This is an end‑to‑end machine‑learning pipeline for YouTube comment sentiment analysis, packaging a trained model behind a Flask API and exposing it via a Chrome plugin. It uses DVC for data/model versioning and GitHub Actions for CI/CD.

##### File structure
- Top‑level orchestration and config:
- Makefile, Dockerfile, dvc.yaml/dvc.lock → pipeline stages (data→train→evaluate)
- GitHub Actions (cicd.yaml) → CI/CD
- Data science pipeline:
- notebooks/ → exploration & prototyping
- src/data/ → data_ingestion.py, data_preprocessing.py
- src/features/ → feature engineering
- src/model/ → model_building.py, model_evaluation.py, register_model.py
- src/visualization/ → visualization scripts
- models/ & vocab.pkl → serialized artifacts
- Service layer:
- flask_app/ → app.py, requirements.txt → inference microservice
- Packaging & testing:
- setup.py, requirements.txt, tox.ini
- Documentation & reports: docs/, reports/

##### README for additional insights
- Follows cookiecutter‑datascience template
- Make targets (make data, make train) reflect DVC stages
- Emphasizes src/ modular structure

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Data Source
    YT["YouTube Data API"]:::external

    %% Data Pipeline
    subgraph "Data Pipeline"
        DI["Data Ingestion"]:::pipeline
        DP["Data Preprocessing"]:::pipeline
        FE["Feature Engineering"]:::pipeline
        MB["Model Building"]:::pipeline
        ME["Model Evaluation"]:::pipeline
        RM["Model Registration"]:::pipeline
        RAW[(raw data)]:::datastore
        INTERIM[(interim data)]:::datastore
        PROCESSED[(processed data)]:::datastore

        YT -->|"fetch data"| DI
        DI --> RAW
        RAW -->|"stage: preprocess"| DP
        DP --> INTERIM
        INTERIM -->|"stage: features"| FE
        FE --> PROCESSED
        PROCESSED -->|"stage: train"| MB
        MB -->|"artifact"| ME
        ME --> RM
    end

    %% Artifacts & Registry
    subgraph "Artifacts & Model Registry"
        MODELS[(models/ directory)]:::artifacts
        DVC_REMOTE[(DVC Remote)]:::artifacts
        VOCAB[(vocab.pkl)]:::artifacts
        RM -->|push model| DVC_REMOTE
        RM -->|save artifact| MODELS
    end

    %% Inference Service
    subgraph "Inference Service"
        API["Flask API (app.py)"]:::service
        REQ["requirements.txt"]:::service
        API -->|loads model + vocab| MODELS
        API -->|loads vocab| VOCAB
    end

    %% Frontend Plugin
    PLUGIN["Chrome Extension"]:::external
    PLUGIN -->|HTTP POST /predict| API

    %% Orchestration & Deployment
    subgraph "Orchestration & Deployment"
        MK["Makefile"]:::orchestration
        DVC_CFG["dvc.yaml & dvc.lock"]:::orchestration
        DOCK["Dockerfile"]:::orchestration
        CI["GitHub Actions (cicd.yaml)"]:::orchestration
        MK -->|runs DVC stages| DVC_CFG
        CI -->|tests & builds| DOCK
        CI -->|deploys service| API
    end

    %% Experimental Notebooks
    NB["notebooks/"]:::experimental

    %% Documentation & Reports
    DOC["docs/"]:::docs
    RPT["reports/"]:::docs

    %% Layout
    YT --> DI
    RM --> API
    API --> PLUGIN

    %% Click Events
    click DI "https://github.com/prayesh13/youtube-comments-analysis/blob/master/src/data/data_ingestion.py"
    click DP "https://github.com/prayesh13/youtube-comments-analysis/blob/master/src/data/data_preprocessing.py"
    click FE "https://github.com/prayesh13/youtube-comments-analysis/tree/master/src/features/"
    click MB "https://github.com/prayesh13/youtube-comments-analysis/blob/master/src/model/model_building.py"
    click ME "https://github.com/prayesh13/youtube-comments-analysis/blob/master/src/model/model_evaluation.py"
    click RM "https://github.com/prayesh13/youtube-comments-analysis/blob/master/src/model/register_model.py"
    click MODELS "https://github.com/prayesh13/youtube-comments-analysis/tree/master/models/"
    click VOCAB "https://github.com/prayesh13/youtube-comments-analysis/blob/master/flask_app/vocab.pkl"
    click API "https://github.com/prayesh13/youtube-comments-analysis/blob/master/flask_app/app.py"
    click REQ "https://github.com/prayesh13/youtube-comments-analysis/blob/master/flask_app/requirements.txt"
    click DVC_CFG "https://github.com/prayesh13/youtube-comments-analysis/blob/master/dvc.yaml"
    click MK "https://github.com/prayesh13/youtube-comments-analysis/tree/master/Makefile"
    click DOCK "https://github.com/prayesh13/youtube-comments-analysis/tree/master/Dockerfile"
    click CI "https://github.com/prayesh13/youtube-comments-analysis/blob/master/.github/workflows/cicd.yaml"
    click NB "https://github.com/prayesh13/youtube-comments-analysis/tree/master/notebooks/"
    click DOC "https://github.com/prayesh13/youtube-comments-analysis/tree/master/docs/"

    %% Styles
    classDef pipeline fill:#add8e6,stroke:#333,stroke-width:1px
    classDef datastore fill:#90ee90,stroke:#333,stroke-width:1px
    classDef artifacts fill:#b2dfdb,stroke:#333,stroke-width:1px
    classDef service fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef orchestration fill:#d8bfd8,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef experimental fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef docs fill:#f0f0f0,stroke:#333,stroke-width:1px
```
