# 14abhishek/newssummarize architecture

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

- Interactive diagram: https://gitdiagram.com/14abhishek/newssummarize
- Repository: https://github.com/14abhishek/newssummarize

## Overview

##### Project Type & Purpose
- Type: A single-page real-time analytics dashboard (full-stack-style, but served entirely by Streamlit).
- Purpose: Fetch news from NewsAPI, run NLP (sentiment + topic modeling), and render interactive visualizations.

##### File Structure
- Top-level scripts:
- app.py – Streamlit UI and orchestrator
- news_fetcher.py – handles external API calls
- sentiment_analyzer.py – NLP component for sentiment
- topic_modeler.py – NLP component for topics
- data_visualizer.py – creates Plotly/Matplotlib/WordCloud outputs
- utils.py – shared data-prep helpers
- No persistent database—data is held in memory/Streamlit session.
- External config: `.streamlit/config.toml` for deployment, `pyproject.toml` for dependencies.

##### Extract Key Architecture Insights from README
- Frontend: Streamlit (Python)
- Data Processing: Pandas, NumPy
- NLP: NLTK, Scikit-learn
- Visualization: Plotly, Matplotlib, WordCloud
- External Service: NewsAPI
- Auto-update scheduler built into Streamlit sidebar settings

##### Main Components & Interactions
a. User (Web Browser) & Streamlit UI
- Triggers data-refresh and filter changes
b. NewsFetcher Module
- Calls NewsAPI → JSON articles
c. Processing Pipeline
1. utils.py cleans & structures raw JSON → DataFrame
2. sentiment_analyzer.py tags each article
3. topic_modeler.py assigns topic labels
d. DataVisualizer Module
- Consumes annotated DataFrame → renders charts & word clouds
e. Environment & Config
- NEWS_API_KEY, refresh interval, filter settings
f. External Service
- NewsAPI (REST calls over HTTPS)

##### Architectural Patterns & Principles
- Modular pipeline (each .py file is one stage)
- Single-page UI orchestration (app.py as controller)
- In-memory data flow (no external DB)
- Extensibility: utils.py for shared logic, easy to plug in new analysis steps

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "UI Layer"
        UI["app.py / Streamlit UI\n(includes scheduler)"]:::ui
    end

    subgraph "Processing Pipeline"
        NF["news_fetcher.py\n(NewsAPI calls)"]:::proc
        UT["utils.py\n(clean & structure)"]:::proc
        SA["sentiment_analyzer.py\n(NLTK, scikit-learn)"]:::proc
        TM["topic_modeler.py\n(label topics)"]:::proc
    end

    DV["data_visualizer.py\n(Plotly, Matplotlib, WordCloud)"]:::viz

    subgraph "External Services & Config"
        API["NewsAPI\n(REST API)"]:::ext
        CFG[".streamlit/config.toml"]:::ext
        PY["pyproject.toml"]:::ext
        RD["README.md"]:::ext
    end

    UI -->|"trigger fetch & filters"| NF
    NF -->|"GET articles"| API
    API -->|"JSON articles"| NF
    NF -->|"raw JSON"| UT
    UT -->|"cleaned DataFrame"| SA
    SA -->|"DF w/ sentiment"| TM
    TM -->|"DF w/ topics"| DV
    DV -->|"charts & word clouds"| UI

    CFG -.->|"deployment settings"| UI
    PY -.->|"dependencies"| NF
    PY -.->|"dependencies"| DV
    RD -.->|"project overview"| UI

    click UI "https://github.com/14abhishek/newssummarize/blob/main/app.py"
    click NF "https://github.com/14abhishek/newssummarize/blob/main/news_fetcher.py"
    click UT "https://github.com/14abhishek/newssummarize/blob/main/utils.py"
    click SA "https://github.com/14abhishek/newssummarize/blob/main/sentiment_analyzer.py"
    click TM "https://github.com/14abhishek/newssummarize/blob/main/topic_modeler.py"
    click DV "https://github.com/14abhishek/newssummarize/blob/main/data_visualizer.py"
    click CFG "https://github.com/14abhishek/newssummarize/blob/main/.streamlit/config.toml"
    click PY "https://github.com/14abhishek/newssummarize/blob/main/pyproject.toml"
    click RD "https://github.com/14abhishek/newssummarize/blob/main/README.md"

    classDef ui fill:#D6E9FF,stroke:#0366d6,color:#0366d6;
    classDef proc fill:#E0F7E0,stroke:#28a745,color:#28a745;
    classDef viz fill:#FFE4B5,stroke:#d2691e,color:#d2691e;
    classDef ext fill:#E8E8E8,stroke:#6a737d,color:#6a737d;
```
