# manpatell/climate-sentiment-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/manpatell/climate-sentiment-analyzer
- Repository: https://github.com/manpatell/climate-sentiment-analyzer

## Overview

1. **Overall shape**
   This repository is a single-process Python application with two layers: a Streamlit dashboard for interactive analysis and a reusable NLP core in `src/climate_analyzer`. There is no separate backend service, database, or message queue; all analysis runs locally in the Streamlit app process.

2. **Primary runtime boundary**
   `app.py` is the dashboard entry point and serves the main overview page. The `pages/` directory implements Streamlit’s multipage navigation, so each dashboard screen is an isolated UI module that imports the shared analysis library.

3. **Core analysis engine**
   `src/climate_analyzer/analyzer.py` is the central domain subsystem. It wraps sentiment scoring around VADER, extends the lexicon with climate-specific terms, and exposes operations for single-text analysis, batch analysis, and keyword aggregation.

4. **Domain data model**
   `src/climate_analyzer/models.py` defines the typed result objects used across the app, likely including article and sentiment result records. This is the main contract boundary between the NLP engine and the UI, keeping analysis output structured and testable.

5. **Dataset and corpus support**
   `src/climate_analyzer/data.py` contains the curated 18-article climate corpus used by the overview, batch, and trends pages. The dashboard is therefore not fetching live external news; it is operating on a bundled sample dataset for reproducible analysis and demonstrations.

6. **UI-to-core data flow**
   The Streamlit pages collect text input or filter selections, call `ClimateAnalyzer`, then render derived metrics with Plotly charts and tables. The flow is: user input or sample article selection → sentiment/keyword analysis → labeled results, scores, densities, and aggregates → visualizations and exports.

7. **Dashboard page responsibilities**
   `pages/1_Analyzer.py` is the single-document deep-dive view, `pages/2_Batch.py` handles comparison and CSV export across multiple articles, and `pages/3_Trends.py` renders time-series sentiment trends and event markers. These pages are presentation-focused and share the same core analyzer rather than duplicating logic.

8. **Analytics outputs**
   The app surfaces several computed dimensions beyond polarity: compound sentiment, positive/neutral/negative proportions, climate keyword density, top keyword frequencies, category averages, regional breakdowns, and temporal rolling averages. These are all derived from the same in-memory corpus and analysis results.

9. **Technology stack**
   The architecture is built around Streamlit for the interface, Plotly for visualization, Pandas/NumPy for tabular and numerical processing, and VADER for sentiment scoring. The project targets Python 3.11+ and uses standard packaging via `pyproject.toml` plus `requirements.txt`.

10. **Quality and validation boundary**
   `tests/test_analyzer.py` and `tests/test_models.py` cover the core engine and data structures, indicating that most correctness risk is concentrated in the library layer rather than the UI. GitHub Actions CI (`.github/workflows/ci.yml`) runs the test suite across Python versions, providing a lightweight release gate for the dashboard and NLP logic.

11. **External dependencies and constraints**
   The only meaningful external dependency at runtime is the VADER sentiment model/library; the climate-specific behavior comes from a hand-crafted lexicon override inside the repo. Because the dataset is bundled and the analysis is local, the architecture is deterministic and offline-friendly.

12. **How to draw it**
   A diagram should show a central `ClimateAnalyzer` library fed by text samples and dataset records, with three Streamlit page modules and the overview app as callers. Around that, show Plotly rendering on the UI side, static sample data in `data.py`, and a test/CI lane validating the models and analyzer independently of the dashboard.

Main entry points: [`src/climate_analyzer/analyzer.py`](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/analyzer.py) (ClimateAnalyzer), [`pages/1_Analyzer.py`](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/1_Analyzer.py) (Analyzer), [`pages/2_Batch.py`](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/2_Batch.py) (Batch), [`pages/3_Trends.py`](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/3_Trends.py) (Trends)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI"]
  node_app_py["App<br/>Streamlit entrypoint<br/>[app.py]"]
  node_page_analyzer["Analyzer<br/>Streamlit page<br/>[1_Analyzer.py]"]
  node_page_batch["Batch<br/>Streamlit page<br/>[2_Batch.py]"]
  node_page_trends["Trends<br/>Streamlit page<br/>[3_Trends.py]"]
end

subgraph group_core["Core"]
  node_analyzer_core["ClimateAnalyzer<br/>NLP engine<br/>[analyzer.py]"]
  node_models["Models<br/>data model<br/>[models.py]"]
  node_data[("Corpus<br/>bundled dataset<br/>[data.py]")]
end

subgraph group_deps["Deps"]
  node_streamlit(("Streamlit<br/>UI library"))
  node_plotly(("Plotly<br/>viz library"))
  node_pandas(("Pandas/NumPy<br/>data stack"))
  node_vader(("VADER<br/>sentiment library"))
end

subgraph group_validation["Validation"]
  node_test_analyzer["Analyzer tests<br/>unit tests<br/>[test_analyzer.py]"]
  node_test_models["Model tests<br/>unit tests<br/>[test_models.py]"]
  node_ci["CI<br/>workflow<br/>[ci.yml]"]
end

