# nithyakumaresan231-lang/online-shopping-counter architecture

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

- Interactive diagram: https://gitdiagram.com/nithyakumaresan231-lang/online-shopping-counter
- Repository: https://github.com/nithyakumaresan231-lang/online-shopping-counter

## Overview

This repository implements online-shopping transaction streaming analytics. The principal workflow publishes CSV records to Kafka, parses and enriches the stream with Spark, computes streaming metrics, persists analytics artifacts, and presents them in a Streamlit dashboard. Analytics also maintains transaction history and provides KPI, category, city, payment, status, and time-window aggregations. The excerpts show the producer, stream entry point, aggregation and dashboard data-loading layers; some dashboard wiring and deployment details are not represented here.

Main entry points: [`analytics/aggregations.py`](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/analytics/aggregations.py) (Streaming Aggregations), [`producer/producer.py`](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/producer/producer.py) (Kafka Producer), [`streaming/spark_stream.py`](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/streaming/spark_stream.py) (Spark Stream), [`output`](https://github.com/nithyakumaresan231-lang/online-shopping-counter/tree/main/output) (Analytics Artifacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Transaction Ingestion"]
  node_dataset["Transaction CSV"]
  node_producer["Kafka Producer<br/>[producer.py]"]
  node_kafka["Kafka Topic"]
end

subgraph group_processing["Stream Processing"]
  node_spark["Spark Stream<br/>[spark_stream.py]"]
  node_contracts["Transaction Schemas<br/>[schemas.py]"]
end

subgraph group_analytics["Analytics"]
  node_aggregations["Streaming Aggregations<br/>[aggregations.py]"]
  node_artifacts["Analytics Artifacts"]
end

subgraph group_presentation["Dashboard"]
  node_loader["Dashboard Data Loader<br/>[data_loader.py]"]
  node_dashboard["Streamlit Dashboard<br/>[dashboard.py]"]
end

node_operator(("Operator"))

node_operator -->|"starts publishing"| node_producer
node_dataset -->|"reads rows"| node_producer
node_producer -->|"publishes JSON"| node_kafka
node_kafka -->|"streams records"| node_spark
node_spark -->|"starts analytics"| node_aggregations
node_aggregations -->|"uses schema"| node_contracts
node_aggregations -->|"writes metrics"| node_artifacts
node_artifacts -->|"loads metrics"| node_loader
node_loader -->|"provides dashboard data"| node_dashboard
node_dashboard -->|"displays analytics"| node_operator

click node_dataset "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/data/ecommerce_transactions.csv"
click node_producer "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/producer/producer.py"
click node_spark "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/streaming/spark_stream.py"
click node_contracts "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/analytics/schemas.py"
click node_aggregations "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/analytics/aggregations.py"
click node_artifacts "https://github.com/nithyakumaresan231-lang/online-shopping-counter/tree/main/output"
click node_loader "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/dashboard/data_loader.py"
click node_dashboard "https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/dashboard/dashboard.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_dataset,node_producer,node_kafka toneBlue
class node_spark,node_contracts toneAmber
class node_aggregations,node_artifacts toneMint
class node_loader,node_dashboard toneRose
class node_operator toneIndigo
```

## Components

### Transaction Ingestion

- [Transaction CSV](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/data/ecommerce_transactions.csv): `data/ecommerce_transactions.csv`
- [Kafka Producer](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/producer/producer.py): `producer/producer.py`
- **Kafka Topic**

### Stream Processing

- [Spark Stream](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/streaming/spark_stream.py): `streaming/spark_stream.py`
- [Transaction Schemas](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/analytics/schemas.py): `analytics/schemas.py`

### Analytics

- [Streaming Aggregations](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/analytics/aggregations.py): `analytics/aggregations.py`
- [Analytics Artifacts](https://github.com/nithyakumaresan231-lang/online-shopping-counter/tree/main/output): `output`

### Dashboard

- [Dashboard Data Loader](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/dashboard/data_loader.py): `dashboard/data_loader.py`
- [Streamlit Dashboard](https://github.com/nithyakumaresan231-lang/online-shopping-counter/blob/main/dashboard/dashboard.py): `dashboard/dashboard.py`

### Other components

- **Operator**

## Connections

- Operator → Kafka Producer: starts publishing (evidence: `producer/producer.py`)
- Transaction CSV → Kafka Producer: reads rows (evidence: `producer/producer.py`)
- Kafka Producer → Kafka Topic: publishes JSON (evidence: `producer/producer.py`)
- Kafka Topic → Spark Stream: streams records (evidence: `streaming/spark_stream.py`)
- Spark Stream → Streaming Aggregations: starts analytics (evidence: `streaming/spark_stream.py`)
- Streaming Aggregations → Transaction Schemas: uses schema (evidence: `analytics/aggregations.py`)
- Streaming Aggregations → Analytics Artifacts: writes metrics (evidence: `analytics/aggregations.py`)
- Analytics Artifacts → Dashboard Data Loader: loads metrics (evidence: `dashboard/data_loader.py`)
- Dashboard Data Loader → Streamlit Dashboard: provides dashboard data (evidence: `dashboard/dashboard.py`)
- Streamlit Dashboard → Operator: displays analytics (evidence: `dashboard/dashboard.py`)
