How manpatell/climate-sentiment-analyzer works
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: analyzer.py ClimateAnalyzer · 1_Analyzer.py Analyzer · 2_Batch.py Batch · 3_Trends.py Trends
Components 14
UI
Streamlit entrypoint and dashboard pages
Core
Reusable NLP engine, corpus, and result models
- ClimateAnalyzer · VADER-based climate sentiment analysis and aggregation
src/climate_analyzer/analyzer.py - Models · Typed analysis and article result contracts
src/climate_analyzer/models.py - Corpus · Curated offline climate article sample set
src/climate_analyzer/data.py
Deps
Primary runtime libraries used by the app
- Streamlit · Interactive multipage dashboard runtime
- Plotly · Charts and interactive visualizations
- Pandas/NumPy · Tabular and numeric processing for metrics and exports
- VADER · Base sentiment scorer extended with climate lexicon terms
Validation
Tests and CI gate for the library layer
- Analyzer tests · Coverage for core sentiment and aggregation logic
tests/test_analyzer.py - Model tests · Coverage for typed result structures
tests/test_models.py - CI · GitHub Actions test gate across Python versions
.github/workflows/ci.yml
Connections 23
- 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