# mansoorxcoder/sentiment architecture

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

- Interactive diagram: https://gitdiagram.com/mansoorxcoder/sentiment
- Repository: https://github.com/mansoorxcoder/sentiment

## Overview

#### Purpose and Runtime
SentiMeter is a client-side sentiment-analysis workbench. It accepts review text and simulated Amazon/Flipkart product URLs, presents positive/neutral/negative results, and compares four algorithm simulations. The deployable entry point is the Vite/React application at `src/main.tsx`, rooted in `src/App.tsx`; Node.js/Vite builds and serves it.

#### Application Shell and Navigation
The top-level app provides routed pages and shared layout/theme behavior. The principal user routes are the landing page, analysis experience, algorithm comparison, informational page, and fallback page:
- `src/App.tsx`
- `src/components/Layout.tsx`
- `src/pages/Home.tsx`
- `src/pages/Analyze.tsx`
- `src/pages/Index.tsx`

#### Sentiment Analysis Flow
The analysis page is the main interaction boundary: users submit raw review text or a supported product link, select an algorithm, and receive a classified sentiment and confidence. Browser-side logic performs the classification; there is no indicated dependency from this UI to a live ML service.
- `src/pages/Analyze.tsx`
- `src/utils/sentimentAnalyzer.ts`
- `src/components/AlgorithmSelector.tsx`
- `src/components/SentimentResult.tsx`

#### Algorithm Simulation Layer
Classification behavior and comparison metadata are centralized in frontend utility modules. The stated model options are Neural Network, SVM, Naïve Bayes, and Logistic Regression; results are rendered as an explanatory comparison rather than executing the archived Python model artifacts.
- `src/utils/algorithms.ts`
- `src/utils/sentimentAnalyzer.ts`
- `src/components/AlgorithmComparison.tsx`

#### Visualization and Presentation
Result and comparison views use reusable React components and charting/UI primitives. Styling is Tailwind-based with a component library under `src/components/ui`; global visual rules are in application CSS.
- `src/components/AlgorithmComparison.tsx`
- `src/components/SentimentResult.tsx`
- `src/components/ui/chart.tsx`
- `src/index.css`

#### Historical Python/ML Pipeline
`SA/test` preserves a separate, staged Python implementation: dataset combination/preprocessing, static model training/inference artifacts, dynamic prediction/web interface, dashboard visualization, and a containerized backend/frontend variant. It is architecturally distinct from the root React app, but supplies the repository’s real serialized classifiers and TF-IDF vectorizers.
- `SA/test/01_Data_Preprocessing/data_preprocessing.py`
- `SA/test/02_Static_Implementation/static_implementation.py`
- `SA/test/03_Dynamic_Implementation/dynamic_prediction.py`
- `SA/test/BE_API/app/main.py`

#### Data, Models, and Deployment Boundary
CSV review datasets feed the legacy preprocessing/training path; generated `.pkl` classifier/vectorizer assets are copied into both static and API-oriented locations. Docker Compose connects the legacy API and static frontend containers. The current React UI has no visible configured API contract to that service.
- `SA/test/dataset/lappi.csv`
- `SA/test/models/tfidf_vectorizer.pkl`
- `SA/test/docker-compose.yml`
- `SA/test/BE_API/Dockerfile`

