# syllygames/yt-comment-sentiment-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/syllygames/yt-comment-sentiment-analysis
- Repository: https://github.com/syllygames/yt-comment-sentiment-analysis

## Overview

- It contains a complete ML pipeline (data ingestion, preprocessing, feature engineering, model training, evaluation, and registration) located in directories like “src”, “notebooks”, “models”, “reports”, and “docs” (which match the cookiecutter data science template).
- It includes a Flask application (in “flask_app/app.py”) that likely serves as the backend API to which the Chrome plugin connects to obtain sentiment analysis results for YouTube comments.

##### Main Components
a. Frontend (Chrome Plugin)
– Represent the Chrome plugin as a separate component. This is the part running in the user’s browser that collects or displays YouTube comment sentiment information.
b. Backend API (Flask Application)
– Include the “flask_app” component (specifically the “app.py”) that likely exposes REST endpoints to receive comment data and return sentiment predictions.
c. Machine Learning Pipeline
d. Data Management & Versioning
– Highlight the usage of DVC (files like dvc.yaml and dvc.lock) to manage, version, and track datasets and intermediate artifacts.
e. Development and Deployment Infrastructure
– Include deployment components such as:
- Docker containerization (Dockerfile and deploy scripts).
- Continuous integration/continuous delivery via GitHub workflows (.github/workflows).
- Additional automation scripts present in “scripts” (like for testing and model serving) and “Makefile” for standard commands.
- The “appspec.yml” and deploy scripts that suggest deployment orchestration, possibly to AWS or a similar service.

##### Relationships and Interactions
– The Chrome Plugin forwards YouTube comment data via HTTP/HTTPS to the Flask API.
– The Flask API receives requests and interacts with the pre-trained ML model (produced from the “src” pipeline and stored in “models”) to predict sentiment.
– The ML pipeline (running separately) processes data and updates models. Once updated, these models are registered and then used by the Flask API in production.
– Communication flows should show data moving from the browser to the API, then from the API to the ML model, and the prediction results moving back to the browser.
– CI/CD components ensure that changes (in code, model artifacts, or configuration) trigger automated builds, tests, and deployments, keeping the production system updated.

##### Architectural Patterns and Technologies
– Separation of concerns: distinct layers for data processing (ETL and ML) and service provisioning (Flask API and Chrome plugin).
– Use of containerization (Docker) facilitates deployment and scaling.
– Data versioning via DVC supports reproducibility.
– Standard data science project structure implies modular, script-based orchestration for model building and evaluation.
– The Flask API acts as a lightweight microservice, interfacing between the browser plugin and the heavy data analytics backend.

##### Detail and Clarity
– Ensure that every module is represented – even if some parts (like “myenv” or many subfolders in the virtual environment) are more for development support, focus on illustrating the main runtime elements.
– Add annotations where appropriate to indicate decisions such as using DVC for versioning or Docker for containerizing the service.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    subgraph "Frontend"
        A["Chrome Plugin"]:::frontend
    end

    subgraph "Backend Services"
        B["Flask API Server"]:::backend
    end

    subgraph "ML Pipeline & Data Storage"
        C["Data Ingestion"]:::ml
        D["Data Preprocessing"]:::ml
        E["Feature Engineering"]:::ml
        F["Model Building"]:::ml
        G["Model Evaluation & Registration"]:::ml
        H["Model Artifacts (models, notebooks, reports)"]:::ml
    end

    subgraph "Infrastructure & Operations"
        I["Data Management & Versioning"]:::infra
        J["Containerization (Docker & Deploy Scripts)"]:::infra
        K["CI/CD"]:::infra
        L["Automation & Build Tools"]:::infra
        M["Deployment Orchestration"]:::infra
    end

    A -->|"sendsCommentData"| B
    B -->|"requestsModelInference"| H
    H -->|"returnsPrediction"| B

    C -->|"processes"| D
    D -->|"passesCleanedData"| E
    E -->|"transformsFeatures"| F
    F -->|"trainsModel"| G
    G -->|"registersModel"| H

    I -->|"versionsData"| C
    I -->|"tracksModel"| F

    J -->|"deploysBackend"| B
    J -->|"deploysMLArtifacts"| H
    K -->|"triggersCI/CD"| B
    K -->|"triggersCI/CD"| H
    L -->|"automatesBuilds"| B
    L -->|"automatesBuilds"| H
    M -->|"orchestratesDeployment"| B

    click B "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/flask_app/app.py"
    click C "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/src/data/data_ingestion.py"
    click D "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/src/data/data_preprocessing.py"
    click E "https://github.com/syllygames/yt-comment-sentiment-analysis/tree/master/src/features/"
    click F "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/src/model/model_building.py"
    click G "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/src/model/model_evaluation.py"
    click H "https://github.com/syllygames/yt-comment-sentiment-analysis/tree/master/models"
    click I "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/dvc.yaml"
    click J "https://github.com/syllygames/yt-comment-sentiment-analysis/tree/master/Dockerfile"
    click K "https://github.com/syllygames/yt-comment-sentiment-analysis/tree/master/.github/workflows"
    click L "https://github.com/syllygames/yt-comment-sentiment-analysis/tree/master/Makefile"
    click M "https://github.com/syllygames/yt-comment-sentiment-analysis/blob/master/appspec.yml"

    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ml fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef infra fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
```
