# codeinject7/musiai-backend architecture

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

- Interactive diagram: https://gitdiagram.com/codeinject7/musiai-backend
- Repository: https://github.com/codeinject7/musiai-backend

## Overview

Musiai Backend is a small Cloudflare Worker that serves song metadata to the Android app as JSON. Requests enter the Worker, which handles CORS and HTTP routing for song listing, search, ID lookup, and health checks. Song data is bundled from metadata.json; the Worker maps raw records into the app’s SongResponse format before returning them. The source excerpt shows the request handler’s calls and data reads; no separate database or runtime service is shown.

Main entry points: [`src/worker.js`](https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js) (Request handler), [`metadata.json`](https://github.com/codeinject7/musiai-backend/blob/main/metadata.json) (Song metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_handler["Request handler<br/>[worker.js]"]
  node_search["Song search<br/>[worker.js]"]
  node_mapper["Song mapper<br/>[worker.js]"]
end

subgraph group_catalog["Song Catalog"]
  node_metadata["Song metadata<br/>[metadata.json]"]
end

node_android(("Android app"))

node_android -->|"sends requests"| node_handler
node_handler -->|"reads"| node_metadata
node_handler -->|"calls"| node_search
node_handler -->|"calls"| node_mapper
node_search -->|"searches"| node_metadata
node_search -->|"calls"| node_mapper

click node_handler "https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js"
click node_search "https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js"
click node_mapper "https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js"
click node_metadata "https://github.com/codeinject7/musiai-backend/blob/main/metadata.json"

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_handler,node_search,node_mapper toneBlue
class node_metadata toneAmber
class node_android toneIndigo
```

## Components

### HTTP API

- [Request handler](https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js): `src/worker.js`
- [Song search](https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js): `src/worker.js`
- [Song mapper](https://github.com/codeinject7/musiai-backend/blob/main/src/worker.js): `src/worker.js`

### Song Catalog

- [Song metadata](https://github.com/codeinject7/musiai-backend/blob/main/metadata.json): `metadata.json`

### Other components

- **Android app**

## Connections

- Android app → Request handler: sends requests (evidence: `README.md`)
- Request handler → Song metadata: reads (evidence: `src/worker.js`)
- Request handler → Song search: calls (evidence: `src/worker.js`)
- Request handler → Song mapper: calls (evidence: `src/worker.js`)
- Song search → Song metadata: searches (evidence: `src/worker.js`)
- Song search → Song mapper: calls (evidence: `src/worker.js`)