node_app_py -->|"runs on"| node_streamlit
node_app_py -->|"navigates"| node_page_analyzer
node_app_py -->|"navigates"| node_page_batch
node_app_py -->|"navigates"| node_page_trends
node_page_analyzer -->|"analyzes"| node_analyzer_core
node_page_batch -->|"analyzes"| node_analyzer_core
node_page_trends -->|"analyzes"| node_analyzer_core
node_page_analyzer -->|"samples"| node_data
node_page_batch -->|"loads"| node_data
node_page_trends -->|"streams"| node_data
node_analyzer_core -->|"returns"| node_models
node_analyzer_core -->|"consumes"| node_data
node_analyzer_core -->|"scores with"| node_vader
node_page_batch -->|"tabulates"| node_pandas
node_page_trends -->|"plots"| node_plotly
node_page_analyzer -->|"plots"| node_plotly
node_page_analyzer -->|"renders"| node_models
node_page_batch -->|"renders"| node_models
node_page_trends -->|"renders"| node_models
node_test_analyzer -->|"verifies"| node_analyzer_core
node_test_models -->|"verifies"| node_models
node_ci -->|"runs"| node_test_analyzer
node_ci -->|"runs"| node_test_models

click node_app_py "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/app.py"
click node_page_analyzer "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/1_Analyzer.py"
click node_page_batch "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/2_Batch.py"
click node_page_trends "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/3_Trends.py"
click node_analyzer_core "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/analyzer.py"
click node_models "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/models.py"
click node_data "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/data.py"
click node_test_analyzer "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/tests/test_analyzer.py"
click node_test_models "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/tests/test_models.py"
click node_ci "https://github.com/manpatell/climate-sentiment-analyzer/blob/main/.github/workflows/ci.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_py,node_page_analyzer,node_page_batch,node_page_trends toneBlue
class node_analyzer_core,node_models,node_data toneAmber
class node_streamlit,node_plotly,node_pandas,node_vader toneMint
class node_test_analyzer,node_test_models,node_ci toneRose
```

## Components

### UI

Streamlit entrypoint and dashboard pages

- [App](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/app.py): Streamlit entrypoint · Main dashboard overview and app launcher · `app.py`
- [Analyzer](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/1_Analyzer.py): Streamlit page · Single-document sentiment deep dive · `pages/1_Analyzer.py`
- [Batch](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/2_Batch.py): Streamlit page · Multi-article comparison and export · `pages/2_Batch.py`
- [Trends](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/pages/3_Trends.py): Streamlit page · Temporal sentiment trends and markers · `pages/3_Trends.py`

### Core

Reusable NLP engine, corpus, and result models

- [ClimateAnalyzer](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/analyzer.py): NLP engine · VADER-based climate sentiment analysis and aggregation · `src/climate_analyzer/analyzer.py`
- [Models](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/models.py): data model · Typed analysis and article result contracts · `src/climate_analyzer/models.py`
- [Corpus](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/src/climate_analyzer/data.py): bundled dataset · Curated offline climate article sample set · `src/climate_analyzer/data.py`

### Deps

Primary runtime libraries used by the app

- **Streamlit**: UI library · Interactive multipage dashboard runtime
- **Plotly**: viz library · Charts and interactive visualizations
- **Pandas/NumPy**: data stack · Tabular and numeric processing for metrics and exports
- **VADER**: sentiment library · Base sentiment scorer extended with climate lexicon terms

### Validation

Tests and CI gate for the library layer

- [Analyzer tests](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/tests/test_analyzer.py): unit tests · Coverage for core sentiment and aggregation logic · `tests/test_analyzer.py`
- [Model tests](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/tests/test_models.py): unit tests · Coverage for typed result structures · `tests/test_models.py`
- [CI](https://github.com/manpatell/climate-sentiment-analyzer/blob/main/.github/workflows/ci.yml): workflow · GitHub Actions test gate across Python versions · `.github/workflows/ci.yml`

## Connections

- App → Streamlit: runs on · Dashboard executes inside Streamlit
- App → Analyzer: navigates · Main app exposes the analyzer page
- App → Batch: navigates · Main app exposes the batch page
- App → Trends: navigates · Main app exposes the trends page
- Analyzer → ClimateAnalyzer: analyzes · Deep-dive page calls shared analysis engine
- Batch → ClimateAnalyzer: analyzes · Batch page reuses the core analyzer
- Trends → ClimateAnalyzer: analyzes · Trends page derives scores from the shared engine
- Analyzer → Corpus: samples · Page can use bundled articles for exploration
- Batch → Corpus: loads · Batch comparisons operate on the local corpus
- Trends → Corpus: streams · Trend charts are built from the bundled corpus
- ClimateAnalyzer → Models: returns · Analysis results are structured as typed models
- ClimateAnalyzer → Corpus: consumes · Core engine processes bundled climate articles
- ClimateAnalyzer → VADER: scores with · Sentiment scoring is delegated to VADER
- Batch → Pandas/NumPy: tabulates · Batch views use tabular processing and export support
- Trends → Plotly: plots · Trends page renders time-series visualizations
- Analyzer → Plotly: plots · Single-article analysis uses charts and metrics
- Analyzer → Models: renders · UI consumes structured result objects
- Batch → Models: renders · Comparison tables use the shared result schema
- Trends → Models: renders · Trend summaries are based on typed analysis data
- Analyzer tests → ClimateAnalyzer: verifies · Unit tests cover core analyzer behavior
- Model tests → Models: verifies · Unit tests cover data model contracts
- CI → Analyzer tests: runs · CI executes analyzer tests
- CI → Model tests: runs · CI executes model tests
