# vanderitto/cityzen_pulse architecture

> Architecture diagram of the GitHub repository vanderitto/cityzen_pulse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vanderitto/cityzen_pulse
- Repository: https://github.com/vanderitto/cityzen_pulse

## Overview

Cityzen Pulse ingests football-community posts, persists them for analysis, and presents fan sentiment and discussion in a Streamlit dashboard. Its main workflow is a recurring Reddit scrape, filtering, and dual write to PostgreSQL and a Hive-style JSON data lake; the dashboard then reads PostgreSQL, performs on-the-fly sentiment and topic inference, and visualizes the results. The README also describes fixture schedules and a Jupyter exploration environment. Source evidence is strongest for the sampled ingestion and dashboard code; unsampled database setup and notebook behavior are represented only where the tree or README supports them.

Main entry points: [`frontend/app.py`](https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py) (Streamlit dashboard), [`ingestion/main.py`](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/main.py) (Ingestion worker), [`ingestion/scrapers.py`](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/scrapers.py) (Reddit scraper), [`ingestion/database.py`](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/database.py) (Post writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_ingestion_loop["Ingestion worker<br/>[main.py]"]
  node_reddit_scraper["Reddit scraper<br/>[scrapers.py]"]
end

subgraph group_storage["Data Storage"]
  node_hive_lake[("Hive JSON lake<br/>[main.py]")]
  node_db_writer["Post writer<br/>[database.py]"]
  node_postgres[("PostgreSQL<br/>[init.sql]")]
end

subgraph group_dashboard["Dashboard and Analysis"]
  node_dashboard_app["Streamlit dashboard<br/>[app.py]"]
  node_post_reader["Post retrieval<br/>[app.py]"]
  node_nlp_analysis["Sentiment and topics<br/>[app.py]"]
  node_fixture_schedule["Fixture schedule<br/>[app.py]"]
end

subgraph group_exploration["Exploration"]
  node_jupyter_eda["Jupyter exploration<br/>[01_mcfc_eda.ipynb]"]
end

node_operator(("Dashboard user"))
node_reddit["Reddit"]
node_football_api["Football data API"]

node_ingestion_loop -->|"fetches posts"| node_reddit_scraper
node_reddit_scraper -->|"requests posts"| node_reddit
node_ingestion_loop -->|"writes JSON"| node_hive_lake
node_ingestion_loop -->|"saves posts"| node_db_writer
node_db_writer -->|"upserts posts"| node_postgres
node_dashboard_app -->|"loads dashboard data"| node_post_reader
node_post_reader -->|"queries posts"| node_postgres
node_dashboard_app -->|"runs inference"| node_nlp_analysis
node_dashboard_app -->|"loads fixtures"| node_fixture_schedule
node_fixture_schedule -->|"requests matches"| node_football_api
node_operator -.->|"views insights"| node_dashboard_app

click node_ingestion_loop "https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/main.py"
click node_reddit_scraper "https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/scrapers.py"
click node_hive_lake "https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/main.py"
click node_db_writer "https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/database.py"
click node_postgres "https://github.com/vanderitto/cityzen_pulse/blob/main/db/init.sql"
click node_dashboard_app "https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py"
click node_post_reader "https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py"
click node_nlp_analysis "https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py"
click node_fixture_schedule "https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py"
click node_jupyter_eda "https://github.com/vanderitto/cityzen_pulse/blob/main/notebooks/01_mcfc_eda.ipynb"

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_ingestion_loop,node_reddit_scraper,node_operator toneBlue
class node_hive_lake,node_db_writer,node_postgres toneAmber
class node_dashboard_app,node_post_reader,node_nlp_analysis,node_fixture_schedule,node_football_api toneMint
class node_jupyter_eda toneRose
class node_reddit toneIndigo
```

## Components

### Ingestion

- [Ingestion worker](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/main.py): `ingestion/main.py`
- [Reddit scraper](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/scrapers.py): `ingestion/scrapers.py`

### Data Storage

- [Hive JSON lake](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/main.py): `ingestion/main.py`
- [Post writer](https://github.com/vanderitto/cityzen_pulse/blob/main/ingestion/database.py): `ingestion/database.py`
- [PostgreSQL](https://github.com/vanderitto/cityzen_pulse/blob/main/db/init.sql): `db/init.sql`

### Dashboard and Analysis

- [Streamlit dashboard](https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py): `frontend/app.py`
- [Post retrieval](https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py): `frontend/app.py`
- [Sentiment and topics](https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py): `frontend/app.py`
- [Fixture schedule](https://github.com/vanderitto/cityzen_pulse/blob/main/frontend/app.py): `frontend/app.py`

### Exploration

- [Jupyter exploration](https://github.com/vanderitto/cityzen_pulse/blob/main/notebooks/01_mcfc_eda.ipynb): `notebooks/01_mcfc_eda.ipynb`

### Other components

- **Dashboard user**
- **Reddit**
- **Football data API**

## Connections

- Ingestion worker → Reddit scraper: fetches posts (evidence: `ingestion/main.py`)
- Reddit scraper → Reddit: requests posts (evidence: `ingestion/scrapers.py`)
- Ingestion worker → Hive JSON lake: writes JSON (evidence: `ingestion/main.py`)
- Ingestion worker → Post writer: saves posts (evidence: `ingestion/main.py`)
- Post writer → PostgreSQL: upserts posts (evidence: `ingestion/database.py`)
- Streamlit dashboard → Post retrieval: loads dashboard data (evidence: `frontend/app.py`)
- Post retrieval → PostgreSQL: queries posts (evidence: `frontend/app.py`)
- Streamlit dashboard → Sentiment and topics: runs inference (evidence: `frontend/app.py`)
- Streamlit dashboard → Fixture schedule: loads fixtures (evidence: `frontend/app.py`)
- Fixture schedule → Football data API: requests matches (evidence: `frontend/app.py`)
- Dashboard user → Streamlit dashboard: views insights (evidence: `README.md`)
