# kaushi019/wiki-live-analytics architecture

> Architecture diagram of the GitHub repository kaushi019/wiki-live-analytics, 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/kaushi019/wiki-live-analytics
- Repository: https://github.com/kaushi019/wiki-live-analytics

## Overview

This is a live Wikipedia edit-monitoring application: Wikimedia events are collected, buffered through Kafka, scored and SLA-classified, persisted to PostgreSQL, and presented through three Streamlit views. A separate `src/ingestor.py` path also implements direct stream-to-database ingestion. The sampled producer/consumer code supports the Kafka path; the dashboard excerpts show direct database queries, rather than dashboard reads from Kafka. The analytics page exposes stored Polars aggregations, while the advanced page provides title/comment search, account filters, and risk visualizations. Evidence is limited to the README and sampled source excerpts; unsampled infrastructure wiring is not asserted.

Main entry points: [`src/db_manager.py`](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/db_manager.py) (Database Access), [`src/kafka_consumer.py`](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_consumer.py) (Kafka Consumer), [`src/ingestor.py`](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/ingestor.py) (Direct Ingestor), [`src/transformer.py`](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/transformer.py) (Polars Aggregator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Event Ingestion"]
  node_kafka_producer["Kafka Producer<br/>[kafka_producer.py]"]
  node_direct_ingestor["Direct Ingestor<br/>[ingestor.py]"]
  node_kafka["Kafka Topic"]
end

subgraph group_processing["Stream Processing"]
  node_kafka_consumer["Kafka Consumer<br/>[kafka_consumer.py]"]
  node_sla["SLA Evaluator<br/>[kafka_consumer.py]"]
  node_detector["Anomaly Detector<br/>[ml_model.py]"]
end

subgraph group_data["Storage &amp; Analytics"]
  node_db_manager["Database Access<br/>[db_manager.py]"]
  node_postgres[("PostgreSQL")]
  node_transformer["Polars Aggregator<br/>[transformer.py]"]
end

subgraph group_interface["Monitoring Interface"]
  node_dashboard["Live Monitor<br/>[dashboard.py]"]
  node_analytics_page["Aggregations View"]
  node_insights_page["Search &amp; Insights"]
end

node_wikimedia(("Wikipedia Events"))
node_operator(("Dashboard User"))

node_wikimedia -->|"streams events"| node_kafka_producer
node_kafka_producer -->|"publishes edits"| node_kafka
node_kafka -->|"delivers messages"| node_kafka_consumer
node_wikimedia -->|"streams events"| node_direct_ingestor
node_kafka_consumer -->|"scores edits"| node_detector
node_kafka_consumer -->|"evaluates alerts"| node_sla
node_kafka_consumer -->|"inserts batches"| node_db_manager
node_kafka_consumer -->|"runs aggregation"| node_transformer
node_direct_ingestor -->|"scores edits"| node_detector
node_direct_ingestor -->|"inserts batches"| node_db_manager
node_direct_ingestor -->|"runs aggregation"| node_transformer
node_transformer -->|"reads and writes"| node_db_manager
node_db_manager -->|"queries and stores"| node_postgres
node_dashboard -->|"queries records"| node_db_manager
node_analytics_page -->|"queries features"| node_db_manager
node_insights_page -->|"queries records"| node_db_manager
node_operator -.->|"views monitor"| node_dashboard
node_operator -.->|"views aggregates"| node_analytics_page
node_operator -.->|"searches insights"| node_insights_page

click node_kafka_producer "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_producer.py"
click node_direct_ingestor "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/ingestor.py"
click node_kafka_consumer "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_consumer.py"
click node_sla "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_consumer.py"
click node_detector "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/ml_model.py"
click node_db_manager "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/db_manager.py"
click node_transformer "https://github.com/kaushi019/wiki-live-analytics/blob/main/src/transformer.py"
click node_dashboard "https://github.com/kaushi019/wiki-live-analytics/blob/main/app/dashboard.py"
click node_analytics_page "https://github.com/kaushi019/wiki-live-analytics/blob/main/app/pages/1_Polars_Analytics.py"
click node_insights_page "https://github.com/kaushi019/wiki-live-analytics/blob/main/app/pages/2_Advanced_Insights.py"

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_kafka_producer,node_direct_ingestor,node_kafka,node_operator toneBlue
class node_kafka_consumer,node_sla,node_detector toneAmber
class node_db_manager,node_postgres,node_transformer toneMint
class node_dashboard,node_analytics_page,node_insights_page toneRose
class node_wikimedia toneIndigo
```

## Components

### Event Ingestion

- [Kafka Producer](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_producer.py): `src/kafka_producer.py`
- [Direct Ingestor](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/ingestor.py): `src/ingestor.py`
- **Kafka Topic**

### Stream Processing

- [Kafka Consumer](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_consumer.py): `src/kafka_consumer.py`
- [SLA Evaluator](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/kafka_consumer.py): `src/kafka_consumer.py`
- [Anomaly Detector](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/ml_model.py): `src/ml_model.py`

### Storage & Analytics

- [Database Access](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/db_manager.py): `src/db_manager.py`
- **PostgreSQL**
- [Polars Aggregator](https://github.com/kaushi019/wiki-live-analytics/blob/main/src/transformer.py): `src/transformer.py`

### Monitoring Interface

- [Live Monitor](https://github.com/kaushi019/wiki-live-analytics/blob/main/app/dashboard.py): `app/dashboard.py`
- [Aggregations View](https://github.com/kaushi019/wiki-live-analytics/blob/main/app/pages/1_Polars_Analytics.py): `app/pages/1_Polars_Analytics.py`
- [Search & Insights](https://github.com/kaushi019/wiki-live-analytics/blob/main/app/pages/2_Advanced_Insights.py): `app/pages/2_Advanced_Insights.py`

### Other components

- **Wikipedia Events**
- **Dashboard User**

## Connections

- Wikipedia Events → Kafka Producer: streams events (evidence: `src/kafka_producer.py`)
- Kafka Producer → Kafka Topic: publishes edits (evidence: `src/kafka_producer.py`)
- Kafka Topic → Kafka Consumer: delivers messages (evidence: `src/kafka_consumer.py`)
- Wikipedia Events → Direct Ingestor: streams events (evidence: `src/ingestor.py`)
- Kafka Consumer → Anomaly Detector: scores edits (evidence: `src/kafka_consumer.py`)
- Kafka Consumer → SLA Evaluator: evaluates alerts (evidence: `src/kafka_consumer.py`)
- Kafka Consumer → Database Access: inserts batches (evidence: `src/kafka_consumer.py`)
- Kafka Consumer → Polars Aggregator: runs aggregation (evidence: `src/kafka_consumer.py`)
- Direct Ingestor → Anomaly Detector: scores edits (evidence: `src/ingestor.py`)
- Direct Ingestor → Database Access: inserts batches (evidence: `src/ingestor.py`)
- Direct Ingestor → Polars Aggregator: runs aggregation (evidence: `src/ingestor.py`)
- Polars Aggregator → Database Access: reads and writes (evidence: `src/transformer.py`)
- Database Access → PostgreSQL: queries and stores (evidence: `src/db_manager.py`)
- Live Monitor → Database Access: queries records (evidence: `app/dashboard.py`)
- Aggregations View → Database Access: queries features (evidence: `app/pages/1_Polars_Analytics.py`)
- Search & Insights → Database Access: queries records (evidence: `app/pages/2_Advanced_Insights.py`)
- Dashboard User → Live Monitor: views monitor (evidence: `README.md`)
- Dashboard User → Aggregations View: views aggregates (evidence: `README.md`)
- Dashboard User → Search & Insights: searches insights (evidence: `README.md`)
