# jaames/dreams-api architecture

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

- Interactive diagram: https://gitdiagram.com/jaames/dreams-api
- Repository: https://github.com/jaames/dreams-api

## Overview

Dreams API is a small Node.js proxy for indreams.me, not a level-data downloader. A client sends a GET, POST, or audio-import request to the local Express server; the server delegates to the corresponding proxy request, which builds authentication headers, forwards the request, updates configured cookies from the response, and relays the upstream status, headers, and body. The repository also provides ID conversion and Dreams content-type definitions, but their use in the proxy workflow is not shown. The configuration file is read and updated at runtime; source excerpts do not show how the example config becomes the required file.

Main entry points: [`src/dreamsClient.ts`](https://github.com/jaames/dreams-api/blob/master/src/dreamsClient.ts) (API client), [`src/server.ts`](https://github.com/jaames/dreams-api/blob/master/src/server.ts) (Express proxy), [`src/dreamsId.ts`](https://github.com/jaames/dreams-api/blob/master/src/dreamsId.ts) (ID conversion), [`src/dreamsThing.ts`](https://github.com/jaames/dreams-api/blob/master/src/dreamsThing.ts) (Content types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_proxy["API proxy"]
  node_client["API client<br/>[dreamsClient.ts]"]
  node_server["Express proxy<br/>[server.ts]"]
  node_indreams["indreams.me API"]
end

subgraph group_identity["Dreams identifiers"]
  node_ids["ID conversion<br/>[dreamsId.ts]"]
  node_thingtypes["Content types<br/>[dreamsThing.ts]"]
end

subgraph group_state["Configuration"]
  node_config[("Config state<br/>[config.ts]")]
end

node_caller(("API caller"))

node_caller -->|"sends requests"| node_server
node_server -->|"dispatches requests"| node_client
node_client -->|"forwards requests"| node_indreams
node_client -->|"reads and updates cookies"| node_config
node_client -->|"returns responses"| node_server
node_ids -->|"maps ID types"| node_thingtypes

click node_client "https://github.com/jaames/dreams-api/blob/master/src/dreamsClient.ts"
click node_server "https://github.com/jaames/dreams-api/blob/master/src/server.ts"
click node_ids "https://github.com/jaames/dreams-api/blob/master/src/dreamsId.ts"
click node_thingtypes "https://github.com/jaames/dreams-api/blob/master/src/dreamsThing.ts"
click node_config "https://github.com/jaames/dreams-api/blob/master/src/config.ts"

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_client,node_server,node_indreams toneBlue
class node_ids,node_thingtypes toneAmber
class node_config,node_caller toneMint
```

## Components

### API proxy

- [API client](https://github.com/jaames/dreams-api/blob/master/src/dreamsClient.ts): `src/dreamsClient.ts`
- [Express proxy](https://github.com/jaames/dreams-api/blob/master/src/server.ts): `src/server.ts`
- **indreams.me API**

### Dreams identifiers

- [ID conversion](https://github.com/jaames/dreams-api/blob/master/src/dreamsId.ts): `src/dreamsId.ts`
- [Content types](https://github.com/jaames/dreams-api/blob/master/src/dreamsThing.ts): `src/dreamsThing.ts`

### Configuration

- [Config state](https://github.com/jaames/dreams-api/blob/master/src/config.ts): `src/config.ts`

### Other components

- **API caller**

## Connections

- API caller → Express proxy: sends requests (evidence: `src/server.ts`)
- Express proxy → API client: dispatches requests (evidence: `src/server.ts`)
- API client → indreams.me API: forwards requests (evidence: `src/dreamsClient.ts`)
- API client → Config state: reads and updates cookies (evidence: `src/dreamsClient.ts`)
- API client → Express proxy: returns responses (evidence: `src/server.ts`)
- ID conversion → Content types: maps ID types (evidence: `src/dreamsId.ts`)
