# storytold/artcraft-services architecture

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

- Interactive diagram: https://gitdiagram.com/storytold/artcraft-services
- Repository: https://github.com/storytold/artcraft-services

## Overview

ArtCraft Services is a Rust and TypeScript platform for creative-media applications. A typical user submits an authenticated generation request through a web client; the API checks access and credits, estimates cost, and submits provider-specific work. Webhooks or workers handle completion, persist outputs and job/media metadata, and clients poll status and retrieve media. The graph also preserves the documented programmatic API and shared query/client layers. Relationships are based on README statements; source excerpts are limited, so unsampled implementation details are not inferred.

Main entry points: [`crates/service/web/storyteller_web`](https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web) (storyteller-web), [`crates/service/job`](https://github.com/storytold/artcraft-services/tree/main/crates/service/job) (Background workers), [`frontend/apps/artcraft-webapp`](https://github.com/storytold/artcraft-services/tree/main/frontend/apps/artcraft-webapp) (Web application), [`crates/service/web/storyteller_web/src/http_server`](https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web/src/http_server) (HTTP handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients and API"]
  node_web_frontend["Web application"]
  node_ts_api["TypeScript API"]
  node_api_defs["API definitions"]
  node_rust_client["Rust API client"]
end

subgraph group_service["HTTP service"]
  node_http_api["storyteller-web"]
  node_handlers["HTTP handlers"]
  node_billing["Billing components"]
end

subgraph group_generation["Generation runtime"]
  node_router["Generation router"]
  node_providers["Generation providers"]
  node_workers["Background workers"]
end

subgraph group_persistence["Persistence and media"]
  node_mysql[("MySQL")]
  node_query_layer["MySQL queries"]
  node_redis[("Redis")]
  node_object_storage[("Object storage")]
  node_media_results["Media results"]
end

node_user(("Application user"))
node_api_consumer(("API consumer"))
node_cdn["CDN media URLs"]

node_user -->|"uses"| node_web_frontend
node_web_frontend -->|"calls"| node_ts_api
node_api_consumer -->|"uses"| node_rust_client
node_ts_api -->|"calls"| node_http_api
node_rust_client -->|"calls"| node_http_api
node_http_api -->|"routes"| node_handlers
node_handlers -->|"uses types"| node_api_defs
node_handlers -->|"checks credits"| node_billing
node_handlers -->|"submits generation"| node_router
node_router -->|"adapts requests"| node_providers
node_providers -->|"sends webhooks"| node_http_api
node_workers -->|"polls jobs"| node_providers
node_http_api -->|"uses queries"| node_query_layer
node_workers -->|"uses queries"| node_query_layer
node_query_layer -->|"reads and writes"| node_mysql
node_http_api -->|"uses caching and limits"| node_redis
node_http_api -->|"stores uploads"| node_object_storage
node_workers -->|"stores outputs"| node_object_storage
node_workers -->|"registers results"| node_media_results
node_http_api -->|"serves job status"| node_media_results
node_web_frontend -->|"polls status"| node_http_api
node_web_frontend -->|"loads media"| node_cdn

click node_web_frontend "https://github.com/storytold/artcraft-services/tree/main/frontend/apps/artcraft-webapp"
click node_ts_api "https://github.com/storytold/artcraft-services/tree/main/frontend/libs/api"
click node_api_defs "https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_api_defs"
click node_rust_client "https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_client"
click node_http_api "https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web"
click node_handlers "https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web/src/http_server"
click node_billing "https://github.com/storytold/artcraft-services/tree/main/crates/service/plugins"
click node_router "https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_router"
click node_providers "https://github.com/storytold/artcraft-services/tree/main/crates/api_clients"
click node_workers "https://github.com/storytold/artcraft-services/tree/main/crates/service/job"
click node_query_layer "https://github.com/storytold/artcraft-services/tree/main/crates/schema/database/mysql_queries"
click node_media_results "https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web/src/http_server"

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_web_frontend,node_ts_api,node_api_defs,node_rust_client,node_user toneBlue
class node_http_api,node_handlers,node_billing toneAmber
class node_router,node_providers,node_workers,node_api_consumer toneMint
class node_mysql,node_query_layer,node_redis,node_object_storage,node_media_results toneRose
class node_cdn toneIndigo
```

## Components

### Clients and API

- [Web application](https://github.com/storytold/artcraft-services/tree/main/frontend/apps/artcraft-webapp): `frontend/apps/artcraft-webapp`
- [TypeScript API](https://github.com/storytold/artcraft-services/tree/main/frontend/libs/api): `frontend/libs/api`
- [API definitions](https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_api_defs): `crates/api_clients/artcraft/artcraft_api_defs`
- [Rust API client](https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_client): `crates/api_clients/artcraft/artcraft_client`

### HTTP service

- [storyteller-web](https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web): `crates/service/web/storyteller_web`
- [HTTP handlers](https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web/src/http_server): `crates/service/web/storyteller_web/src/http_server`
- [Billing components](https://github.com/storytold/artcraft-services/tree/main/crates/service/plugins): `crates/service/plugins`

### Generation runtime

- [Generation router](https://github.com/storytold/artcraft-services/tree/main/crates/api_clients/artcraft/artcraft_router): `crates/api_clients/artcraft/artcraft_router`
- [Generation providers](https://github.com/storytold/artcraft-services/tree/main/crates/api_clients): `crates/api_clients`
- [Background workers](https://github.com/storytold/artcraft-services/tree/main/crates/service/job): `crates/service/job`

### Persistence and media

- **MySQL**
- [MySQL queries](https://github.com/storytold/artcraft-services/tree/main/crates/schema/database/mysql_queries): `crates/schema/database/mysql_queries`
- **Redis**
- **Object storage**
- [Media results](https://github.com/storytold/artcraft-services/tree/main/crates/service/web/storyteller_web/src/http_server): `crates/service/web/storyteller_web/src/http_server`

### Other components

- **Application user**
- **API consumer**
- **CDN media URLs**

## Connections

- Application user → Web application: uses
- Web application → TypeScript API: calls
- API consumer → Rust API client: uses
- TypeScript API → storyteller-web: calls
- Rust API client → storyteller-web: calls
- storyteller-web → HTTP handlers: routes (evidence: `crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/conversion/enqueue_render_engine_scene_to_video_handler.rs`)
- HTTP handlers → API definitions: uses types
- HTTP handlers → Billing components: checks credits
- HTTP handlers → Generation router: submits generation
- Generation router → Generation providers: adapts requests
- Generation providers → storyteller-web: sends webhooks
- Background workers → Generation providers: polls jobs
- storyteller-web → MySQL queries: uses queries
- Background workers → MySQL queries: uses queries
- MySQL queries → MySQL: reads and writes
- storyteller-web → Redis: uses caching and limits
- storyteller-web → Object storage: stores uploads
- Background workers → Object storage: stores outputs
- Background workers → Media results: registers results
- storyteller-web → Media results: serves job status (evidence: `crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/conversion/enqueue_render_engine_scene_to_video_handler.rs`)
- Web application → storyteller-web: polls status
- Web application → CDN media URLs: loads media
