# autarkis/chitin architecture

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

- Interactive diagram: https://gitdiagram.com/autarkis/chitin
- Repository: https://github.com/autarkis/chitin

## Overview

Chitin compiles meshes, point clouds, Gaussian fields, and skinned assets into convex colliders and portable `.phys` artifacts. The principal workflow is input analysis and planning, geometry reconstruction/decomposition, verification and profile-based acceptance, then artifact export. It can run through Python or a Worker-hosted browser WASM compiler; a local job service wraps the Python compiler, and engine integrations consume the shared artifact. README documents the broad compiler and integration capabilities; several internal Python links are inferred only at subsystem level because their implementation excerpts were not provided.

Main entry points: [`src/chitin/core.py`](https://github.com/autarkis/chitin/blob/main/src/chitin/core.py) (Compiler orchestration), [`src/chitin_service/worker.py`](https://github.com/autarkis/chitin/blob/main/src/chitin_service/worker.py) (Job runner), [`src/chitin/phys.py`](https://github.com/autarkis/chitin/blob/main/src/chitin/phys.py) (PHYS format), [`integrations/wasm-lite/src/worker.ts`](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker.ts) (Compiler worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python compiler"]
  node_cli["CLI<br/>[cli.py]"]
  node_inputs["Input adapters"]
  node_analyze["Analyze and plan<br/>[analyze.py]"]
  node_core["Compiler orchestration<br/>[core.py]"]
  node_reconstruct["Surface reconstruction<br/>[reconstruct.py]"]
  node_stages["Geometry stages"]
  node_verify["Geometry verification<br/>[sweep.py]"]
  node_accept["Profile acceptance<br/>[acceptance.py]"]
  node_result["Compilation result<br/>[result.py]"]
  node_report["Reports and provenance<br/>[report.py]"]
  node_export["Artifact exporters"]
  node_phys["PHYS format<br/>[phys.py]"]
end

subgraph group_browser["Browser compiler"]
  node_browser_api["Browser compiler API<br/>[compiler.ts]"]
  node_worker_client["Worker client<br/>[worker-client.ts]"]
  node_worker["Compiler worker<br/>[worker.ts]"]
  node_decompose["WASM decomposition<br/>[decompose.ts]"]
  node_protocol["Worker protocol<br/>[worker-protocol.ts]"]
end

subgraph group_service["Local build service"]
  node_service_api["Job API<br/>[app.py]"]
  node_job_worker["Job runner<br/>[worker.py]"]
  node_job_store[("Job and artifact store<br/>[store.py]")]
end

subgraph group_artifacts["Artifact consumers"]
  node_web_reader["Web PHYS reader<br/>[phys-parser.ts]"]
  node_unity["Unity importer<br/>[PhysImporter.cs]"]
  node_unreal["Unreal importer"]
end

subgraph group_native["WASM compute"]
  node_wasm["Native WASM modules"]
end

node_user(("Asset author"))
node_runtime(("Physics runtime"))

node_user -.->|"submits asset"| node_cli
node_cli -.->|"invokes compiler"| node_core
node_user -->|"submits asset"| node_browser_api
node_browser_api -.->|"dispatches work"| node_worker_client
node_worker_client -->|"posts requests"| node_worker
node_worker -->|"uses messages"| node_protocol
node_worker -->|"calls decomposition"| node_decompose
node_decompose -.->|"runs WASM"| node_wasm
node_core -.->|"loads geometry"| node_inputs
node_core -.->|"analyzes input"| node_analyze
node_core -.->|"requests reconstruction"| node_reconstruct
node_core -.->|"runs pipeline"| node_stages
node_core -.->|"checks geometry"| node_verify
node_core -.->|"builds result"| node_result
node_accept -->|"reads metrics"| node_verify
node_core -.->|"evaluates build"| node_accept
node_core -.->|"writes artifacts"| node_export
node_export -.->|"writes PHYS"| node_phys
node_user -->|"submits job"| node_service_api
node_service_api -.->|"stores job"| node_job_store
node_service_api -.->|"runs job"| node_job_worker
node_job_worker -->|"updates job"| node_job_store
node_job_worker -->|"evaluates result"| node_accept
node_job_worker -->|"calls extract"| node_core
node_job_worker -.->|"exports artifacts"| node_export
node_phys -.->|"reads artifact"| node_web_reader
node_phys -->|"imports artifact"| node_unity
node_phys -.->|"reads artifact"| node_unreal
node_web_reader -->|"loads colliders"| node_runtime
node_unity -->|"creates colliders"| node_runtime
node_unreal -->|"loads hulls"| node_runtime

click node_cli "https://github.com/autarkis/chitin/blob/main/src/chitin/cli.py"
click node_inputs "https://github.com/autarkis/chitin/tree/main/src/chitin/adapters"
click node_analyze "https://github.com/autarkis/chitin/blob/main/src/chitin/analyze.py"
click node_core "https://github.com/autarkis/chitin/blob/main/src/chitin/core.py"
click node_reconstruct "https://github.com/autarkis/chitin/blob/main/src/chitin/stages/reconstruct.py"
click node_stages "https://github.com/autarkis/chitin/tree/main/src/chitin/stages"
click node_verify "https://github.com/autarkis/chitin/blob/main/src/chitin/verify/sweep.py"
click node_accept "https://github.com/autarkis/chitin/blob/main/src/chitin/acceptance.py"
click node_result "https://github.com/autarkis/chitin/blob/main/src/chitin/result.py"
click node_report "https://github.com/autarkis/chitin/blob/main/src/chitin/report.py"
click node_export "https://github.com/autarkis/chitin/tree/main/src/chitin/exporters"
click node_phys "https://github.com/autarkis/chitin/blob/main/src/chitin/phys.py"
click node_browser_api "https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/compiler.ts"
click node_worker_client "https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker-client.ts"
click node_worker "https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker.ts"
click node_decompose "https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/decompose.ts"
click node_protocol "https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker-protocol.ts"
click node_wasm "https://github.com/autarkis/chitin/tree/main/integrations/wasm/src"
click node_service_api "https://github.com/autarkis/chitin/blob/main/src/chitin_service/app.py"
click node_job_worker "https://github.com/autarkis/chitin/blob/main/src/chitin_service/worker.py"
click node_job_store "https://github.com/autarkis/chitin/blob/main/src/chitin_service/store.py"
click node_web_reader "https://github.com/autarkis/chitin/blob/main/integrations/web/src/phys-parser.ts"
click node_unity "https://github.com/autarkis/chitin/blob/main/integrations/unity/Editor/PhysImporter.cs"
click node_unreal "https://github.com/autarkis/chitin/blob/main/integrations/unreal/Source/ChitinImporter/Private/ChitinPhysReader.cpp"

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_cli,node_inputs,node_analyze,node_core,node_reconstruct,node_stages,node_verify,node_accept,node_result,node_report,node_export,node_phys toneBlue
class node_browser_api,node_worker_client,node_worker,node_decompose,node_protocol toneAmber
class node_service_api,node_job_worker,node_job_store toneMint
class node_web_reader,node_unity,node_unreal toneRose
class node_wasm,node_user,node_runtime toneIndigo
```

## Components

### Python compiler

- [CLI](https://github.com/autarkis/chitin/blob/main/src/chitin/cli.py): `src/chitin/cli.py`
- [Input adapters](https://github.com/autarkis/chitin/tree/main/src/chitin/adapters): `src/chitin/adapters`
- [Analyze and plan](https://github.com/autarkis/chitin/blob/main/src/chitin/analyze.py): `src/chitin/analyze.py`
- [Compiler orchestration](https://github.com/autarkis/chitin/blob/main/src/chitin/core.py): `src/chitin/core.py`
- [Surface reconstruction](https://github.com/autarkis/chitin/blob/main/src/chitin/stages/reconstruct.py): `src/chitin/stages/reconstruct.py`
- [Geometry stages](https://github.com/autarkis/chitin/tree/main/src/chitin/stages): `src/chitin/stages`
- [Geometry verification](https://github.com/autarkis/chitin/blob/main/src/chitin/verify/sweep.py): `src/chitin/verify/sweep.py`
- [Profile acceptance](https://github.com/autarkis/chitin/blob/main/src/chitin/acceptance.py): `src/chitin/acceptance.py`
- [Compilation result](https://github.com/autarkis/chitin/blob/main/src/chitin/result.py): `src/chitin/result.py`
- [Reports and provenance](https://github.com/autarkis/chitin/blob/main/src/chitin/report.py): `src/chitin/report.py`
- [Artifact exporters](https://github.com/autarkis/chitin/tree/main/src/chitin/exporters): `src/chitin/exporters`
- [PHYS format](https://github.com/autarkis/chitin/blob/main/src/chitin/phys.py): `src/chitin/phys.py`

### Browser compiler

- [Browser compiler API](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/compiler.ts): `integrations/wasm-lite/src/compiler.ts`
- [Worker client](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker-client.ts): `integrations/wasm-lite/src/worker-client.ts`
- [Compiler worker](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker.ts): `integrations/wasm-lite/src/worker.ts`
- [WASM decomposition](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/decompose.ts): `integrations/wasm-lite/src/decompose.ts`
- [Worker protocol](https://github.com/autarkis/chitin/blob/main/integrations/wasm-lite/src/worker-protocol.ts): `integrations/wasm-lite/src/worker-protocol.ts`

### Local build service

- [Job API](https://github.com/autarkis/chitin/blob/main/src/chitin_service/app.py): `src/chitin_service/app.py`
- [Job runner](https://github.com/autarkis/chitin/blob/main/src/chitin_service/worker.py): `src/chitin_service/worker.py`
- [Job and artifact store](https://github.com/autarkis/chitin/blob/main/src/chitin_service/store.py): `src/chitin_service/store.py`

### Artifact consumers

- [Web PHYS reader](https://github.com/autarkis/chitin/blob/main/integrations/web/src/phys-parser.ts): `integrations/web/src/phys-parser.ts`
- [Unity importer](https://github.com/autarkis/chitin/blob/main/integrations/unity/Editor/PhysImporter.cs): `integrations/unity/Editor/PhysImporter.cs`
- [Unreal importer](https://github.com/autarkis/chitin/blob/main/integrations/unreal/Source/ChitinImporter/Private/ChitinPhysReader.cpp): `integrations/unreal/Source/ChitinImporter/Private/ChitinPhysReader.cpp`

### WASM compute

- [Native WASM modules](https://github.com/autarkis/chitin/tree/main/integrations/wasm/src): `integrations/wasm/src`

### Other components

- **Asset author**
- **Physics runtime**

## Connections

- Asset author → CLI: submits asset (evidence: `README.md`)
- CLI → Compiler orchestration: invokes compiler (evidence: `README.md`)
- Asset author → Browser compiler API: submits asset (evidence: `README.md`)
- Browser compiler API → Worker client: dispatches work (evidence: `README.md`)
- Worker client → Compiler worker: posts requests (evidence: `integrations/wasm-lite/src/worker-client.ts`)
- Compiler worker → Worker protocol: uses messages (evidence: `integrations/wasm-lite/src/worker.ts`)
- Compiler worker → WASM decomposition: calls decomposition (evidence: `integrations/wasm-lite/src/worker.ts`)
- WASM decomposition → Native WASM modules: runs WASM
- Compiler orchestration → Input adapters: loads geometry
- Compiler orchestration → Analyze and plan: analyzes input
- Compiler orchestration → Surface reconstruction: requests reconstruction
- Compiler orchestration → Geometry stages: runs pipeline
- Compiler orchestration → Geometry verification: checks geometry
- Compiler orchestration → Compilation result: builds result
- Profile acceptance → Geometry verification: reads metrics (evidence: `src/chitin/acceptance.py`)
- Compiler orchestration → Profile acceptance: evaluates build
- Compiler orchestration → Artifact exporters: writes artifacts
- Artifact exporters → PHYS format: writes PHYS
- Asset author → Job API: submits job (evidence: `src/chitin_service/app.py`)
- Job API → Job and artifact store: stores job (evidence: `src/chitin_service/app.py`)
- Job API → Job runner: runs job (evidence: `src/chitin_service/app.py`)
- Job runner → Job and artifact store: updates job (evidence: `src/chitin_service/worker.py`)
- Job runner → Profile acceptance: evaluates result (evidence: `src/chitin_service/worker.py`)
- Job runner → Compiler orchestration: calls extract (evidence: `src/chitin_service/worker.py`)
- Job runner → Artifact exporters: exports artifacts (evidence: `src/chitin_service/worker.py`)
- PHYS format → Web PHYS reader: reads artifact (evidence: `README.md`)
- PHYS format → Unity importer: imports artifact (evidence: `integrations/unity/Editor/PhysImporter.cs`)
- PHYS format → Unreal importer: reads artifact (evidence: `README.md`)
- Web PHYS reader → Physics runtime: loads colliders (evidence: `README.md`)
- Unity importer → Physics runtime: creates colliders (evidence: `README.md`)
- Unreal importer → Physics runtime: loads hulls (evidence: `README.md`)
