# yoepan/betterboombox-samp architecture

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

- Interactive diagram: https://gitdiagram.com/yoepan/betterboombox-samp
- Repository: https://github.com/yoepan/betterboombox-samp

## Overview

BetterBoombox is a SA-MP boombox filterscript backed by a Node.js audio API. Players place a boombox through a gamemode callback or command, then configure music and range; the README also documents pickup callbacks, personal playlists, a ten-minute limit, and Spotify tracks. The API validates requests, resolves Spotify tracks through YouTube search, and streams downloaded audio, sharing active streams where possible. The Pawn implementation was not excerpted, so its internal stages and its exact API request wiring are documented only at a high level.

Main entry points: [`API/index.js`](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js) (HTTP API), [`better_boombox.pwn`](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn) (Boombox Script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_samp["SA-MP Boombox"]
  node_filterscript["Boombox Script<br/>[better_boombox.pwn]"]
  node_placement["Placement &amp; Pickup<br/>[better_boombox.pwn]"]
  node_controls["Song &amp; Radius<br/>[better_boombox.pwn]"]
  node_playlists["Personal Playlists<br/>[better_boombox.pwn]"]
  node_api_config["API Address Config<br/>[better_boombox.pwn]"]
end

subgraph group_api["Audio API"]
  node_api_server["HTTP API<br/>[index.js]"]
  node_request_checks["Request Checks<br/>[index.js]"]
  node_spotify_convert["Spotify Conversion<br/>[index.js]"]
  node_stream_manager["Shared Stream Manager<br/>[index.js]"]
  node_downloader["Audio Downloader<br/>[index.js]"]
end

subgraph group_media["Media Integrations"]
  node_spotify_info["Spotify Metadata"]
  node_youtube_search["YouTube Search"]
  node_youtube_audio["YouTube Audio"]
end

node_player(("Player"))
node_gamemode["Gamemode"]

node_player -->|"uses item or command"| node_gamemode
node_gamemode -->|"calls placement"| node_placement
node_player -->|"configures nearby box"| node_controls
node_placement -->|"calls pickup callback"| node_gamemode
node_filterscript -->|"offers saved tracks"| node_playlists
node_filterscript -->|"uses configured API address"| node_api_config
node_filterscript -.->|"requests audio"| node_api_server
node_api_server -->|"checks request"| node_request_checks
node_api_server -->|"resolves Spotify track"| node_spotify_convert
node_spotify_convert -->|"fetches preview"| node_spotify_info
node_spotify_convert -->|"searches track"| node_youtube_search
node_api_server -->|"streams audio"| node_stream_manager
node_stream_manager -->|"starts download"| node_downloader
node_downloader -->|"downloads audio"| node_youtube_audio
node_youtube_search -->|"resolves playable URL"| node_youtube_audio

click node_filterscript "https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn"
click node_placement "https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn"
click node_controls "https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn"
click node_playlists "https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn"
click node_api_config "https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn"
click node_api_server "https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js"
click node_request_checks "https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js"
click node_spotify_convert "https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js"
click node_stream_manager "https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js"
click node_downloader "https://github.com/yoepan/betterboombox-samp/blob/main/API/index.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_filterscript,node_placement,node_controls,node_playlists,node_api_config toneBlue
class node_api_server,node_request_checks,node_spotify_convert,node_stream_manager,node_downloader toneAmber
class node_spotify_info,node_youtube_search,node_youtube_audio toneMint
class node_player,node_gamemode toneIndigo
```

## Components

### SA-MP Boombox

- [Boombox Script](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn): `better_boombox.pwn`
- [Placement & Pickup](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn): `better_boombox.pwn`
- [Song & Radius](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn): `better_boombox.pwn`
- [Personal Playlists](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn): `better_boombox.pwn`
- [API Address Config](https://github.com/yoepan/betterboombox-samp/blob/main/better_boombox.pwn): `better_boombox.pwn`

### Audio API

- [HTTP API](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js): `API/index.js`
- [Request Checks](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js): `API/index.js`
- [Spotify Conversion](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js): `API/index.js`
- [Shared Stream Manager](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js): `API/index.js`
- [Audio Downloader](https://github.com/yoepan/betterboombox-samp/blob/main/API/index.js): `API/index.js`

### Media Integrations

- **Spotify Metadata**
- **YouTube Search**
- **YouTube Audio**

### Other components

- **Player**
- **Gamemode**

## Connections

- Player → Gamemode: uses item or command (evidence: `README.md`)
- Gamemode → Placement & Pickup: calls placement (evidence: `README.md`)
- Player → Song & Radius: configures nearby box (evidence: `README.md`)
- Placement & Pickup → Gamemode: calls pickup callback (evidence: `README.md`)
- Boombox Script → Personal Playlists: offers saved tracks (evidence: `README.md`)
- Boombox Script → API Address Config: uses configured API address (evidence: `README.md`)
- Boombox Script → HTTP API: requests audio
- HTTP API → Request Checks: checks request (evidence: `API/index.js`)
- HTTP API → Spotify Conversion: resolves Spotify track (evidence: `API/index.js`)
- Spotify Conversion → Spotify Metadata: fetches preview (evidence: `API/index.js`)
- Spotify Conversion → YouTube Search: searches track (evidence: `API/index.js`)
- HTTP API → Shared Stream Manager: streams audio (evidence: `API/index.js`)
- Shared Stream Manager → Audio Downloader: starts download (evidence: `API/index.js`)
- Audio Downloader → YouTube Audio: downloads audio (evidence: `API/index.js`)
- YouTube Search → YouTube Audio: resolves playable URL
