# skypan322/emotion-recognition architecture

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

- Interactive diagram: https://gitdiagram.com/skypan322/emotion-recognition
- Repository: https://github.com/skypan322/emotion-recognition

## Overview

Emotion-recognition is a Telegram bot that recommends films by genre or by interpreting a user’s facial expression. Users send a genre or photo; the bot validates genres, or analyzes a photo, maps emotions to a genre, fetches a film recommendation, and replies. The sampled bot also documents help/start commands and saves uploaded photos and emotion results. The README is only a title, so the architecture is based on the sampled source; unshown relationships are omitted.

Main entry points: [`telegram_bot.py`](https://github.com/skypan322/emotion-recognition/blob/main/telegram_bot.py) (Bot handlers), [`Parser_v2.py`](https://github.com/skypan322/emotion-recognition/blob/main/Parser_v2.py) (Film lookup), [`genre_id.json`](https://github.com/skypan322/emotion-recognition/blob/main/genre_id.json) (Genre catalog), [`auth.py`](https://github.com/skypan322/emotion-recognition/blob/main/auth.py) (API credentials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Telegram interaction"]
  node_bot["Bot handlers<br/>[telegram_bot.py]"]
  node_photo["Uploaded photos"]
end

subgraph group_emotion["Emotion analysis"]
  node_emotion_model["FER detector"]
  node_emotion_results["Emotion results<br/>[emotions.json]"]
end

subgraph group_recommendation["Film recommendations"]
  node_genre_catalog["Genre catalog<br/>[genre_id.json]"]
  node_film_lookup["Film lookup<br/>[Parser_v2.py]"]
  node_credentials["API credentials<br/>[auth.py]"]
end

node_user(("Telegram user"))
node_film_api["Kinopoisk API"]

node_user -->|"sends messages"| node_bot
node_bot -->|"sends replies"| node_user
node_bot -->|"saves uploads"| node_photo
node_bot -->|"detects emotions"| node_emotion_model
node_bot -->|"appends results"| node_emotion_results
node_bot -->|"loads genres"| node_genre_catalog
node_bot -->|"requests films"| node_film_lookup
node_film_lookup -->|"reads IDs"| node_genre_catalog
node_film_lookup -->|"imports key"| node_credentials
node_bot -->|"imports token"| node_credentials
node_film_lookup -->|"requests films"| node_film_api

click node_bot "https://github.com/skypan322/emotion-recognition/blob/main/telegram_bot.py"
click node_photo "https://github.com/skypan322/emotion-recognition/tree/main/images"
click node_emotion_results "https://github.com/skypan322/emotion-recognition/blob/main/emotions.json"
click node_genre_catalog "https://github.com/skypan322/emotion-recognition/blob/main/genre_id.json"
click node_film_lookup "https://github.com/skypan322/emotion-recognition/blob/main/Parser_v2.py"
click node_credentials "https://github.com/skypan322/emotion-recognition/blob/main/auth.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_bot,node_photo,node_user toneBlue
class node_emotion_model,node_emotion_results toneAmber
class node_genre_catalog,node_film_lookup,node_credentials,node_film_api toneMint
```

## Components

### Telegram interaction

- [Bot handlers](https://github.com/skypan322/emotion-recognition/blob/main/telegram_bot.py): `telegram_bot.py`
- [Uploaded photos](https://github.com/skypan322/emotion-recognition/tree/main/images): `images`

### Emotion analysis

- **FER detector**
- [Emotion results](https://github.com/skypan322/emotion-recognition/blob/main/emotions.json): `emotions.json`

### Film recommendations

- [Genre catalog](https://github.com/skypan322/emotion-recognition/blob/main/genre_id.json): `genre_id.json`
- [Film lookup](https://github.com/skypan322/emotion-recognition/blob/main/Parser_v2.py): `Parser_v2.py`
- [API credentials](https://github.com/skypan322/emotion-recognition/blob/main/auth.py): `auth.py`

### Other components

- **Telegram user**
- **Kinopoisk API**

## Connections

- Telegram user → Bot handlers: sends messages (evidence: `telegram_bot.py`)
- Bot handlers → Telegram user: sends replies (evidence: `telegram_bot.py`)
- Bot handlers → Uploaded photos: saves uploads (evidence: `telegram_bot.py`)
- Bot handlers → FER detector: detects emotions (evidence: `telegram_bot.py`)
- Bot handlers → Emotion results: appends results (evidence: `telegram_bot.py`)
- Bot handlers → Genre catalog: loads genres
- Bot handlers → Film lookup: requests films (evidence: `telegram_bot.py`)
- Film lookup → Genre catalog: reads IDs (evidence: `Parser_v2.py`)
- Film lookup → API credentials: imports key (evidence: `Parser_v2.py`)
- Bot handlers → API credentials: imports token (evidence: `telegram_bot.py`)
- Film lookup → Kinopoisk API: requests films (evidence: `Parser_v2.py`)
