# genshindev/api architecture

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

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

## Overview

genshin.dev is a static-data API for Genshin Impact, not a game client. A caller requests entity types, entity lists, localized entity details, or image listings/images; Koa routes the request to filesystem-backed services, which read JSON or image assets and return the result. The principal runtime layers and the documented data and image capabilities are shown. The route and storage calls are evidenced by excerpts; asset behavior is also described in the README. Image assets are documented but not present in the supplied tree.

Main entry points: [`src/modules/filesystem.ts`](https://github.com/genshindev/api/blob/mistress/src/modules/filesystem.ts) (Filesystem services), [`src/index.ts`](https://github.com/genshindev/api/blob/mistress/src/index.ts) (Koa server), [`src/routes/index.ts`](https://github.com/genshindev/api/blob/mistress/src/routes/index.ts) (Endpoint routing), [`assets/data`](https://github.com/genshindev/api/tree/mistress/assets/data) (Entity JSON)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_server["Koa server<br/>[index.ts]"]
  node_routes["Endpoint routing<br/>[index.ts]"]
end

subgraph group_content["Static content"]
  node_entity_data["Entity JSON"]
  node_image_assets["Entity images"]
end

subgraph group_storage["Data access"]
  node_filesystem["Filesystem services<br/>[filesystem.ts]"]
  node_paths["Asset paths<br/>[config.ts]"]
  node_cache[("In-memory cache<br/>[filesystem.ts]")]
end

node_caller(("API caller"))

node_caller -->|"requests endpoints"| node_server
node_server -->|"registers routes"| node_routes
node_routes -->|"calls data services"| node_filesystem
node_filesystem -->|"uses asset paths"| node_paths
node_filesystem -->|"reads and writes"| node_cache
node_filesystem -->|"reads JSON"| node_entity_data
node_filesystem -->|"reads and converts"| node_image_assets

click node_server "https://github.com/genshindev/api/blob/mistress/src/index.ts"
click node_routes "https://github.com/genshindev/api/blob/mistress/src/routes/index.ts"
click node_filesystem "https://github.com/genshindev/api/blob/mistress/src/modules/filesystem.ts"
click node_paths "https://github.com/genshindev/api/blob/mistress/src/config.ts"
click node_cache "https://github.com/genshindev/api/blob/mistress/src/modules/filesystem.ts"
click node_entity_data "https://github.com/genshindev/api/tree/mistress/assets/data"
click node_image_assets "https://github.com/genshindev/api/tree/mistress/assets/images"

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_routes toneBlue
class node_entity_data,node_image_assets toneAmber
class node_filesystem,node_paths,node_cache,node_caller toneMint
```

## Components

### API runtime

- [Koa server](https://github.com/genshindev/api/blob/mistress/src/index.ts): `src/index.ts`
- [Endpoint routing](https://github.com/genshindev/api/blob/mistress/src/routes/index.ts): `src/routes/index.ts`

### Static content

- [Entity JSON](https://github.com/genshindev/api/tree/mistress/assets/data): `assets/data`
- [Entity images](https://github.com/genshindev/api/tree/mistress/assets/images): `assets/images`

### Data access

- [Filesystem services](https://github.com/genshindev/api/blob/mistress/src/modules/filesystem.ts): `src/modules/filesystem.ts`
- [Asset paths](https://github.com/genshindev/api/blob/mistress/src/config.ts): `src/config.ts`
- [In-memory cache](https://github.com/genshindev/api/blob/mistress/src/modules/filesystem.ts): `src/modules/filesystem.ts`

### Other components

- **API caller**

## Connections

- API caller → Koa server: requests endpoints (evidence: `README.md`)
- Koa server → Endpoint routing: registers routes (evidence: `src/index.ts`)
- Endpoint routing → Filesystem services: calls data services (evidence: `src/routes/index.ts`)
- Filesystem services → Asset paths: uses asset paths (evidence: `src/modules/filesystem.ts`)
- Filesystem services → In-memory cache: reads and writes (evidence: `src/modules/filesystem.ts`)
- Filesystem services → Entity JSON: reads JSON (evidence: `src/modules/filesystem.ts`)
- Filesystem services → Entity images: reads and converts (evidence: `src/modules/filesystem.ts`)
