# ydv-prince/sentiment-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/ydv-prince/sentiment-analysis
- Repository: https://github.com/ydv-prince/sentiment-analysis

## Overview

This is a notes-and-reviews sentiment analyzer: a user submits text in the React interface, the frontend sends it to the configured API, and the resulting text and sentiment are displayed. The README documents a companion Notes API that forwards prediction requests to the FastAPI service; that service calls the keyword-based classifier. The Notes API is not present in this repository, so its role and connection are based on documentation, not inspected source. The README also describes direct frontend-to-ML configuration as an optional fallback.

Main entry points: [`frontend/src/api.js`](https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/api.js) (Request client), [`ml-service/main.py`](https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/main.py) (Prediction endpoint), [`frontend/src/App.jsx`](https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/App.jsx) (Analyzer UI), [`ml-service/model.py`](https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/model.py) (Keyword classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Analyzer UI<br/>[App.jsx]"]
  node_api["Request client<br/>[api.js]"]
end

subgraph group_notes["Notes API"]
  node_notes_api["Notes API"]
end

subgraph group_ml["Sentiment service"]
  node_fastapi["Prediction endpoint<br/>[main.py]"]
  node_classifier["Keyword classifier<br/>[model.py]"]
end

node_user(("Note author"))

node_user -->|"submits text"| node_app
node_app -->|"creates note"| node_api
node_api -->|"POST note"| node_notes_api
node_notes_api -->|"requests prediction"| node_fastapi
node_fastapi -->|"classifies text"| node_classifier
node_classifier -->|"returns sentiment"| node_fastapi
node_fastapi -->|"returns prediction"| node_notes_api
node_notes_api -->|"returns note result"| node_api
node_api -->|"returns data"| node_app
node_api -.->|"optional direct POST"| node_fastapi

click node_app "https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/api.js"
click node_fastapi "https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/main.py"
click node_classifier "https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/model.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_app,node_api toneBlue
class node_notes_api toneAmber
class node_fastapi,node_classifier toneMint
class node_user toneIndigo
```

## Components

### Web client

- [Analyzer UI](https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Request client](https://github.com/ydv-prince/sentiment-analysis/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Notes API

- **Notes API**

### Sentiment service

- [Prediction endpoint](https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/main.py): `ml-service/main.py`
- [Keyword classifier](https://github.com/ydv-prince/sentiment-analysis/blob/main/ml-service/model.py): `ml-service/model.py`

### Other components

- **Note author**

## Connections

- Note author → Analyzer UI: submits text
- Analyzer UI → Request client: creates note
- Request client → Notes API: POST note
- Notes API → Prediction endpoint: requests prediction
- Prediction endpoint → Keyword classifier: classifies text
- Keyword classifier → Prediction endpoint: returns sentiment
- Prediction endpoint → Notes API: returns prediction
- Notes API → Request client: returns note result
- Request client → Analyzer UI: returns data
- Request client → Prediction endpoint: optional direct POST
