# derstgamd/infinity_bd architecture

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

- Interactive diagram: https://gitdiagram.com/derstgamd/infinity_bd
- Repository: https://github.com/derstgamd/infinity_bd

## Overview

A small Flask service accepts a video URL, uses yt-dlp to resolve its audio stream, and runs FFmpeg to transcode that stream into MP3 chunks for the requester. The separate ping endpoint reports whether FFmpeg and the optional cookie file exist. Runtime behavior is concentrated in app.py; the repository does not include the FFmpeg binary or cookie file, so these are shown as external resources.

Main entry points: [`app.py`](https://github.com/derstgamd/infinity_bd/blob/main/app.py) (Flask routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP service"]
  node_flask["Flask routes<br/>[app.py]"]
  node_ping["Health check<br/>[app.py]"]
end

subgraph group_streaming["Audio streaming"]
  node_stream_handler["Stream handler<br/>[app.py]"]
  node_resolver["URL resolver<br/>[app.py]"]
  node_ytdlp["yt-dlp"]
  node_ffmpeg["FFmpeg"]
  node_audio_response["MP3 response<br/>[app.py]"]
end

node_user(("HTTP client"))
node_youtube["Video source"]
node_cookies["Cookie file"]
node_ffmpeg_status["FFmpeg binary"]

node_user -->|"sends request"| node_flask
node_flask -->|"dispatches"| node_ping
node_flask -->|"dispatches"| node_stream_handler
node_ping -->|"checks existence"| node_ffmpeg_status
node_ping -->|"checks existence"| node_cookies
node_stream_handler -->|"resolves URL"| node_resolver
node_resolver -->|"extracts info"| node_ytdlp
node_ytdlp -->|"retrieves metadata"| node_youtube
node_ytdlp -.->|"uses if present"| node_cookies
node_ytdlp -->|"returns stream URL"| node_resolver
node_stream_handler -->|"starts transcoding"| node_ffmpeg
node_ffmpeg -->|"runs binary"| node_ffmpeg_status
node_ffmpeg -->|"writes MP3 chunks"| node_audio_response
node_audio_response -->|"streams response"| node_user

click node_flask "https://github.com/derstgamd/infinity_bd/blob/main/app.py"
click node_ping "https://github.com/derstgamd/infinity_bd/blob/main/app.py"
click node_stream_handler "https://github.com/derstgamd/infinity_bd/blob/main/app.py"
click node_resolver "https://github.com/derstgamd/infinity_bd/blob/main/app.py"
click node_audio_response "https://github.com/derstgamd/infinity_bd/blob/main/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_flask,node_ping,node_user toneBlue
class node_stream_handler,node_resolver,node_ytdlp,node_ffmpeg,node_audio_response toneAmber
class node_youtube,node_cookies,node_ffmpeg_status toneIndigo
```

## Components

### HTTP service

- [Flask routes](https://github.com/derstgamd/infinity_bd/blob/main/app.py): `app.py`
- [Health check](https://github.com/derstgamd/infinity_bd/blob/main/app.py): `app.py`

### Audio streaming

- [Stream handler](https://github.com/derstgamd/infinity_bd/blob/main/app.py): `app.py`
- [URL resolver](https://github.com/derstgamd/infinity_bd/blob/main/app.py): `app.py`
- **yt-dlp**
- **FFmpeg**
- [MP3 response](https://github.com/derstgamd/infinity_bd/blob/main/app.py): `app.py`

### Other components

- **HTTP client**
- **Video source**
- **Cookie file**
- **FFmpeg binary**

## Connections

- HTTP client → Flask routes: sends request
- Flask routes → Health check: dispatches
- Flask routes → Stream handler: dispatches
- Health check → FFmpeg binary: checks existence
- Health check → Cookie file: checks existence
- Stream handler → URL resolver: resolves URL
- URL resolver → yt-dlp: extracts info
- yt-dlp → Video source: retrieves metadata
- yt-dlp → Cookie file: uses if present
- yt-dlp → URL resolver: returns stream URL
- Stream handler → FFmpeg: starts transcoding
- FFmpeg → FFmpeg binary: runs binary
- FFmpeg → MP3 response: writes MP3 chunks
- MP3 response → HTTP client: streams response