Main entry points: [`src/App.tsx`](https://github.com/mansoorxcoder/sentiment/blob/main/src/App.tsx) (App routes), [`src/utils/sentimentAnalyzer.ts`](https://github.com/mansoorxcoder/sentiment/blob/main/src/utils/sentimentAnalyzer.ts) (Browser classifier), [`SA/test/BE_API/app/main.py`](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/BE_API/app/main.py) (Legacy prediction API), [`src/pages/Analyze.tsx`](https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Analyze.tsx) (Analysis experience)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_react["Current React Workbench"]
  node_vite{{"Vite / Node runtime<br/>build runtime<br/>[main.tsx]"}}
  node_app["App routes<br/>React shell<br/>[App.tsx]"]
  node_layout["Shared layout<br/>React layout<br/>[Layout.tsx]"]
  node_home["Landing page<br/>React page<br/>[Home.tsx]"]
  node_analyze["Analysis experience<br/>React page<br/>[Analyze.tsx]"]
  node_comparison["Comparison page<br/>React page<br/>[Index.tsx]"]
  node_selector["Algorithm selector<br/>React component"]
  node_analyzer{{"Browser classifier<br/>sentiment utility"}}
  node_algorithm_meta["Algorithm simulations<br/>comparison utility<br/>[algorithms.ts]"]
  node_result["Sentiment result<br/>React component"]
  node_algorithm_view["Algorithm comparison view<br/>React component"]
  node_chart_ui["Chart primitives<br/>UI component<br/>[chart.tsx]"]
  node_styles["Global Tailwind styling<br/>CSS<br/>[index.css]"]
end

subgraph group_legacy["Historical Python/ML Pipeline"]
  node_dataset[("Review CSV data<br/>dataset<br/>[lappi.csv]")]
  node_preprocessing["Dataset preprocessing<br/>Python stage"]
  node_static_ml["Static training / inference<br/>Python stage"]
  node_model_assets[("TF-IDF model assets<br/>serialized model")]
  node_dynamic_ml["Dynamic prediction<br/>Python stage"]
  node_legacy_api{{"Legacy prediction API<br/>Python API<br/>[main.py]"}}
  node_compose{{"Legacy container deployment<br/>Docker Compose<br/>[docker-compose.yml]"}}
  node_api_dockerfile["API container image<br/>Dockerfile"]
end

node_vite -->|"mounts"| node_app
node_app -->|"uses"| node_layout
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_analyze
node_app -->|"routes to"| node_comparison
node_analyze -->|"selects algorithm"| node_selector
node_analyze -->|"submits input"| node_analyzer
node_selector -->|"configures"| node_analyzer
node_analyzer -->|"uses simulations"| node_algorithm_meta
node_analyzer -->|"returns result"| node_result
node_comparison -->|"renders"| node_algorithm_view
node_algorithm_meta -->|"supplies metadata"| node_algorithm_view
node_algorithm_view -->|"uses"| node_chart_ui
node_styles -.->|"styles"| node_app
node_dataset -->|"feeds"| node_preprocessing
node_preprocessing -->|"prepares data"| node_static_ml
node_static_ml -->|"generates"| node_model_assets
node_model_assets -->|"loads"| node_dynamic_ml
node_model_assets -->|"loads"| node_legacy_api
node_api_dockerfile -->|"packages"| node_legacy_api
node_compose -->|"orchestrates"| node_legacy_api
node_analyzer -.->|"no configured API contract"| node_legacy_api

click node_vite "https://github.com/mansoorxcoder/sentiment/blob/main/src/main.tsx"
click node_app "https://github.com/mansoorxcoder/sentiment/blob/main/src/App.tsx"
click node_layout "https://github.com/mansoorxcoder/sentiment/blob/main/src/components/Layout.tsx"
click node_home "https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Home.tsx"
click node_analyze "https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Analyze.tsx"
click node_comparison "https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Index.tsx"
click node_selector "https://github.com/mansoorxcoder/sentiment/blob/main/src/components/AlgorithmSelector.tsx"
click node_analyzer "https://github.com/mansoorxcoder/sentiment/blob/main/src/utils/sentimentAnalyzer.ts"
click node_algorithm_meta "https://github.com/mansoorxcoder/sentiment/blob/main/src/utils/algorithms.ts"
click node_result "https://github.com/mansoorxcoder/sentiment/blob/main/src/components/SentimentResult.tsx"
click node_algorithm_view "https://github.com/mansoorxcoder/sentiment/blob/main/src/components/AlgorithmComparison.tsx"
click node_chart_ui "https://github.com/mansoorxcoder/sentiment/blob/main/src/components/ui/chart.tsx"
click node_styles "https://github.com/mansoorxcoder/sentiment/blob/main/src/index.css"
click node_dataset "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/dataset/lappi.csv"
click node_preprocessing "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/01_Data_Preprocessing/data_preprocessing.py"
click node_static_ml "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/02_Static_Implementation/static_implementation.py"
click node_model_assets "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/models/tfidf_vectorizer.pkl"
click node_dynamic_ml "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/03_Dynamic_Implementation/dynamic_prediction.py"
click node_legacy_api "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/BE_API/app/main.py"
click node_compose "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/docker-compose.yml"
click node_api_dockerfile "https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/BE_API/Dockerfile"

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_vite,node_app,node_layout,node_home,node_analyze,node_comparison,node_selector,node_analyzer,node_algorithm_meta,node_result,node_algorithm_view,node_chart_ui,node_styles toneBlue
class node_dataset,node_preprocessing,node_static_ml,node_model_assets,node_dynamic_ml,node_legacy_api,node_compose,node_api_dockerfile toneAmber
```

## Components

### Current React Workbench

Browser-only Vite/React sentiment simulation.

- [Vite / Node runtime](https://github.com/mansoorxcoder/sentiment/blob/main/src/main.tsx): build runtime · Builds and serves the client application. · `src/main.tsx`
- [App routes](https://github.com/mansoorxcoder/sentiment/blob/main/src/App.tsx): React shell · Defines routed pages and shared application behavior. · `src/App.tsx`
- [Shared layout](https://github.com/mansoorxcoder/sentiment/blob/main/src/components/Layout.tsx): React layout · Provides shared layout and theme behavior. · `src/components/Layout.tsx`
- [Landing page](https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Home.tsx): React page · `src/pages/Home.tsx`
- [Analysis experience](https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Analyze.tsx): React page · Accepts review text or supported product URLs and selected algorithms. · `src/pages/Analyze.tsx`
- [Comparison page](https://github.com/mansoorxcoder/sentiment/blob/main/src/pages/Index.tsx): React page · Presents algorithm comparison content. · `src/pages/Index.tsx`
- [Algorithm selector](https://github.com/mansoorxcoder/sentiment/blob/main/src/components/AlgorithmSelector.tsx): React component · Selects Neural Network, SVM, Naïve Bayes, or Logistic Regression. · `src/components/AlgorithmSelector.tsx`
- [Browser classifier](https://github.com/mansoorxcoder/sentiment/blob/main/src/utils/sentimentAnalyzer.ts): sentiment utility · Classifies input locally with confidence; no live ML service dependency. · `src/utils/sentimentAnalyzer.ts`
- [Algorithm simulations](https://github.com/mansoorxcoder/sentiment/blob/main/src/utils/algorithms.ts): comparison utility · Centralizes simulation behavior and comparison metadata. · `src/utils/algorithms.ts`
- [Sentiment result](https://github.com/mansoorxcoder/sentiment/blob/main/src/components/SentimentResult.tsx): React component · Renders positive, neutral, or negative classification and confidence. · `src/components/SentimentResult.tsx`
- [Algorithm comparison view](https://github.com/mansoorxcoder/sentiment/blob/main/src/components/AlgorithmComparison.tsx): React component · Explains and visualizes simulated algorithm differences. · `src/components/AlgorithmComparison.tsx`
- [Chart primitives](https://github.com/mansoorxcoder/sentiment/blob/main/src/components/ui/chart.tsx): UI component · `src/components/ui/chart.tsx`
- [Global Tailwind styling](https://github.com/mansoorxcoder/sentiment/blob/main/src/index.css): CSS · `src/index.css`

### Historical Python/ML Pipeline

Separate preserved training, inference, and container path.

- [Review CSV data](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/dataset/lappi.csv): dataset · Source reviews for the legacy pipeline. · `SA/test/dataset/lappi.csv`
- [Dataset preprocessing](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/01_Data_Preprocessing/data_preprocessing.py): Python stage · Combines and preprocesses review data. · `SA/test/01_Data_Preprocessing/data_preprocessing.py`
- [Static training / inference](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/02_Static_Implementation/static_implementation.py): Python stage · Produces and uses legacy classifier artifacts. · `SA/test/02_Static_Implementation/static_implementation.py`
- [TF-IDF model assets](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/models/tfidf_vectorizer.pkl): serialized model · Legacy vectorizer and classifier assets copied to inference locations. · `SA/test/models/tfidf_vectorizer.pkl`
- [Dynamic prediction](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/03_Dynamic_Implementation/dynamic_prediction.py): Python stage · Legacy dynamic prediction and web interface. · `SA/test/03_Dynamic_Implementation/dynamic_prediction.py`
- [Legacy prediction API](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/BE_API/app/main.py): Python API · Containerized API-oriented inference service. · `SA/test/BE_API/app/main.py`
- [Legacy container deployment](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/docker-compose.yml): Docker Compose · Connects legacy API and static frontend containers. · `SA/test/docker-compose.yml`
- [API container image](https://github.com/mansoorxcoder/sentiment/blob/main/SA/test/BE_API/Dockerfile): Dockerfile · `SA/test/BE_API/Dockerfile`

## Connections

- Vite / Node runtime → App routes: mounts
- App routes → Shared layout: uses
- App routes → Landing page: routes to
- App routes → Analysis experience: routes to
- App routes → Comparison page: routes to
- Analysis experience → Algorithm selector: selects algorithm
- Analysis experience → Browser classifier: submits input
- Algorithm selector → Browser classifier: configures
- Browser classifier → Algorithm simulations: uses simulations
- Browser classifier → Sentiment result: returns result
- Comparison page → Algorithm comparison view: renders
- Algorithm simulations → Algorithm comparison view: supplies metadata
- Algorithm comparison view → Chart primitives: uses
- Global Tailwind styling → App routes: styles
- Review CSV data → Dataset preprocessing: feeds
- Dataset preprocessing → Static training / inference: prepares data
- Static training / inference → TF-IDF model assets: generates
- TF-IDF model assets → Dynamic prediction: loads
- TF-IDF model assets → Legacy prediction API: loads
- API container image → Legacy prediction API: packages
- Legacy container deployment → Legacy prediction API: orchestrates
- Browser classifier → Legacy prediction API: no configured API contract
