# prateeks-py/emotion-detection architecture

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

- Interactive diagram: https://gitdiagram.com/prateeks-py/emotion-detection
- Repository: https://github.com/prateeks-py/emotion-detection

## Overview

This repository is a reproducible emotion-dataset bundle with an adjacent baseline classifier and interactive local coaching script. The main workflow builds synthetic records (optionally mixed with public multilingual records), writes CSV/SQLite outputs and a manifest, then can train a classifier for use by the coach. The README documents dataset provenance, mixed-mode generation, and validation. The graph also includes the coach because it is a runnable product capability in the tree; its local Ollama dependency is shown separately. Edges reflect the builder, trainer, and coach excerpts, plus README-documented workflows.

Main entry points: [`build_dataset.py`](https://github.com/prateeks-py/emotion-detection/blob/main/build_dataset.py) (Dataset builder), [`emotional_coach.py`](https://github.com/prateeks-py/emotion-detection/blob/main/emotional_coach.py) (Conditional-trajectory coach), [`train_emotion_model.py`](https://github.com/prateeks-py/emotion-detection/blob/main/train_emotion_model.py) (Classifier training), [`emotion_model.joblib`](https://github.com/prateeks-py/emotion-detection/blob/main/emotion_model.joblib) (Trained classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dataset["Dataset generation"]
  node_builder["Dataset builder<br/>[build_dataset.py]"]
end

subgraph group_model["Emotion modeling"]
  node_trainer["Classifier training"]
  node_model_file["Trained classifier"]
  node_report["Evaluation report"]
end

subgraph group_coach["Interactive coaching"]
  node_coach["Conditional-trajectory coach<br/>[emotional_coach.py]"]
end

subgraph group_artifacts["Dataset artifacts"]
  node_schema["SQLite schema<br/>[schema.sql]"]
  node_csv["Emotion CSV"]
  node_sqlite[("Emotion database")]
  node_manifest["Provenance manifest<br/>[manifest.json]"]
end

node_maintainer(("Dataset maintainer"))
node_hf[("Hugging Face dataset")]
node_user(("Chat user"))
node_ollama["Local Ollama service"]

node_maintainer -->|"runs build"| node_builder
node_builder -->|"writes rows"| node_csv
node_builder -->|"reads schema"| node_schema
node_builder -->|"writes records"| node_sqlite
node_builder -->|"writes provenance"| node_manifest
node_builder -.->|"loads public rows"| node_hf
node_trainer -->|"reads records"| node_csv
node_trainer -->|"saves classifier"| node_model_file
node_trainer -->|"writes metrics"| node_report
node_user -->|"enters messages"| node_coach
node_coach -->|"loads and predicts"| node_model_file
node_coach -->|"queries examples"| node_sqlite
node_coach -->|"sends prompt"| node_ollama

click node_builder "https://github.com/prateeks-py/emotion-detection/blob/main/build_dataset.py"
click node_schema "https://github.com/prateeks-py/emotion-detection/blob/main/schema.sql"
click node_csv "https://github.com/prateeks-py/emotion-detection/blob/main/emotion_dataset.csv"
click node_sqlite "https://github.com/prateeks-py/emotion-detection/blob/main/emotion_dataset.sqlite"
click node_manifest "https://github.com/prateeks-py/emotion-detection/blob/main/manifest.json"
click node_trainer "https://github.com/prateeks-py/emotion-detection/blob/main/train_emotion_model.py"
click node_model_file "https://github.com/prateeks-py/emotion-detection/blob/main/emotion_model.joblib"
click node_report "https://github.com/prateeks-py/emotion-detection/blob/main/evaluation_report.txt"
click node_coach "https://github.com/prateeks-py/emotion-detection/blob/main/emotional_coach.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_builder,node_user toneBlue
class node_trainer,node_model_file,node_report,node_hf toneAmber
class node_coach toneMint
class node_schema,node_csv,node_sqlite,node_manifest toneRose
class node_maintainer,node_ollama toneIndigo
```

## Components

### Dataset generation

- [Dataset builder](https://github.com/prateeks-py/emotion-detection/blob/main/build_dataset.py): `build_dataset.py`

### Emotion modeling

- [Classifier training](https://github.com/prateeks-py/emotion-detection/blob/main/train_emotion_model.py): `train_emotion_model.py`
- [Trained classifier](https://github.com/prateeks-py/emotion-detection/blob/main/emotion_model.joblib): `emotion_model.joblib`
- [Evaluation report](https://github.com/prateeks-py/emotion-detection/blob/main/evaluation_report.txt): `evaluation_report.txt`

### Interactive coaching

- [Conditional-trajectory coach](https://github.com/prateeks-py/emotion-detection/blob/main/emotional_coach.py): `emotional_coach.py`

### Dataset artifacts

- [SQLite schema](https://github.com/prateeks-py/emotion-detection/blob/main/schema.sql): `schema.sql`
- [Emotion CSV](https://github.com/prateeks-py/emotion-detection/blob/main/emotion_dataset.csv): `emotion_dataset.csv`
- [Emotion database](https://github.com/prateeks-py/emotion-detection/blob/main/emotion_dataset.sqlite): `emotion_dataset.sqlite`
- [Provenance manifest](https://github.com/prateeks-py/emotion-detection/blob/main/manifest.json): `manifest.json`

### Other components

- **Dataset maintainer**
- **Hugging Face dataset**
- **Chat user**
- **Local Ollama service**

## Connections

- Dataset maintainer → Dataset builder: runs build (evidence: `README.md`)
- Dataset builder → Emotion CSV: writes rows (evidence: `build_dataset.py`)
- Dataset builder → SQLite schema: reads schema (evidence: `build_dataset.py`)
- Dataset builder → Emotion database: writes records (evidence: `build_dataset.py`)
- Dataset builder → Provenance manifest: writes provenance (evidence: `build_dataset.py`)
- Dataset builder → Hugging Face dataset: loads public rows (evidence: `build_dataset.py`)
- Classifier training → Emotion CSV: reads records (evidence: `train_emotion_model.py`)
- Classifier training → Trained classifier: saves classifier (evidence: `train_emotion_model.py`)
- Classifier training → Evaluation report: writes metrics (evidence: `train_emotion_model.py`)
- Chat user → Conditional-trajectory coach: enters messages (evidence: `emotional_coach.py`)
- Conditional-trajectory coach → Trained classifier: loads and predicts (evidence: `emotional_coach.py`)
- Conditional-trajectory coach → Emotion database: queries examples (evidence: `emotional_coach.py`)
- Conditional-trajectory coach → Local Ollama service: sends prompt (evidence: `emotional_coach.py`)
