# abdipr/myinstants-api architecture

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

- Interactive diagram: https://gitdiagram.com/abdipr/myinstants-api
- Repository: https://github.com/abdipr/myinstants-api

## Overview

MyInstants REST API exposes sound discovery, detail, and user-profile data by scraping MyInstants pages and returning JSON. Clients call separate endpoints; list endpoints fetch pages and share sound extraction, while detail extracts richer metadata. The shared helper also handles JSON/error responses and cache/CORS headers. README documents edge caching and serverless deployment; source excerpts show response headers but not deployment configuration, so the graph focuses on runtime behavior. The local router is shown only as an optional path to endpoint dispatch.

Main entry points: [`router.php`](https://github.com/abdipr/myinstants-api/blob/main/router.php) (Local router), [`api/helper.php`](https://github.com/abdipr/myinstants-api/blob/main/api/helper.php) (JSON responses), [`api/detail.php`](https://github.com/abdipr/myinstants-api/blob/main/api/detail.php) (Sound detail), [`api/search.php`](https://github.com/abdipr/myinstants-api/blob/main/api/search.php) (Sound search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API endpoints"]
  node_router["Local router<br/>[router.php]"]
  node_index["Root endpoint<br/>[index.php]"]
  node_notfound["404 endpoint<br/>[404.php]"]
  node_search["Sound search<br/>[search.php]"]
  node_detail["Sound detail<br/>[detail.php]"]
  node_trending["Trending sounds<br/>[trending.php]"]
  node_best["Best sounds<br/>[best.php]"]
  node_recent["Recent sounds<br/>[recent.php]"]
  node_uploaded["User uploads<br/>[uploaded.php]"]
  node_favorites["User favorites<br/>[favorites.php]"]
end

subgraph group_scrape["Scraping and parsing"]
  node_helper["Scrape helpers<br/>[helper.php]"]
  node_dom["HTML parser"]
end

subgraph group_response["Response handling"]
  node_json["JSON responses<br/>[helper.php]"]
end

node_client(("API client"))
node_myinstants{{"MyInstants website"}}
node_cache{{"Edge cache"}}

node_client -->|"requests"| node_index
node_client -->|"requests"| node_search
node_client -->|"requests"| node_detail
node_client -->|"requests"| node_trending
node_client -->|"requests"| node_best
node_client -->|"requests"| node_recent
node_client -->|"requests"| node_uploaded
node_client -->|"requests"| node_favorites
node_router -.->|"dispatches"| node_index
node_router -.->|"dispatches"| node_search
node_router -.->|"dispatches"| node_detail
node_router -.->|"dispatches"| node_trending
node_router -.->|"dispatches"| node_best
node_router -.->|"dispatches"| node_recent
node_router -.->|"dispatches"| node_uploaded
node_router -.->|"dispatches"| node_favorites
node_router -.->|"dispatches"| node_notfound
node_client -->|"requests"| node_notfound
node_search -->|"fetches and parses"| node_helper
node_trending -->|"fetches and parses"| node_helper
node_best -->|"fetches and parses"| node_helper
node_recent -->|"fetches and parses"| node_helper
node_uploaded -->|"fetches and parses"| node_helper
node_favorites -->|"fetches and parses"| node_helper
node_detail -->|"fetches page"| node_helper
node_helper -->|"requests HTML"| node_myinstants
node_helper -->|"parses HTML"| node_dom
node_detail -->|"extracts metadata"| node_dom
node_search -->|"formats results"| node_json
node_detail -->|"formats results"| node_json
node_trending -->|"formats results"| node_json
node_best -->|"formats results"| node_json
node_recent -->|"formats results"| node_json
node_uploaded -->|"formats results"| node_json
node_favorites -->|"formats results"| node_json
node_notfound -->|"formats error"| node_json
node_json -->|"returns JSON"| node_client
node_json -->|"sets cache headers"| node_cache

click node_router "https://github.com/abdipr/myinstants-api/blob/main/router.php"
click node_index "https://github.com/abdipr/myinstants-api/blob/main/api/index.php"
click node_notfound "https://github.com/abdipr/myinstants-api/blob/main/api/404.php"
click node_search "https://github.com/abdipr/myinstants-api/blob/main/api/search.php"
click node_detail "https://github.com/abdipr/myinstants-api/blob/main/api/detail.php"
click node_trending "https://github.com/abdipr/myinstants-api/blob/main/api/trending.php"
click node_best "https://github.com/abdipr/myinstants-api/blob/main/api/best.php"
click node_recent "https://github.com/abdipr/myinstants-api/blob/main/api/recent.php"
click node_uploaded "https://github.com/abdipr/myinstants-api/blob/main/api/uploaded.php"
click node_favorites "https://github.com/abdipr/myinstants-api/blob/main/api/favorites.php"
click node_helper "https://github.com/abdipr/myinstants-api/blob/main/api/helper.php"
click node_dom "https://github.com/abdipr/myinstants-api/blob/main/api/simple_html_dom.php"
click node_json "https://github.com/abdipr/myinstants-api/blob/main/api/helper.php"

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_router,node_index,node_notfound,node_search,node_detail,node_trending,node_best,node_recent,node_uploaded,node_favorites,node_client toneBlue
class node_helper,node_dom,node_cache toneAmber
class node_json toneMint
class node_myinstants toneIndigo
```

## Components

### API endpoints

- [Local router](https://github.com/abdipr/myinstants-api/blob/main/router.php): `router.php`
- [Root endpoint](https://github.com/abdipr/myinstants-api/blob/main/api/index.php): `api/index.php`
- [404 endpoint](https://github.com/abdipr/myinstants-api/blob/main/api/404.php): `api/404.php`
- [Sound search](https://github.com/abdipr/myinstants-api/blob/main/api/search.php): `api/search.php`
- [Sound detail](https://github.com/abdipr/myinstants-api/blob/main/api/detail.php): `api/detail.php`
- [Trending sounds](https://github.com/abdipr/myinstants-api/blob/main/api/trending.php): `api/trending.php`
- [Best sounds](https://github.com/abdipr/myinstants-api/blob/main/api/best.php): `api/best.php`
- [Recent sounds](https://github.com/abdipr/myinstants-api/blob/main/api/recent.php): `api/recent.php`
- [User uploads](https://github.com/abdipr/myinstants-api/blob/main/api/uploaded.php): `api/uploaded.php`
- [User favorites](https://github.com/abdipr/myinstants-api/blob/main/api/favorites.php): `api/favorites.php`

### Scraping and parsing

- [Scrape helpers](https://github.com/abdipr/myinstants-api/blob/main/api/helper.php): `api/helper.php`
- [HTML parser](https://github.com/abdipr/myinstants-api/blob/main/api/simple_html_dom.php): `api/simple_html_dom.php`

### Response handling

- [JSON responses](https://github.com/abdipr/myinstants-api/blob/main/api/helper.php): `api/helper.php`

### Other components

- **API client**
- **MyInstants website**
- **Edge cache**

## Connections

- API client → Root endpoint: requests
- API client → Sound search: requests
- API client → Sound detail: requests
- API client → Trending sounds: requests
- API client → Best sounds: requests
- API client → Recent sounds: requests
- API client → User uploads: requests
- API client → User favorites: requests
- Local router → Root endpoint: dispatches
- Local router → Sound search: dispatches
- Local router → Sound detail: dispatches
- Local router → Trending sounds: dispatches
- Local router → Best sounds: dispatches
- Local router → Recent sounds: dispatches
- Local router → User uploads: dispatches
- Local router → User favorites: dispatches
- Local router → 404 endpoint: dispatches
- API client → 404 endpoint: requests
- Sound search → Scrape helpers: fetches and parses
- Trending sounds → Scrape helpers: fetches and parses
- Best sounds → Scrape helpers: fetches and parses
- Recent sounds → Scrape helpers: fetches and parses
- User uploads → Scrape helpers: fetches and parses
- User favorites → Scrape helpers: fetches and parses
- Sound detail → Scrape helpers: fetches page
- Scrape helpers → MyInstants website: requests HTML
- Scrape helpers → HTML parser: parses HTML
- Sound detail → HTML parser: extracts metadata
- Sound search → JSON responses: formats results
- Sound detail → JSON responses: formats results
- Trending sounds → JSON responses: formats results
- Best sounds → JSON responses: formats results
- Recent sounds → JSON responses: formats results
- User uploads → JSON responses: formats results
- User favorites → JSON responses: formats results
- 404 endpoint → JSON responses: formats error
- JSON responses → API client: returns JSON
- JSON responses → Edge cache: sets cache headers
