# discordcreater/trase-project architecture

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

- Interactive diagram: https://gitdiagram.com/discordcreater/trase-project
- Repository: https://github.com/discordcreater/trase-project
- Video tour (about a minute): https://gitdiagram.com/discordcreater/trase-project/video

## Overview

wfk is a small durable Python workflow engine, demonstrated by document triage. A caller starts or resumes a spec through the CLI; the engine orders ingest, extract, classify, and notify, persisting transitions and outputs so interrupted work can resume. Tools perform document processing, classification records its decision, and notification uses an effects ledger plus an idempotency-aware receiver. Operators can inspect status and event history or replay the log to check stored state. Edges reflect README statements and shown calls; internal store details and some engine control paths are only partially excerpted.

Main entry points: [`wfk/engine.py`](https://github.com/discordcreater/trase-project/blob/main/wfk/engine.py) (Execution engine), [`wfk/cli.py`](https://github.com/discordcreater/trase-project/blob/main/wfk/cli.py) (CLI commands), [`wfk/store.py`](https://github.com/discordcreater/trase-project/blob/main/wfk/store.py) (SQLite store), [`wfk/faults.py`](https://github.com/discordcreater/trase-project/blob/main/wfk/faults.py) (Fault wrappers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Invocation"]
  node_cli["CLI commands<br/>[cli.py]"]
end

subgraph group_workflow["Workflow Runtime"]
  node_spec["Workflow specs<br/>[spec.py]"]
  node_engine["Execution engine<br/>[engine.py]"]
  node_faults["Fault wrappers<br/>[faults.py]"]
end

subgraph group_work["Triage Work"]
  node_ingest["Ingest document<br/>[tools.py]"]
  node_extract["Extract text<br/>[tools.py]"]
  node_classify["Classify document<br/>[tools.py]"]
  node_notify["Send notification<br/>[tools.py]"]
  node_receiver["File notifier<br/>[tools.py]"]
end

subgraph group_durability["Durable State"]
  node_store[("SQLite store<br/>[store.py]")]
  node_effects[("Effect ledger<br/>[store.py]")]
  node_eventlog[("Append-only events<br/>[store.py]")]
  node_replay["Replay checker<br/>[engine.py]"]
end

node_operator(("Operator"))

node_operator -->|"invokes"| node_cli
node_cli -->|"builds and calls"| node_engine
node_cli -->|"loads spec"| node_spec
node_cli -->|"configures"| node_faults
node_cli -->|"opens"| node_store
node_engine -->|"reads"| node_spec
node_engine -->|"reads and writes"| node_store
node_engine -->|"dispatches"| node_ingest
node_engine -->|"dispatches"| node_extract
node_engine -->|"dispatches"| node_classify
node_engine -->|"dispatches"| node_notify
node_ingest -->|"passes output"| node_extract
node_extract -->|"passes output"| node_classify
node_classify -->|"passes output"| node_notify
node_classify -->|"records decision"| node_engine
node_notify -->|"runs effect"| node_engine
node_engine -->|"claims and records"| node_effects
node_engine -->|"sends keyed effect"| node_receiver
node_receiver -->|"deduplication outcome"| node_effects
node_store -->|"appends transitions"| node_eventlog
node_cli -->|"reads status and history"| node_store
node_cli -->|"requests replay"| node_replay
node_replay -->|"compares rebuilt state"| node_store
node_faults -.->|"wraps tools"| node_ingest
node_faults -->|"wraps sink"| node_receiver
node_faults -->|"crashes after commit"| node_store

click node_cli "https://github.com/discordcreater/trase-project/blob/main/wfk/cli.py"
click node_spec "https://github.com/discordcreater/trase-project/blob/main/wfk/spec.py"
click node_engine "https://github.com/discordcreater/trase-project/blob/main/wfk/engine.py"
click node_ingest "https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py"
click node_extract "https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py"
click node_classify "https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py"
click node_notify "https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py"
click node_receiver "https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py"
click node_store "https://github.com/discordcreater/trase-project/blob/main/wfk/store.py"
click node_effects "https://github.com/discordcreater/trase-project/blob/main/wfk/store.py"
click node_eventlog "https://github.com/discordcreater/trase-project/blob/main/wfk/store.py"
click node_replay "https://github.com/discordcreater/trase-project/blob/main/wfk/engine.py"
click node_faults "https://github.com/discordcreater/trase-project/blob/main/wfk/faults.py"

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 toneBlue
class node_spec,node_engine,node_faults toneAmber
class node_ingest,node_extract,node_classify,node_notify,node_receiver toneMint
class node_store,node_effects,node_eventlog,node_replay toneRose
class node_operator toneIndigo
```

## Components

### Invocation

- [CLI commands](https://github.com/discordcreater/trase-project/blob/main/wfk/cli.py): `wfk/cli.py`

### Workflow Runtime

- [Workflow specs](https://github.com/discordcreater/trase-project/blob/main/wfk/spec.py): `wfk/spec.py`
- [Execution engine](https://github.com/discordcreater/trase-project/blob/main/wfk/engine.py): `wfk/engine.py`
- [Fault wrappers](https://github.com/discordcreater/trase-project/blob/main/wfk/faults.py): `wfk/faults.py`

### Triage Work

- [Ingest document](https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py): `wfk/tools.py`
- [Extract text](https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py): `wfk/tools.py`
- [Classify document](https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py): `wfk/tools.py`
- [Send notification](https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py): `wfk/tools.py`
- [File notifier](https://github.com/discordcreater/trase-project/blob/main/wfk/tools.py): `wfk/tools.py`

### Durable State

- [SQLite store](https://github.com/discordcreater/trase-project/blob/main/wfk/store.py): `wfk/store.py`
- [Effect ledger](https://github.com/discordcreater/trase-project/blob/main/wfk/store.py): `wfk/store.py`
- [Append-only events](https://github.com/discordcreater/trase-project/blob/main/wfk/store.py): `wfk/store.py`
- [Replay checker](https://github.com/discordcreater/trase-project/blob/main/wfk/engine.py): `wfk/engine.py`

### Other components

- **Operator**

## Connections

- Operator → CLI commands: invokes (evidence: `README.md`)
- CLI commands → Execution engine: builds and calls (evidence: `wfk/cli.py`)
- CLI commands → Workflow specs: loads spec (evidence: `wfk/cli.py`)
- CLI commands → Fault wrappers: configures (evidence: `wfk/cli.py`)
- CLI commands → SQLite store: opens (evidence: `README.md`)
- Execution engine → Workflow specs: reads (evidence: `wfk/engine.py`)
- Execution engine → SQLite store: reads and writes (evidence: `wfk/engine.py`)
- Execution engine → Ingest document: dispatches (evidence: `README.md`)
- Execution engine → Extract text: dispatches (evidence: `README.md`)
- Execution engine → Classify document: dispatches (evidence: `README.md`)
- Execution engine → Send notification: dispatches (evidence: `README.md`)
- Ingest document → Extract text: passes output (evidence: `README.md`)
- Extract text → Classify document: passes output (evidence: `README.md`)
- Classify document → Send notification: passes output (evidence: `README.md`)
- Classify document → Execution engine: records decision (evidence: `wfk/engine.py`)
- Send notification → Execution engine: runs effect (evidence: `wfk/engine.py`)
- Execution engine → Effect ledger: claims and records (evidence: `README.md`)
- Execution engine → File notifier: sends keyed effect (evidence: `README.md`)
- File notifier → Effect ledger: deduplication outcome (evidence: `README.md`)
- SQLite store → Append-only events: appends transitions (evidence: `README.md`)
- CLI commands → SQLite store: reads status and history (evidence: `wfk/cli.py`)
- CLI commands → Replay checker: requests replay (evidence: `wfk/cli.py`)
- Replay checker → SQLite store: compares rebuilt state (evidence: `wfk/engine.py`)
- Fault wrappers → Ingest document: wraps tools (evidence: `wfk/faults.py`)
- Fault wrappers → File notifier: wraps sink (evidence: `wfk/faults.py`)
- Fault wrappers → SQLite store: crashes after commit (evidence: `wfk/faults.py`)
