# pratyush-barik/bda-sentiment-analysis architecture

> Architecture diagram of the GitHub repository pratyush-barik/bda-sentiment-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pratyush-barik/bda-sentiment-analysis
- Repository: https://github.com/pratyush-barik/bda-sentiment-analysis

## Overview

This is an end-to-end product-review sentiment analytics platform. Its principal workflow is CLI-orchestrated: generate or load reviews, simulate distributed storage, clean records, then run MapReduce, Spark, document-store, ML, graph, and visualization stages. A Flask dashboard separately exposes analytics and sentiment inference. The README documents major capabilities beyond the sampled excerpts; links for those are cited to the README. Unsampled implementation details are not assumed.

Main entry points: [`main.py`](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/main.py) (Pipeline CLI), [`web/app.py`](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/web/app.py) (Flask Dashboard API), [`src/database/document_store.py`](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/document_store.py) (Document Store Factory), [`src/ml/spark_mllib_pipeline.py`](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/ml/spark_mllib_pipeline.py) (MLlib Classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Review Ingestion"]
  node_cli["Pipeline CLI<br/>[main.py]"]
  node_generator["Review Generator"]
end

subgraph group_processing["Distributed Processing"]
  node_hdfs["HDFS Simulator<br/>[hdfs_simulation.py]"]
  node_cleaner["Data Cleaner<br/>[data_cleaner.py]"]
  node_mapreduce["Sentiment MapReduce<br/>[sentiment_mr.py]"]
  node_sparkfactory["Spark Session<br/>[spark_session.py]"]
  node_sparkcore["Spark Core RDDs<br/>[spark_core_rdd.py]"]
  node_sparksql["Spark SQL"]
end

subgraph group_persistence["Document Persistence"]
  node_storeapi["Document Store Factory<br/>[document_store.py]"]
  node_localstore[("Local JSON Store<br/>[local_store.py]")]
  node_mongostore[("Mongo Store<br/>[mongo_store.py]")]
  node_mongopipeline["Mongo ETL Pipeline<br/>[mongo_pipeline.py]"]
end

subgraph group_insights["Models And Insights"]
  node_ml["MLlib Classifier"]
  node_evaluator["Model Evaluator<br/>[evaluator.py]"]
  node_graph["Review Graph Analytics"]
  node_visualizer["Plot Generator<br/>[plot_generator.py]"]
end

subgraph group_serving["Dashboard And Serving"]
  node_web["Flask Dashboard API<br/>[app.py]"]
end

node_user(("Analyst"))
node_mongodb[("MongoDB Atlas")]

node_user -->|"runs pipeline"| node_cli
node_cli -->|"generates reviews"| node_generator
node_cli -->|"simulates storage"| node_hdfs
node_cli -->|"cleans records"| node_cleaner
node_cli -->|"runs analysis"| node_mapreduce
node_cli -->|"persists reviews"| node_storeapi
node_storeapi -->|"selects fallback"| node_localstore
node_storeapi -->|"selects Mongo"| node_mongostore
node_mongostore -->|"connects to"| node_mongodb
node_cli -->|"runs extraction"| node_mongopipeline
node_mongopipeline -->|"ingests and queries"| node_mongodb
node_cli -->|"creates session"| node_sparkfactory
node_cli -->|"runs RDD analytics"| node_sparkcore
node_cli -->|"runs SQL analytics"| node_sparksql
node_cli -->|"trains classifier"| node_ml
node_ml -->|"evaluates model"| node_evaluator
node_cli -->|"runs graph analysis"| node_graph
node_cli -->|"generates figures"| node_visualizer
node_user -->|"uses dashboard"| node_web
node_web -->|"serves inference"| node_ml
node_web -->|"shows graph summaries"| node_graph
node_web -->|"inspects figures"| node_visualizer

click node_cli "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/main.py"
click node_generator "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/data/review_generator.py"
click node_hdfs "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/storage/hdfs_simulation.py"
click node_cleaner "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/data/data_cleaner.py"
click node_mapreduce "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/mapreduce/sentiment_mr.py"
click node_sparkfactory "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark_session.py"
click node_sparkcore "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark/spark_core_rdd.py"
click node_sparksql "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark/spark_sql_analytics.py"
click node_storeapi "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/document_store.py"
click node_localstore "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/local_store.py"
click node_mongostore "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/mongo_store.py"
click node_mongopipeline "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/mongo_pipeline.py"
click node_ml "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/ml/spark_mllib_pipeline.py"
click node_evaluator "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/ml/evaluator.py"
click node_graph "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/graph/review_graph_analytics.py"
click node_visualizer "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/visualization/plot_generator.py"
click node_web "https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/web/app.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_cli,node_generator toneBlue
class node_hdfs,node_cleaner,node_mapreduce,node_sparkfactory,node_sparkcore,node_sparksql,node_mongodb toneAmber
class node_storeapi,node_localstore,node_mongostore,node_mongopipeline toneMint
class node_ml,node_evaluator,node_graph,node_visualizer toneRose
class node_web,node_user toneIndigo
```

## Components

### Review Ingestion

- [Pipeline CLI](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/main.py): `main.py`
- [Review Generator](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/data/review_generator.py): `src/data/review_generator.py`

### Distributed Processing

- [HDFS Simulator](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/storage/hdfs_simulation.py): `src/storage/hdfs_simulation.py`
- [Data Cleaner](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/data/data_cleaner.py): `src/data/data_cleaner.py`
- [Sentiment MapReduce](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/mapreduce/sentiment_mr.py): `src/mapreduce/sentiment_mr.py`
- [Spark Session](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark_session.py): `src/spark_session.py`
- [Spark Core RDDs](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark/spark_core_rdd.py): `src/spark/spark_core_rdd.py`
- [Spark SQL](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/spark/spark_sql_analytics.py): `src/spark/spark_sql_analytics.py`

### Document Persistence

- [Document Store Factory](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/document_store.py): `src/database/document_store.py`
- [Local JSON Store](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/local_store.py): `src/database/local_store.py`
- [Mongo Store](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/mongo_store.py): `src/database/mongo_store.py`
- [Mongo ETL Pipeline](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/database/mongo_pipeline.py): `src/database/mongo_pipeline.py`

### Models And Insights

- [MLlib Classifier](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/ml/spark_mllib_pipeline.py): `src/ml/spark_mllib_pipeline.py`
- [Model Evaluator](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/ml/evaluator.py): `src/ml/evaluator.py`
- [Review Graph Analytics](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/graph/review_graph_analytics.py): `src/graph/review_graph_analytics.py`
- [Plot Generator](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/src/visualization/plot_generator.py): `src/visualization/plot_generator.py`

### Dashboard And Serving

- [Flask Dashboard API](https://github.com/pratyush-barik/bda-sentiment-analysis/blob/main/web/app.py): `web/app.py`

### Other components

- **Analyst**
- **MongoDB Atlas**

## Connections

- Analyst → Pipeline CLI: runs pipeline (evidence: `main.py`)
- Pipeline CLI → Review Generator: generates reviews (evidence: `main.py`)
- Pipeline CLI → HDFS Simulator: simulates storage (evidence: `main.py`)
- Pipeline CLI → Data Cleaner: cleans records (evidence: `main.py`)
- Pipeline CLI → Sentiment MapReduce: runs analysis (evidence: `main.py`)
- Pipeline CLI → Document Store Factory: persists reviews (evidence: `main.py`)
- Document Store Factory → Local JSON Store: selects fallback (evidence: `src/database/document_store.py`)
- Document Store Factory → Mongo Store: selects Mongo (evidence: `src/database/document_store.py`)
- Mongo Store → MongoDB Atlas: connects to (evidence: `src/database/mongo_store.py`)
- Pipeline CLI → Mongo ETL Pipeline: runs extraction (evidence: `main.py`)
- Mongo ETL Pipeline → MongoDB Atlas: ingests and queries (evidence: `src/database/mongo_pipeline.py`)
- Pipeline CLI → Spark Session: creates session (evidence: `main.py`)
- Pipeline CLI → Spark Core RDDs: runs RDD analytics (evidence: `main.py`)
- Pipeline CLI → Spark SQL: runs SQL analytics (evidence: `main.py`)
- Pipeline CLI → MLlib Classifier: trains classifier (evidence: `main.py`)
- MLlib Classifier → Model Evaluator: evaluates model (evidence: `src/ml/spark_mllib_pipeline.py`)
- Pipeline CLI → Review Graph Analytics: runs graph analysis (evidence: `main.py`)
- Pipeline CLI → Plot Generator: generates figures (evidence: `main.py`)
- Analyst → Flask Dashboard API: uses dashboard (evidence: `README.md`)
- Flask Dashboard API → MLlib Classifier: serves inference (evidence: `web/app.py`)
- Flask Dashboard API → Review Graph Analytics: shows graph summaries (evidence: `README.md`)
- Flask Dashboard API → Plot Generator: inspects figures (evidence: `web/app.py`)
