# bfiliks/streamlit-lda-dashboard architecture

> Architecture diagram of the GitHub repository bfiliks/streamlit-lda-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bfiliks/streamlit-lda-dashboard
- Repository: https://github.com/bfiliks/streamlit-lda-dashboard

## Overview

##### Project type and purpose
- This is a single‐page interactive data‐analysis dashboard built with Streamlit (Python) for NLP on YouTube comments. It is not a traditional multi‐service microservices app but a full‐stack “one‐process” web app: the same Python process provides both UI and business logic.

##### File structure
- Top level:
- app.py – the Streamlit entry point; contains all UI and processing code
- requirements.txt – lists Python dependencies (Streamlit, Gensim, TextBlob, Plotly, sklearn, pandas, etc.)
- sample CSV data and .gitignore, LICENSE, README.md
- No separate frontend folder – Streamlit generates the UI
- No separate backend folder or database – all data lives in memory or is uploaded/downloaded as CSV

##### README for additional insights
- Explains pipeline steps: CSV upload → text preprocessing → topic modeling (LDA) → sentiment analysis (TextBlob) → t-SNE clustering → interactive Plotly visualizations → CSV export
- Technologies: Python 3.9+, Streamlit, Gensim, TextBlob, Plotly, scikit-learn (t-SNE)

a. Main components:
- User’s Browser / Streamlit UI
- Streamlit Web Server (Python runtime)
- Data Ingestion Module (CSV upload & sample loader)
- NLP Preprocessing Module (tokenization, stopword removal)
- NLP Core Modules:
– Topic Modeling (Gensim LDA)
– Sentiment Analysis (TextBlob)
– Dimensionality Reduction (t-SNE via scikit-learn)
- Visualization Engine (Plotly charts embedded in Streamlit)
- Data Export Module (filtered/comment CSV download)
- External Dependencies (Python libraries from requirements.txt)

b. Relationships & data flows:
1. User uploads CSV via Streamlit UI →
2. Data Ingestion reads into pandas DataFrame →
3. Data passes to Preprocessing → cleans and tokenizes →
4a. Feeds LDA for topic assignments → returns topic labels
4b. Feeds TextBlob for sentiment scores
4c. Feeds vectorized text into t-SNE for cluster coordinates
5. Visualization Engine receives processed data → renders interactive charts in the browser
6. User may trigger “Export” → Data Export Module writes out filtered DataFrame as new CSV → prompts browser download

c. Architectural patterns & principles:
- Pipeline pattern (sequential data transformations)
- Single‐page application hosted entirely in a Python process
- Stateless between requests (all state lives in memory per session)
- Modular code organization within app.py (could be refactored into sub‐modules)

d. Key technologies & libraries:
- Streamlit (UI framework)
- pandas (data manipulation)
- Gensim (LDA topic modeling)
- TextBlob (sentiment analysis)
- scikit-learn (t-SNE)
- Plotly (interactive charts)

##### Essential details
- How tensors or DataFrames move between modules

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    BrowserUI["User's Browser / Streamlit UI"]:::ui

    %% Data Stores
    CSVIn[(Input CSV Data)]:::storage
    CSVOut[(Output CSV Data)]:::storage

    %% External Dependencies
    ExtLibs[(Python Dependencies & External Libraries)]:::external

    %% Streamlit Server Components
    subgraph "Streamlit Server"
        direction TB
        StreamlitServer["Streamlit Web Server (UI & Business Logic)"]:::process
        Ingestion["Data Ingestion Module (CSV upload & sample loader)"]:::process
        Preprocess["NLP Preprocessing Module (tokenization, stopword removal)"]:::process
        Topic["Topic Modeling (Gensim LDA)"]:::process
        Sentiment["Sentiment Analysis (TextBlob)"]:::process
        TSNE["Dimensionality Reduction (t-SNE via scikit-learn)"]:::process
        Visualization["Visualization Engine (Plotly charts embedded in Streamlit)"]:::process
        Export["Data Export Module (filtered/comment CSV download)"]:::process
    end

    %% Documentation Files
    README["Project Documentation & Pipeline Description"]:::doc
    Gitignore["Git Ignore Configuration"]:::doc
    License["License Information"]:::doc

    %% Data Flow
    BrowserUI -->|uploads CSV| CSVIn
    CSVIn --> Ingestion
    Ingestion --> Preprocess
    Preprocess --> Topic
    Preprocess --> Sentiment
    Preprocess --> TSNE
    Topic --> Visualization
    Sentiment --> Visualization
    TSNE --> Visualization
    Visualization -->|renders charts| BrowserUI
    BrowserUI -->|triggers export| Export
    Export --> CSVOut
    ExtLibs -.-> StreamlitServer

    %% Click Events
    click StreamlitServer "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Ingestion "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Preprocess "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Topic "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Sentiment "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click TSNE "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Visualization "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click Export "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/app.py"
    click ExtLibs "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/requirements.txt"
    click CSVIn "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/videoinfo_11FQQv81hDw_2025_07_08-03_59_30_comments.csv"
    click README "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/README.md"
    click Gitignore "https://github.com/bfiliks/streamlit-lda-dashboard/blob/main/.gitignore"
    click License "https://github.com/bfiliks/streamlit-lda-dashboard/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef process fill:#d4edda,stroke:#000,stroke-width:1px
    classDef storage fill:#fff3cd,stroke:#000,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#000,stroke-width:1px
    classDef doc fill:#f8d7da,stroke:#000,stroke-width:1px
```
