# danielmartinezsebastian/youtube-audio-downloader-api architecture

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

- Interactive diagram: https://gitdiagram.com/danielmartinezsebastian/youtube-audio-downloader-api
- Repository: https://github.com/danielmartinezsebastian/youtube-audio-downloader-api

## Overview

This is an Express API that accepts a YouTube URL, obtains audio, converts it to MP3, and returns a download URL; a separate endpoint serves the cached file. The graph follows both request paths through the app, routes, controllers, and service implementations. The cache and external media/conversion dependencies are shown where the sampled service code uses them; no persistent database is evident.

Main entry points: [`services/audioConverter.js`](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/audioConverter.js) (Audio converter), [`api/app.js`](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/app.js) (Express app), [`services/fileDownloader.js`](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/fileDownloader.js) (File downloader), [`api/routes/audioRoutes.js`](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/routes/audioRoutes.js) (Audio routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Server startup<br/>[index.js]"]
  node_app["Express app<br/>[app.js]"]
  node_audio_routes["Audio routes<br/>[audioRoutes.js]"]
  node_audio_controller["Audio controller<br/>[audioController.js]"]
  node_file_routes["File routes<br/>[fileRoutes.js]"]
  node_file_controller["File controller<br/>[fileController.js]"]
end

subgraph group_convert["Audio conversion"]
  node_converter["Audio converter<br/>[audioConverter.js]"]
  node_youtube["YouTube metadata"]
  node_audio_source["Audio source"]
  node_ffmpeg["FFmpeg"]
end

subgraph group_download["File delivery"]
  node_cache[("Cached files<br/>[fileDownloader.js]")]
  node_downloader["File downloader<br/>[fileDownloader.js]"]
end

node_client(("API client"))

node_client -->|"POST /audio/convert"| node_app
node_client -->|"GET /download"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts /audio"| node_audio_routes
node_app -->|"mounts /download"| node_file_routes
node_audio_routes -->|"routes to"| node_audio_controller
node_audio_controller -->|"invokes"| node_converter
node_file_routes -->|"routes to"| node_file_controller
node_file_controller -->|"invokes"| node_downloader
node_converter -->|"queries metadata"| node_youtube
node_converter -->|"downloads audio"| node_audio_source
node_converter -->|"writes files"| node_cache
node_converter -->|"executes conversion"| node_ffmpeg
node_downloader -->|"reads file"| node_cache
node_downloader -->|"sends file"| node_client

click node_server "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/index.js"
click node_app "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/app.js"
click node_audio_routes "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/routes/audioRoutes.js"
click node_audio_controller "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/controllers/audioController.js"
click node_file_routes "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/routes/fileRoutes.js"
click node_file_controller "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/controllers/fileController.js"
click node_converter "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/audioConverter.js"
click node_cache "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/fileDownloader.js"
click node_downloader "https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/fileDownloader.js"

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_server,node_app,node_audio_routes,node_audio_controller,node_file_routes,node_file_controller,node_client toneBlue
class node_converter,node_youtube,node_audio_source,node_ffmpeg toneAmber
class node_cache,node_downloader toneMint
```

## Components

### API routing

- [Server startup](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/index.js): `index.js`
- [Express app](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/app.js): `api/app.js`
- [Audio routes](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/routes/audioRoutes.js): `api/routes/audioRoutes.js`
- [Audio controller](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/controllers/audioController.js): `api/controllers/audioController.js`
- [File routes](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/routes/fileRoutes.js): `api/routes/fileRoutes.js`
- [File controller](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/api/controllers/fileController.js): `api/controllers/fileController.js`

### Audio conversion

- [Audio converter](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/audioConverter.js): `services/audioConverter.js`
- **YouTube metadata**
- **Audio source**
- **FFmpeg**

### File delivery

- [Cached files](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/fileDownloader.js): `services/fileDownloader.js`
- [File downloader](https://github.com/danielmartinezsebastian/youtube-audio-downloader-api/blob/main/services/fileDownloader.js): `services/fileDownloader.js`

### Other components

- **API client**

## Connections

- API client → Express app: POST /audio/convert (evidence: `README.md`)
- API client → Express app: GET /download (evidence: `README.md`)
- Server startup → Express app: starts (evidence: `index.js`)
- Express app → Audio routes: mounts /audio (evidence: `api/app.js`)
- Express app → File routes: mounts /download (evidence: `api/app.js`)
- Audio routes → Audio controller: routes to (evidence: `api/routes/audioRoutes.js`)
- Audio controller → Audio converter: invokes (evidence: `api/controllers/audioController.js`)
- File routes → File controller: routes to (evidence: `api/routes/fileRoutes.js`)
- File controller → File downloader: invokes (evidence: `api/controllers/fileController.js`)
- Audio converter → YouTube metadata: queries metadata (evidence: `services/audioConverter.js`)
- Audio converter → Audio source: downloads audio (evidence: `services/audioConverter.js`)
- Audio converter → Cached files: writes files (evidence: `services/audioConverter.js`)
- Audio converter → FFmpeg: executes conversion (evidence: `services/audioConverter.js`)
- File downloader → Cached files: reads file (evidence: `services/fileDownloader.js`)
- File downloader → API client: sends file (evidence: `services/fileDownloader.js`)
