# sh0mik/anivault-api architecture

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

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

## Overview

AniVault Scraper API serves two principal workflows: anime metadata/art lookup and playback resolution from title or IDs through episodes and servers to playable streams. The graph also preserves the independent MAL scraping capabilities and the ZokoAnime provider route. Source excerpts and the index support the shown calls; some README-described stages are retained where their detailed implementation was not sampled.

Main entry points: [`src/routes.ts`](https://github.com/sh0mik/anivault-api/blob/main/src/routes.ts) (API handlers), [`src/utils/mapper.ts`](https://github.com/sh0mik/anivault-api/blob/main/src/utils/mapper.ts) (ID and site mapping), [`src/utils/cache.ts`](https://github.com/sh0mik/anivault-api/blob/main/src/utils/cache.ts) (Response cache), [`src/utils/fetch.ts`](https://github.com/sh0mik/anivault-api/blob/main/src/utils/fetch.ts) (HTTP fetch clients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API orchestration"]
  node_server["HTTP server<br/>[server.ts]"]
  node_api_routes["API handlers<br/>[routes.ts]"]
  node_provider_routes["Provider routes<br/>[routes.ts]"]
end

subgraph group_metadata["Metadata and mapping"]
  node_mapper["ID and site mapping<br/>[mapper.ts]"]
  node_anilist["AniList metadata<br/>[anilist.ts]"]
  node_mal["MAL scraping<br/>[mal.ts]"]
  node_tmdb["TMDB art<br/>[tmdb.ts]"]
  node_kitsu["Kitsu art<br/>[kitsu.ts]"]
end

subgraph group_playback["Playback sources"]
  node_animeheaven["AnimeHeaven<br/>[animeheaven.ts]"]
  node_anikoto["Anikoto<br/>[anikoto.ts]"]
  node_desidub["DesiDub<br/>[desidub.ts]"]
  node_megaplay["MegaPlay Direct<br/>[megaplay.ts]"]
  node_zoko["ZokoAnime provider<br/>[zokoanime.ts]"]
  node_megacloud["Megacloud resolver<br/>[megacloud.ts]"]
end

subgraph group_shared["Shared services"]
  node_fetch["HTTP fetch clients<br/>[fetch.ts]"]
  node_cache[("Response cache<br/>[cache.ts]")]
end

node_client(("AniVault client"))

node_client -->|"calls API"| node_server
node_server -->|"mounts routes"| node_api_routes
node_server -->|"mounts routes"| node_provider_routes
node_api_routes -->|"resolves IDs"| node_mapper
node_api_routes -->|"gets MAL data"| node_mal
node_api_routes -->|"resolves streams"| node_animeheaven
node_api_routes -->|"gets episodes and streams"| node_anikoto
node_api_routes -->|"resolves streams"| node_desidub
node_api_routes -->|"gets art"| node_tmdb
node_api_routes -->|"gets fallback art"| node_kitsu
node_api_routes -.->|"resolves embeds"| node_megacloud
node_api_routes -->|"searches titles"| node_anilist
node_mapper -->|"gets title details"| node_mal
node_mapper -->|"finds source ID"| node_animeheaven
node_mapper -->|"finds source slug"| node_desidub
node_mapper -->|"queries AniList"| node_anilist
node_provider_routes -->|"gets servers and streams"| node_zoko
node_provider_routes -->|"uses proxy URLs"| node_api_routes
node_api_routes -->|"resolves direct playback"| node_megaplay
node_anikoto -.->|"resolves embed"| node_megacloud
node_animeheaven -->|"uses HTTP client"| node_fetch
node_anikoto -->|"uses HTTP client"| node_fetch
node_desidub -->|"uses HTTP client"| node_fetch
node_mal -->|"uses HTTP client"| node_fetch
node_anilist -->|"uses HTTP client"| node_fetch
node_animeheaven -->|"caches results"| node_cache
node_anikoto -->|"caches results"| node_cache
node_desidub -->|"caches results"| node_cache
node_mal -->|"caches results"| node_cache
node_tmdb -->|"caches results"| node_cache
node_kitsu -->|"caches results"| node_cache
node_mapper -->|"caches mappings"| node_cache

click node_server "https://github.com/sh0mik/anivault-api/blob/main/src/server.ts"
click node_api_routes "https://github.com/sh0mik/anivault-api/blob/main/src/routes.ts"
click node_provider_routes "https://github.com/sh0mik/anivault-api/blob/main/src/providers/routes.ts"
click node_mapper "https://github.com/sh0mik/anivault-api/blob/main/src/utils/mapper.ts"
click node_anilist "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/anilist.ts"
click node_mal "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/mal.ts"
click node_tmdb "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/tmdb.ts"
click node_kitsu "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/kitsu.ts"
click node_animeheaven "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/animeheaven.ts"
click node_anikoto "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/anikoto.ts"
click node_desidub "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/desidub.ts"
click node_megaplay "https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/megaplay.ts"
click node_zoko "https://github.com/sh0mik/anivault-api/blob/main/src/providers/zokoanime.ts"
click node_megacloud "https://github.com/sh0mik/anivault-api/blob/main/src/resolvers/megacloud.ts"
click node_fetch "https://github.com/sh0mik/anivault-api/blob/main/src/utils/fetch.ts"
click node_cache "https://github.com/sh0mik/anivault-api/blob/main/src/utils/cache.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_server,node_api_routes,node_provider_routes,node_client toneBlue
class node_mapper,node_anilist,node_mal,node_tmdb,node_kitsu toneAmber
class node_animeheaven,node_anikoto,node_desidub,node_megaplay,node_zoko,node_megacloud toneMint
class node_fetch,node_cache toneRose
```

## Components

### API orchestration

- [HTTP server](https://github.com/sh0mik/anivault-api/blob/main/src/server.ts): `src/server.ts`
- [API handlers](https://github.com/sh0mik/anivault-api/blob/main/src/routes.ts): `src/routes.ts`
- [Provider routes](https://github.com/sh0mik/anivault-api/blob/main/src/providers/routes.ts): `src/providers/routes.ts`

### Metadata and mapping

- [ID and site mapping](https://github.com/sh0mik/anivault-api/blob/main/src/utils/mapper.ts): `src/utils/mapper.ts`
- [AniList metadata](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/anilist.ts): `src/scrapers/anilist.ts`
- [MAL scraping](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/mal.ts): `src/scrapers/mal.ts`
- [TMDB art](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/tmdb.ts): `src/scrapers/tmdb.ts`
- [Kitsu art](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/kitsu.ts): `src/scrapers/kitsu.ts`

### Playback sources

- [AnimeHeaven](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/animeheaven.ts): `src/scrapers/animeheaven.ts`
- [Anikoto](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/anikoto.ts): `src/scrapers/anikoto.ts`
- [DesiDub](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/desidub.ts): `src/scrapers/desidub.ts`
- [MegaPlay Direct](https://github.com/sh0mik/anivault-api/blob/main/src/scrapers/megaplay.ts): `src/scrapers/megaplay.ts`
- [ZokoAnime provider](https://github.com/sh0mik/anivault-api/blob/main/src/providers/zokoanime.ts): `src/providers/zokoanime.ts`
- [Megacloud resolver](https://github.com/sh0mik/anivault-api/blob/main/src/resolvers/megacloud.ts): `src/resolvers/megacloud.ts`

### Shared services

- [HTTP fetch clients](https://github.com/sh0mik/anivault-api/blob/main/src/utils/fetch.ts): `src/utils/fetch.ts`
- [Response cache](https://github.com/sh0mik/anivault-api/blob/main/src/utils/cache.ts): `src/utils/cache.ts`

### Other components

- **AniVault client**

## Connections

- AniVault client → HTTP server: calls API (evidence: `README.md`)
- HTTP server → API handlers: mounts routes (evidence: `src/server.ts`)
- HTTP server → Provider routes: mounts routes (evidence: `src/server.ts`)
- API handlers → ID and site mapping: resolves IDs (evidence: `src/routes.ts`)
- API handlers → MAL scraping: gets MAL data (evidence: `src/routes.ts`)
- API handlers → AnimeHeaven: resolves streams (evidence: `src/routes.ts`)
- API handlers → Anikoto: gets episodes and streams (evidence: `src/routes.ts`)
- API handlers → DesiDub: resolves streams (evidence: `src/routes.ts`)
- API handlers → TMDB art: gets art (evidence: `src/routes.ts`)
- API handlers → Kitsu art: gets fallback art (evidence: `src/routes.ts`)
- API handlers → Megacloud resolver: resolves embeds (evidence: `src/routes.ts`)
- API handlers → AniList metadata: searches titles (evidence: `README.md`)
- ID and site mapping → MAL scraping: gets title details (evidence: `src/utils/mapper.ts`)
- ID and site mapping → AnimeHeaven: finds source ID (evidence: `src/utils/mapper.ts`)
- ID and site mapping → DesiDub: finds source slug (evidence: `src/utils/mapper.ts`)
- ID and site mapping → AniList metadata: queries AniList (evidence: `src/utils/mapper.ts`)
- Provider routes → ZokoAnime provider: gets servers and streams (evidence: `src/providers/routes.ts`)
- Provider routes → API handlers: uses proxy URLs (evidence: `src/providers/routes.ts`)
- API handlers → MegaPlay Direct: resolves direct playback (evidence: `README.md`)
- Anikoto → Megacloud resolver: resolves embed
- AnimeHeaven → HTTP fetch clients: uses HTTP client (evidence: `src/scrapers/animeheaven.ts`)
- Anikoto → HTTP fetch clients: uses HTTP client (evidence: `src/scrapers/anikoto.ts`)
- DesiDub → HTTP fetch clients: uses HTTP client (evidence: `src/scrapers/desidub.ts`)
- MAL scraping → HTTP fetch clients: uses HTTP client (evidence: `src/scrapers/mal.ts`)
- AniList metadata → HTTP fetch clients: uses HTTP client (evidence: `src/scrapers/anilist.ts`)
- AnimeHeaven → Response cache: caches results (evidence: `src/scrapers/animeheaven.ts`)
- Anikoto → Response cache: caches results (evidence: `src/scrapers/anikoto.ts`)
- DesiDub → Response cache: caches results (evidence: `src/scrapers/desidub.ts`)
- MAL scraping → Response cache: caches results (evidence: `src/scrapers/mal.ts`)
- TMDB art → Response cache: caches results (evidence: `src/scrapers/tmdb.ts`)
- Kitsu art → Response cache: caches results (evidence: `src/scrapers/kitsu.ts`)
- ID and site mapping → Response cache: caches mappings (evidence: `src/utils/mapper.ts`)
