# gizemexe/emotions architecture

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

- Interactive diagram: https://gitdiagram.com/gizemexe/emotions
- Repository: https://github.com/gizemexe/emotions

## Overview

Moodify captures webcam frames, detects facial emotion, and uses the latest detected category to fetch Spotify playlist tracks for display in the web interface. A separate training workflow builds the CNN weights used at runtime. The excerpts show the Flask-to-camera and Flask-to-Spotify calls; the README documents the interface behavior. The template itself was not sampled, so its detailed request wiring is not shown.

Main entry points: [`app.py`](https://github.com/gizemexe/emotions/blob/main/app.py) (Flask routes), [`Spotipy.py`](https://github.com/gizemexe/emotions/blob/main/Spotipy.py) (Recommendation lookup), [`templates/index.html`](https://github.com/gizemexe/emotions/blob/main/templates/index.html) (Web interface), [`camera.py`](https://github.com/gizemexe/emotions/blob/main/camera.py) (Face detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webui["Web interface<br/>[index.html]"]
  node_flask["Flask routes<br/>[app.py]"]
  node_stream["Video feed<br/>[app.py]"]
end

subgraph group_vision["Emotion recognition"]
  node_camera["Frame capture<br/>[camera.py]"]
  node_face["Face detection<br/>[camera.py]"]
  node_emotion["Emotion prediction<br/>[camera.py]"]
  node_cascade["Face cascade"]
  node_weights["CNN weights<br/>[model.h5]"]
end

subgraph group_music["Music recommendations"]
  node_spotify["Spotify API"]
  node_recommend["Recommendation lookup<br/>[Spotipy.py]"]
  node_playlist["Playlist tracks<br/>[Spotipy.py]"]
  node_track["Track details<br/>[Spotipy.py]"]
end

subgraph group_training["Model training"]
  node_training["CNN training<br/>[train.py]"]
  node_dataset["Training and validation data"]
  node_trained["Saved weights<br/>[model.h5]"]
end

node_user(("User"))
node_webcam(("Webcam"))

node_user -->|"uses"| node_webui
node_webui -->|"requests"| node_flask
node_flask -->|"serves"| node_stream
node_stream -->|"gets frames"| node_camera
node_webcam -->|"supplies frames"| node_camera
node_camera -->|"processes frames"| node_face
node_face -->|"loads"| node_cascade
node_face -->|"crops faces"| node_emotion
node_emotion -->|"loads"| node_weights
node_webui -->|"requests songs"| node_flask
node_flask -->|"reads latest category"| node_emotion
node_flask -->|"requests tracks"| node_recommend
node_recommend -->|"searches playlists"| node_spotify
node_recommend -->|"collects tracks"| node_playlist
node_playlist -->|"fetches playlist items"| node_spotify
node_recommend -->|"gets track details"| node_track
node_track -->|"fetches metadata"| node_spotify
node_training -->|"reads"| node_dataset
node_training -->|"saves weights"| node_trained

click node_webui "https://github.com/gizemexe/emotions/blob/main/templates/index.html"
click node_flask "https://github.com/gizemexe/emotions/blob/main/app.py"
click node_stream "https://github.com/gizemexe/emotions/blob/main/app.py"
click node_camera "https://github.com/gizemexe/emotions/blob/main/camera.py"
click node_face "https://github.com/gizemexe/emotions/blob/main/camera.py"
click node_emotion "https://github.com/gizemexe/emotions/blob/main/camera.py"
click node_cascade "https://github.com/gizemexe/emotions/blob/main/haarcascade_frontalface_default.xml"
click node_weights "https://github.com/gizemexe/emotions/blob/main/model.h5"
click node_recommend "https://github.com/gizemexe/emotions/blob/main/Spotipy.py"
click node_playlist "https://github.com/gizemexe/emotions/blob/main/Spotipy.py"
click node_track "https://github.com/gizemexe/emotions/blob/main/Spotipy.py"
click node_training "https://github.com/gizemexe/emotions/blob/main/train.py"
click node_dataset "https://github.com/gizemexe/emotions/tree/main/data"
click node_trained "https://github.com/gizemexe/emotions/blob/main/model.h5"

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_webui,node_flask,node_stream,node_user toneBlue
class node_camera,node_face,node_emotion,node_cascade,node_weights toneAmber
class node_spotify,node_recommend,node_playlist,node_track toneMint
class node_training,node_dataset,node_trained toneRose
class node_webcam toneIndigo
```

## Components

### Web application

- [Web interface](https://github.com/gizemexe/emotions/blob/main/templates/index.html): `templates/index.html`
- [Flask routes](https://github.com/gizemexe/emotions/blob/main/app.py): `app.py`
- [Video feed](https://github.com/gizemexe/emotions/blob/main/app.py): `app.py`

### Emotion recognition

- [Frame capture](https://github.com/gizemexe/emotions/blob/main/camera.py): `camera.py`
- [Face detection](https://github.com/gizemexe/emotions/blob/main/camera.py): `camera.py`
- [Emotion prediction](https://github.com/gizemexe/emotions/blob/main/camera.py): `camera.py`
- [Face cascade](https://github.com/gizemexe/emotions/blob/main/haarcascade_frontalface_default.xml): `haarcascade_frontalface_default.xml`
- [CNN weights](https://github.com/gizemexe/emotions/blob/main/model.h5): `model.h5`

### Music recommendations

- **Spotify API**
- [Recommendation lookup](https://github.com/gizemexe/emotions/blob/main/Spotipy.py): `Spotipy.py`
- [Playlist tracks](https://github.com/gizemexe/emotions/blob/main/Spotipy.py): `Spotipy.py`
- [Track details](https://github.com/gizemexe/emotions/blob/main/Spotipy.py): `Spotipy.py`

### Model training

- [CNN training](https://github.com/gizemexe/emotions/blob/main/train.py): `train.py`
- [Training and validation data](https://github.com/gizemexe/emotions/tree/main/data): `data`
- [Saved weights](https://github.com/gizemexe/emotions/blob/main/model.h5): `model.h5`

### Other components

- **User**
- **Webcam**

## Connections

- User → Web interface: uses (evidence: `README.md`)
- Web interface → Flask routes: requests (evidence: `README.md`)
- Flask routes → Video feed: serves (evidence: `app.py`)
- Video feed → Frame capture: gets frames (evidence: `app.py`)
- Webcam → Frame capture: supplies frames (evidence: `camera.py`)
- Frame capture → Face detection: processes frames (evidence: `camera.py`)
- Face detection → Face cascade: loads (evidence: `camera.py`)
- Face detection → Emotion prediction: crops faces (evidence: `camera.py`)
- Emotion prediction → CNN weights: loads (evidence: `camera.py`)
- Web interface → Flask routes: requests songs (evidence: `README.md`)
- Flask routes → Emotion prediction: reads latest category (evidence: `app.py`)
- Flask routes → Recommendation lookup: requests tracks (evidence: `app.py`)
- Recommendation lookup → Spotify API: searches playlists (evidence: `Spotipy.py`)
- Recommendation lookup → Playlist tracks: collects tracks (evidence: `Spotipy.py`)
- Playlist tracks → Spotify API: fetches playlist items (evidence: `Spotipy.py`)
- Recommendation lookup → Track details: gets track details (evidence: `Spotipy.py`)
- Track details → Spotify API: fetches metadata (evidence: `Spotipy.py`)
- CNN training → Training and validation data: reads (evidence: `train.py`)
- CNN training → Saved weights: saves weights (evidence: `train.py`)
