# tejmanthena/mood-based-music-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/tejmanthena/mood-based-music-recommendation-system
- Repository: https://github.com/tejmanthena/mood-based-music-recommendation-system

## Overview

This is a Streamlit emotion-based music recommender. The user triggers webcam scanning; OpenCV detects faces, a CNN classifies expressions, and the app aggregates detected emotions to sample matching tracks from the CSV and render linked recommendations. The graph captures the main runtime stages and the model/data assets. Evidence is limited to the README and the excerpted app.py; external services are not shown as runtime dependencies.

Main entry points: [`app.py`](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py) (Streamlit UI), [`model.h5`](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/model.h5) (CNN weights), [`haarcascade_frontalface_default.xml`](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/haarcascade_frontalface_default.xml) (Haar cascade), [`muse_v3.csv`](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/muse_v3.csv) (Track catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Emotion capture"]
  node_camera["Webcam"]
  node_face["Face detection<br/>[app.py]"]
  node_classifier["Emotion CNN<br/>[app.py]"]
  node_weights["CNN weights<br/>[model.h5]"]
  node_emotion["Emotion aggregation<br/>[app.py]"]
  node_cascade["Haar cascade"]
end

subgraph group_recommend["Music recommendation"]
  node_catalog["Track catalog<br/>[muse_v3.csv]"]
  node_sampling["Emotion sampling<br/>[app.py]"]
  node_recommendations["Song recommendations<br/>[app.py]"]
end

subgraph group_interface["Streamlit interface"]
  node_app["App workflow<br/>[app.py]"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
end

node_user(("User"))

node_user -->|"starts scan"| node_streamlit
node_streamlit -->|"reads frames"| node_camera
node_streamlit -->|"detects faces"| node_face
node_face -->|"loads classifier"| node_cascade
node_face -->|"passes face crop"| node_classifier
node_classifier -->|"loads weights"| node_weights
node_classifier -->|"returns predictions"| node_emotion
node_streamlit -->|"aggregates detections"| node_emotion
node_streamlit -->|"requests tracks"| node_sampling
node_sampling -->|"samples tracks"| node_catalog
node_sampling -->|"returns tracks"| node_recommendations
node_streamlit -->|"renders links"| node_recommendations

click node_app "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_face "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_classifier "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_weights "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/model.h5"
click node_emotion "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_catalog "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/muse_v3.csv"
click node_sampling "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_recommendations "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py"
click node_cascade "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/haarcascade_frontalface_default.xml"
click node_streamlit "https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.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_camera,node_face,node_classifier,node_weights,node_emotion,node_cascade,node_user toneBlue
class node_catalog,node_sampling,node_recommendations toneAmber
class node_app,node_streamlit toneMint
```

## Components

### Emotion capture

- **Webcam**
- [Face detection](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`
- [Emotion CNN](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`
- [CNN weights](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/model.h5): `model.h5`
- [Emotion aggregation](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`
- [Haar cascade](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/haarcascade_frontalface_default.xml): `haarcascade_frontalface_default.xml`

### Music recommendation

- [Track catalog](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/muse_v3.csv): `muse_v3.csv`
- [Emotion sampling](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`
- [Song recommendations](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`

### Streamlit interface

- [App workflow](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`
- [Streamlit UI](https://github.com/tejmanthena/mood-based-music-recommendation-system/blob/master/app.py): `app.py`

### Other components

- **User**

## Connections

- User → Streamlit UI: starts scan (evidence: `app.py`)
- Streamlit UI → Webcam: reads frames (evidence: `app.py`)
- Streamlit UI → Face detection: detects faces (evidence: `app.py`)
- Face detection → Haar cascade: loads classifier (evidence: `app.py`)
- Face detection → Emotion CNN: passes face crop (evidence: `app.py`)
- Emotion CNN → CNN weights: loads weights (evidence: `app.py`)
- Emotion CNN → Emotion aggregation: returns predictions (evidence: `app.py`)
- Streamlit UI → Emotion aggregation: aggregates detections (evidence: `app.py`)
- Streamlit UI → Emotion sampling: requests tracks (evidence: `app.py`)
- Emotion sampling → Track catalog: samples tracks (evidence: `app.py`)
- Emotion sampling → Song recommendations: returns tracks (evidence: `app.py`)
- Streamlit UI → Song recommendations: renders links (evidence: `app.py`)
