# avibadola510/emotion-sense architecture

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

- Interactive diagram: https://gitdiagram.com/avibadola510/emotion-sense
- Repository: https://github.com/avibadola510/emotion-sense

## Overview

Emotion-Sense is a web app that predicts one of six emotions from text. The user enters text in the browser UI, which submits it to the FastAPI prediction endpoint; the server cleans and tokenizes the text, pads the sequence, runs the loaded BiGRU model, and returns a label and probabilities for display. The tree and excerpts support the API, model assets, and browser result rendering. Training or other notebook capabilities are not described in the supplied README, so their behavior is not mapped.

Main entry points: [`main.py`](https://github.com/avibadola510/emotion-sense/blob/main/main.py) (Prediction endpoint), [`static/index.html`](https://github.com/avibadola510/emotion-sense/blob/main/static/index.html) (Emotion UI), [`static/script.js`](https://github.com/avibadola510/emotion-sense/blob/main/static/script.js) (UI interactions), [`Artifacts/BiGRU_Model.keras`](https://github.com/avibadola510/emotion-sense/blob/main/Artifacts/BiGRU_Model.keras) (Emotion classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_ui["Emotion UI<br/>[index.html]"]
  node_browser["UI interactions<br/>[script.js]"]
end

subgraph group_api["Prediction API"]
  node_endpoint["Prediction endpoint<br/>[main.py]"]
  node_results["Prediction results<br/>[main.py]"]
  node_health["Health check<br/>[main.py]"]
  node_static["Static file service<br/>[main.py]"]
end

subgraph group_inference["Inference runtime"]
  node_preprocess["Text preprocessing<br/>[main.py]"]
  node_encode["Sequence encoding<br/>[main.py]"]
  node_classifier["Emotion classifier<br/>[BiGRU_Model.keras]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.pkl]"]
end

subgraph group_assets["Model assets"]
end

node_user(("User"))

node_user -->|"uses"| node_ui
node_ui -->|"loads interactions"| node_browser
node_browser -->|"POSTs text"| node_endpoint
node_endpoint -->|"cleans text"| node_preprocess
node_endpoint -->|"encodes sequence"| node_encode
node_endpoint -->|"predicts with"| node_classifier
node_endpoint -->|"loads tokenizer"| node_tokenizer
node_endpoint -->|"returns probabilities"| node_results
node_browser -->|"renders response"| node_results
node_endpoint -->|"exposes"| node_health
node_ui -->|"served by"| node_static

click node_ui "https://github.com/avibadola510/emotion-sense/blob/main/static/index.html"
click node_browser "https://github.com/avibadola510/emotion-sense/blob/main/static/script.js"
click node_endpoint "https://github.com/avibadola510/emotion-sense/blob/main/main.py"
click node_preprocess "https://github.com/avibadola510/emotion-sense/blob/main/main.py"
click node_encode "https://github.com/avibadola510/emotion-sense/blob/main/main.py"
click node_classifier "https://github.com/avibadola510/emotion-sense/blob/main/Artifacts/BiGRU_Model.keras"
click node_tokenizer "https://github.com/avibadola510/emotion-sense/blob/main/Artifacts/tokenizer.pkl"
click node_results "https://github.com/avibadola510/emotion-sense/blob/main/main.py"
click node_health "https://github.com/avibadola510/emotion-sense/blob/main/main.py"
click node_static "https://github.com/avibadola510/emotion-sense/blob/main/main.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_ui,node_browser,node_user toneBlue
class node_endpoint,node_results,node_health,node_static toneAmber
class node_preprocess,node_encode,node_classifier,node_tokenizer toneMint
```

## Components

### Web interface

- [Emotion UI](https://github.com/avibadola510/emotion-sense/blob/main/static/index.html): `static/index.html`
- [UI interactions](https://github.com/avibadola510/emotion-sense/blob/main/static/script.js): `static/script.js`

### Prediction API

- [Prediction endpoint](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`
- [Prediction results](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`
- [Health check](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`
- [Static file service](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`

### Inference runtime

- [Text preprocessing](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`
- [Sequence encoding](https://github.com/avibadola510/emotion-sense/blob/main/main.py): `main.py`
- [Emotion classifier](https://github.com/avibadola510/emotion-sense/blob/main/Artifacts/BiGRU_Model.keras): `Artifacts/BiGRU_Model.keras`
- [Tokenizer](https://github.com/avibadola510/emotion-sense/blob/main/Artifacts/tokenizer.pkl): `Artifacts/tokenizer.pkl`

### Other components

- **User**

## Connections

- User → Emotion UI: uses
- Emotion UI → UI interactions: loads interactions (evidence: `static/script.js`)
- UI interactions → Prediction endpoint: POSTs text (evidence: `static/script.js`)
- Prediction endpoint → Text preprocessing: cleans text (evidence: `main.py`)
- Prediction endpoint → Sequence encoding: encodes sequence (evidence: `main.py`)
- Prediction endpoint → Emotion classifier: predicts with (evidence: `main.py`)
- Prediction endpoint → Tokenizer: loads tokenizer (evidence: `main.py`)
- Prediction endpoint → Prediction results: returns probabilities (evidence: `main.py`)
- UI interactions → Prediction results: renders response (evidence: `static/script.js`)
- Prediction endpoint → Health check: exposes (evidence: `main.py`)
- Emotion UI → Static file service: served by (evidence: `main.py`)
