# psrockstar098/yatta.js architecture

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

- Interactive diagram: https://gitdiagram.com/psrockstar098/yatta.js
- Repository: https://github.com/psrockstar098/yatta.js

## Overview

Yatta is a Bun backend framework with two documented layers: application engines wired into HTTP services, and an independently usable worker runtime. The principal request path enters the server, reaches protocol or realtime handling, then dispatches file-based routes; routes can use the configured engines and persistent stores. The graph also preserves the documented deployment CLI and major feature-engine families. Several engine implementations and runtime files were not excerpted, so their internal links are omitted unless documented or visible in the source index.

Main entry points: [`src/main.ts`](https://github.com/psrockstar098/yatta.js/blob/main/src/main.ts) (Bun server), [`src/func/routerHelper.ts`](https://github.com/psrockstar098/yatta.js/blob/main/src/func/routerHelper.ts) (Request dispatcher), [`core_runtime/runtime.ts`](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/runtime.ts) (Runtime lifecycle), [`src/func/auth.ts`](https://github.com/psrockstar098/yatta.js/blob/main/src/func/auth.ts) (Auth wiring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application runtime"]
  node_server["Bun server<br/>[main.ts]"]
  node_env["Environment config<br/>[env.ts]"]
  node_peer["Peer tracking<br/>[peer.ts]"]
end

subgraph group_http["HTTP and protocols"]
  node_router["Request dispatcher<br/>[routerHelper.ts]"]
  node_file_routes["File routes"]
  node_protocols["Protocol handlers<br/>[grpcweb.ts]"]
  node_oauth["OAuth and OIDC<br/>[oauth.ts]"]
  node_webdav["WebDAV handler<br/>[webdav.ts]"]
end

subgraph group_engines["Framework engines"]
  node_api["Typed API engine<br/>[api.ts]"]
  node_realtime["Realtime engine<br/>[realtime.ts]"]
  node_db_config["Database wiring<br/>[db.ts]"]
  node_database[("SQLite ORM<br/>[db.ts]")]
  node_auth_config["Auth wiring<br/>[auth.ts]"]
  node_auth["Auth engine<br/>[auth.ts]"]
  node_jobs["Jobs and cron<br/>[job.ts]"]
  node_cache["Cache engine<br/>[cache_queue.ts]"]
  node_storage_config["Storage wiring<br/>[storage.ts]"]
  node_storage["Object storage<br/>[storage.ts]"]
  node_mail["Mail engine<br/>[mail.ts]"]
  node_observe["Observability<br/>[observe.ts]"]
end

subgraph group_compute["Worker runtime"]
  node_runtime["Runtime lifecycle<br/>[runtime.ts]"]
  node_scheduler["Task scheduler<br/>[scheduler.ts]"]
  node_worker["Worker execution<br/>[worker.ts]"]
  node_module_graph["Module isolation<br/>[moduleGraph.ts]"]
  node_cluster["Cluster support<br/>[cluster.ts]"]
end

subgraph group_operations["CLI and deployment"]
  node_cli["Framework CLI<br/>[cli.ts]"]
  node_deploy["Deployment CLI<br/>[cli.ts]"]
end

node_client(("HTTP client"))

node_client -->|"sends requests"| node_server
node_server -->|"loads config"| node_env
node_server -->|"records peer"| node_peer
node_server -->|"dispatches requests"| node_router
node_router -->|"loads route modules"| node_file_routes
node_router -->|"calls handlers"| node_api
node_router -->|"handles realtime"| node_realtime
node_router -->|"serves storage"| node_storage_config
node_router -->|"dispatches protocols"| node_protocols
node_router -->|"dispatches auth"| node_oauth
node_router -->|"dispatches WebDAV"| node_webdav
node_db_config -->|"configures"| node_database
node_auth_config -->|"creates engine"| node_auth
node_auth_config -->|"uses database"| node_db_config
node_storage_config -->|"creates engine"| node_storage
node_server -->|"starts and drains"| node_runtime
node_runtime -.->|"schedules tasks"| node_scheduler
node_scheduler -->|"dispatches tasks"| node_worker
node_worker -->|"loads isolated modules"| node_module_graph
node_runtime -.->|"coordinates workers"| node_cluster
node_server -.->|"attaches subsystem"| node_jobs
node_server -.->|"attaches subsystem"| node_cache
node_server -.->|"attaches subsystem"| node_mail
node_server -.->|"starts observer"| node_observe
node_cli -->|"invokes deployment"| node_deploy

click node_server "https://github.com/psrockstar098/yatta.js/blob/main/src/main.ts"
click node_env "https://github.com/psrockstar098/yatta.js/blob/main/src/func/env.ts"
click node_peer "https://github.com/psrockstar098/yatta.js/blob/main/src/func/peer.ts"
click node_router "https://github.com/psrockstar098/yatta.js/blob/main/src/func/routerHelper.ts"
click node_file_routes "https://github.com/psrockstar098/yatta.js/blob/main/src/func/standalone_routes.ts"
click node_api "https://github.com/psrockstar098/yatta.js/blob/main/src/types/api.ts"
click node_protocols "https://github.com/psrockstar098/yatta.js/blob/main/src/func/grpcweb.ts"
click node_oauth "https://github.com/psrockstar098/yatta.js/blob/main/src/func/oauth.ts"
click node_webdav "https://github.com/psrockstar098/yatta.js/blob/main/src/func/webdav.ts"
click node_realtime "https://github.com/psrockstar098/yatta.js/blob/main/src/types/realtime.ts"
click node_db_config "https://github.com/psrockstar098/yatta.js/blob/main/src/func/db.ts"
click node_database "https://github.com/psrockstar098/yatta.js/blob/main/src/types/db.ts"
click node_auth_config "https://github.com/psrockstar098/yatta.js/blob/main/src/func/auth.ts"
click node_auth "https://github.com/psrockstar098/yatta.js/blob/main/src/types/auth.ts"
click node_jobs "https://github.com/psrockstar098/yatta.js/blob/main/src/types/job.ts"
click node_cache "https://github.com/psrockstar098/yatta.js/blob/main/src/types/cache_queue.ts"
click node_storage_config "https://github.com/psrockstar098/yatta.js/blob/main/src/func/storage.ts"
click node_storage "https://github.com/psrockstar098/yatta.js/blob/main/src/types/storage.ts"
click node_mail "https://github.com/psrockstar098/yatta.js/blob/main/src/types/mail.ts"
click node_observe "https://github.com/psrockstar098/yatta.js/blob/main/src/types/observe.ts"
click node_runtime "https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/runtime.ts"
click node_scheduler "https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/scheduler.ts"
click node_worker "https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/worker.ts"
click node_module_graph "https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/moduleGraph.ts"
click node_cluster "https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/cluster.ts"
click node_cli "https://github.com/psrockstar098/yatta.js/blob/main/src/cli.ts"
click node_deploy "https://github.com/psrockstar098/yatta.js/blob/main/src/deploy/cli.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_env,node_peer,node_client toneBlue
class node_router,node_file_routes,node_protocols,node_oauth,node_webdav toneAmber
class node_api,node_realtime,node_db_config,node_database,node_auth_config,node_auth,node_jobs,node_cache,node_storage_config,node_storage,node_mail,node_observe toneMint
class node_runtime,node_scheduler,node_worker,node_module_graph,node_cluster toneRose
class node_cli,node_deploy toneIndigo
```

## Components

### Application runtime

- [Bun server](https://github.com/psrockstar098/yatta.js/blob/main/src/main.ts): `src/main.ts`
- [Environment config](https://github.com/psrockstar098/yatta.js/blob/main/src/func/env.ts): `src/func/env.ts`
- [Peer tracking](https://github.com/psrockstar098/yatta.js/blob/main/src/func/peer.ts): `src/func/peer.ts`

### HTTP and protocols

- [Request dispatcher](https://github.com/psrockstar098/yatta.js/blob/main/src/func/routerHelper.ts): `src/func/routerHelper.ts`
- [File routes](https://github.com/psrockstar098/yatta.js/blob/main/src/func/standalone_routes.ts): `src/func/standalone_routes.ts`
- [Protocol handlers](https://github.com/psrockstar098/yatta.js/blob/main/src/func/grpcweb.ts): `src/func/grpcweb.ts`
- [OAuth and OIDC](https://github.com/psrockstar098/yatta.js/blob/main/src/func/oauth.ts): `src/func/oauth.ts`
- [WebDAV handler](https://github.com/psrockstar098/yatta.js/blob/main/src/func/webdav.ts): `src/func/webdav.ts`

### Framework engines

- [Typed API engine](https://github.com/psrockstar098/yatta.js/blob/main/src/types/api.ts): `src/types/api.ts`
- [Realtime engine](https://github.com/psrockstar098/yatta.js/blob/main/src/types/realtime.ts): `src/types/realtime.ts`
- [Database wiring](https://github.com/psrockstar098/yatta.js/blob/main/src/func/db.ts): `src/func/db.ts`
- [SQLite ORM](https://github.com/psrockstar098/yatta.js/blob/main/src/types/db.ts): `src/types/db.ts`
- [Auth wiring](https://github.com/psrockstar098/yatta.js/blob/main/src/func/auth.ts): `src/func/auth.ts`
- [Auth engine](https://github.com/psrockstar098/yatta.js/blob/main/src/types/auth.ts): `src/types/auth.ts`
- [Jobs and cron](https://github.com/psrockstar098/yatta.js/blob/main/src/types/job.ts): `src/types/job.ts`
- [Cache engine](https://github.com/psrockstar098/yatta.js/blob/main/src/types/cache_queue.ts): `src/types/cache_queue.ts`
- [Storage wiring](https://github.com/psrockstar098/yatta.js/blob/main/src/func/storage.ts): `src/func/storage.ts`
- [Object storage](https://github.com/psrockstar098/yatta.js/blob/main/src/types/storage.ts): `src/types/storage.ts`
- [Mail engine](https://github.com/psrockstar098/yatta.js/blob/main/src/types/mail.ts): `src/types/mail.ts`
- [Observability](https://github.com/psrockstar098/yatta.js/blob/main/src/types/observe.ts): `src/types/observe.ts`

### Worker runtime

- [Runtime lifecycle](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/runtime.ts): `core_runtime/runtime.ts`
- [Task scheduler](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/scheduler.ts): `core_runtime/scheduler.ts`
- [Worker execution](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/worker.ts): `core_runtime/worker.ts`
- [Module isolation](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/moduleGraph.ts): `core_runtime/moduleGraph.ts`
- [Cluster support](https://github.com/psrockstar098/yatta.js/blob/main/core_runtime/cluster.ts): `core_runtime/cluster.ts`

### CLI and deployment

- [Framework CLI](https://github.com/psrockstar098/yatta.js/blob/main/src/cli.ts): `src/cli.ts`
- [Deployment CLI](https://github.com/psrockstar098/yatta.js/blob/main/src/deploy/cli.ts): `src/deploy/cli.ts`

### Other components

- **HTTP client**

## Connections

- HTTP client → Bun server: sends requests (evidence: `README.md`)
- Bun server → Environment config: loads config (evidence: `src/main.ts`)
- Bun server → Peer tracking: records peer (evidence: `src/main.ts`)
- Bun server → Request dispatcher: dispatches requests (evidence: `src/main.ts`)
- Request dispatcher → File routes: loads route modules (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → Typed API engine: calls handlers (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → Realtime engine: handles realtime (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → Storage wiring: serves storage (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → Protocol handlers: dispatches protocols (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → OAuth and OIDC: dispatches auth (evidence: `src/func/routerHelper.ts`)
- Request dispatcher → WebDAV handler: dispatches WebDAV (evidence: `src/func/routerHelper.ts`)
- Database wiring → SQLite ORM: configures (evidence: `src/func/db.ts`)
- Auth wiring → Auth engine: creates engine (evidence: `src/func/auth.ts`)
- Auth wiring → Database wiring: uses database (evidence: `src/func/auth.ts`)
- Storage wiring → Object storage: creates engine (evidence: `src/func/storage.ts`)
- Bun server → Runtime lifecycle: starts and drains (evidence: `src/main.ts`)
- Runtime lifecycle → Task scheduler: schedules tasks
- Task scheduler → Worker execution: dispatches tasks (evidence: `core_runtime/scheduler.ts`)
- Worker execution → Module isolation: loads isolated modules (evidence: `core_runtime/worker.ts`)
- Runtime lifecycle → Cluster support: coordinates workers
- Bun server → Jobs and cron: attaches subsystem
- Bun server → Cache engine: attaches subsystem
- Bun server → Mail engine: attaches subsystem
- Bun server → Observability: starts observer (evidence: `src/main.ts`)
- Framework CLI → Deployment CLI: invokes deployment (evidence: `src/cli.ts`)
