Skip to content

Commit 39e1b5a

Browse files
intel352claude
andcommitted
docs: comprehensive documentation overhaul
- README.md: add pkg.go.dev badge, mermaid architecture diagram, wfctl install instructions, library usage section, documentation index - CLAUDE.md: new file with build/test commands, project structure, coding conventions, and documentation maintenance rules - docs/WFCTL.md: new comprehensive CLI reference for all 22 wfctl commands with flags, examples, and mermaid command tree diagram - DOCUMENTATION.md: update template functions from 9 to 30+ (add v0.3.9/v0.3.10 functions: upper, title, replace, contains, hasPrefix, hasSuffix, split, join, trimSpace, urlEncode, add, sub, mul, div, toInt, toFloat, toString, length, coalesce, config), add pipeline execution flow diagram, document step.hash and step.regex_match Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a5bf3f5 commit 39e1b5a

4 files changed

Lines changed: 1402 additions & 31 deletions

File tree

CLAUDE.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Configuration-driven workflow orchestration engine built in Go on the [modular](https://github.com/CrisisTextLine/modular) framework. Turns YAML configs into running applications — API servers, event pipelines, state machines, and more.
8+
9+
## Build & Run
10+
11+
```sh
12+
# Build the server
13+
go build -o server ./cmd/server
14+
./server -config example/api-server-config.yaml
15+
16+
# Build the CLI
17+
go build -o wfctl ./cmd/wfctl
18+
./wfctl validate example/api-server-config.yaml
19+
20+
# Run tests
21+
go test ./...
22+
go test -race ./...
23+
24+
# UI development
25+
cd ui && npm install && npm run dev
26+
27+
# Lint
28+
go fmt ./...
29+
golangci-lint run
30+
```
31+
32+
## Project Structure
33+
34+
- `cmd/server/` — Server binary entry point
35+
- `cmd/wfctl/` — CLI tool (validate, inspect, deploy, api extract, etc.)
36+
- `config/` — YAML config structs
37+
- `module/` — All module and pipeline step implementations
38+
- `handlers/` — Workflow handler types (HTTP, Messaging, StateMachine, Scheduler, Integration)
39+
- `plugins/` — Built-in engine plugins (auth, storage, pipeline-steps, etc.)
40+
- `plugin/` — Plugin SDK (EnginePlugin interface, factories, hooks)
41+
- `schema/` — JSON Schema generation for config validation
42+
- `dynamic/` — Yaegi hot-reload system
43+
- `ai/` — AI integration (Anthropic Claude, GitHub Copilot)
44+
- `ui/` — React + ReactFlow visual builder (Vite, TypeScript)
45+
- `example/` — Example YAML configs with companion .md docs
46+
- `deploy/` — Deployment configs (Docker, Kubernetes/Helm, OpenTofu/AWS)
47+
- `docs/` — Documentation (tutorials, ADRs, API reference)
48+
49+
## Key Conventions
50+
51+
- Module implementations live in `module/` with the naming pattern `module/<type>.go`
52+
- Pipeline steps follow `module/pipeline_step_<name>.go`
53+
- Template functions are registered in `module/pipeline_template.go` via `templateFuncMap()`
54+
- Module factories are registered in `engine.go` `BuildFromConfig()`
55+
- Plugin step/module factories are registered in `plugins/<name>/plugin.go`
56+
- wfctl commands each have their own file in `cmd/wfctl/<command>.go`
57+
- Tests follow standard Go conventions: `*_test.go` alongside source files
58+
59+
## Documentation Maintenance
60+
61+
**When adding new functionality, update the corresponding documentation:**
62+
63+
| Change | Update |
64+
|--------|--------|
65+
| New module type | `DOCUMENTATION.md` module table, `engine.go` factory registration |
66+
| New pipeline step | `DOCUMENTATION.md` step table, register in plugin or engine |
67+
| New template function | `DOCUMENTATION.md` template functions section, add to `templateFuncMap()` |
68+
| New wfctl command | `docs/WFCTL.md` command reference, update `main.go` usage() |
69+
| New trigger type | `DOCUMENTATION.md` trigger types section |
70+
| Config format change | `DOCUMENTATION.md` configuration section |
71+
72+
## Common Tasks
73+
74+
### Adding a New Module Type
75+
1. Create `module/<type>.go` implementing `modular.Module`
76+
2. Register factory in `engine.go` `BuildFromConfig()` or in a plugin's `ModuleFactories()`
77+
3. Add schema in the plugin's `ModuleSchemas()` or inline
78+
4. Add example YAML in `example/`
79+
5. Update `DOCUMENTATION.md`
80+
81+
### Adding a New Pipeline Step
82+
1. Create `module/pipeline_step_<name>.go` implementing the step interface
83+
2. Register in `plugins/pipelinesteps/plugin.go` `StepFactories()`
84+
3. Update `DOCUMENTATION.md`
85+
86+
### Adding a Template Function
87+
1. Add to `templateFuncMap()` in `module/pipeline_template.go`
88+
2. Add tests in `module/pipeline_template_test.go`
89+
3. Update `DOCUMENTATION.md` template functions section
90+
91+
## Links
92+
93+
- [Full Documentation](DOCUMENTATION.md)
94+
- [CLI Reference](docs/WFCTL.md)
95+
- [Deployment Guide](deploy/README.md)
96+
- [Tutorials](docs/tutorials/)
97+
- [Go Package Docs](https://pkg.go.dev/github.com/GoCodeAlone/workflow)

DOCUMENTATION.md

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
The Workflow Engine is a configuration-driven orchestration platform built in Go. It turns YAML configuration files into running applications with no code changes required. The engine provides 48+ built-in module types, a visual workflow builder UI, a multi-tenant admin platform, AI-assisted configuration generation, and dynamic hot-reload of Go components at runtime.
5+
The Workflow Engine is a configuration-driven orchestration platform built in Go. It turns YAML configuration files into running applications with no code changes required. The engine provides 50+ built-in module types, a visual workflow builder UI, a multi-tenant admin platform, AI-assisted configuration generation, and dynamic hot-reload of Go components at runtime.
66

77
## Core Engine
88

@@ -11,15 +11,15 @@ The engine is built on the [CrisisTextLine/modular](https://github.com/CrisisTex
1111
**Key capabilities:**
1212
- YAML-driven configuration with environment variable expansion (`${JWT_SECRET}`)
1313
- Config validation via JSON Schema
14-
- Module factory registry with 48 built-in types
14+
- Module factory registry with 50+ built-in types
1515
- Trigger-based workflow dispatch (HTTP, EventBus, cron schedule)
1616
- Graceful lifecycle management (start/stop)
1717

1818
**CLI tools:**
1919
- `cmd/server` -- runs workflow configs as a server process
2020
- `cmd/wfctl` -- validates and inspects workflow configs offline
2121

22-
## Module Types (48+)
22+
## Module Types (50+)
2323

2424
All modules are registered in `engine.go` and instantiated from YAML config. Organized by category:
2525

@@ -85,6 +85,28 @@ All modules are registered in `engine.go` and instantiated from YAML config. Org
8585
| `persistence.store` | Write-through persistence (SQLite/PostgreSQL) |
8686

8787
### Pipeline Steps
88+
89+
Pipeline execution flow:
90+
91+
```mermaid
92+
flowchart TD
93+
A[HTTP Request] --> B[Trigger]
94+
B --> C[WorkflowHandler]
95+
C --> D[PipelineContext\ncurrent / steps / trigger / meta]
96+
D --> E[Step 1\nresolve templates]
97+
E --> F{StepResult}
98+
F --> G[Merge output\ninto context]
99+
G --> H[Step 2\nresolve templates]
100+
H --> I{StepResult}
101+
I --> J[Merge output\ninto context]
102+
J --> K[... more steps ...]
103+
K --> L[Final Response]
104+
105+
style D fill:#f0f4ff,stroke:#4a6fa5
106+
style F fill:#e8f5e9,stroke:#388e3c
107+
style I fill:#e8f5e9,stroke:#388e3c
108+
```
109+
88110
| Type | Description |
89111
|------|-------------|
90112
| `processing.step` | Configurable processing step |
@@ -94,12 +116,42 @@ All modules are registered in `engine.go` and instantiated from YAML config. Org
94116
| `step.set` | Sets values in pipeline context with template support |
95117
| `step.log` | Logs pipeline data for debugging |
96118
| `step.publish` | Publishes events to EventBus |
119+
| `step.event_publish` | Publishes events to EventBus with full envelope control |
97120
| `step.http_call` | Makes outbound HTTP requests |
98121
| `step.delegate` | Delegates to a named service |
99122
| `step.request_parse` | Extracts path params, query params, and request body from HTTP requests |
100123
| `step.db_query` | Executes parameterized SQL SELECT queries against a named database |
101124
| `step.db_exec` | Executes parameterized SQL INSERT/UPDATE/DELETE against a named database |
125+
| `step.db_query_cached` | Executes a cached SQL SELECT query |
126+
| `step.db_create_partition` | Creates a time-based table partition |
127+
| `step.db_sync_partitions` | Ensures future partitions exist for a partitioned table |
102128
| `step.json_response` | Writes HTTP JSON response with custom status code and headers |
129+
| `step.raw_response` | Writes a raw HTTP response with arbitrary content type |
130+
| `step.static_file` | Serves a pre-loaded file from disk as an HTTP response |
131+
| `step.workflow_call` | Invokes another workflow pipeline by name |
132+
| `step.validate_path_param` | Validates a URL path parameter against a set of rules |
133+
| `step.validate_pagination` | Validates and normalizes pagination query params |
134+
| `step.validate_request_body` | Validates request body against a JSON schema |
135+
| `step.foreach` | Iterates over a slice and runs a sub-pipeline per element |
136+
| `step.webhook_verify` | Verifies an inbound webhook signature |
137+
| `step.base64_decode` | Decodes a base64-encoded field |
138+
| `step.cache_get` | Reads a value from the cache module |
139+
| `step.cache_set` | Writes a value to the cache module |
140+
| `step.cache_delete` | Deletes a value from the cache module |
141+
| `step.ui_scaffold` | Generates UI scaffolding from a workflow config |
142+
| `step.ui_scaffold_analyze` | Analyzes UI scaffold state for a workflow |
143+
| `step.dlq_send` | Sends a message to the dead-letter queue |
144+
| `step.dlq_replay` | Replays messages from the dead-letter queue |
145+
| `step.retry_with_backoff` | Retries a sub-pipeline with exponential backoff |
146+
| `step.resilient_circuit_breaker` | Wraps a sub-pipeline with a circuit breaker |
147+
| `step.s3_upload` | Uploads a file or data to an S3-compatible bucket |
148+
| `step.auth_validate` | Validates an authentication token and populates claims |
149+
| `step.token_revoke` | Revokes an auth token |
150+
| `step.field_reencrypt` | Re-encrypts a field with a new key |
151+
| `step.sandbox_exec` | Executes a command inside a sandboxed container |
152+
| `step.http_proxy` | Proxies an HTTP request to an upstream service |
153+
| `step.hash` | Computes a cryptographic hash (md5/sha256/sha512) of a template-resolved input |
154+
| `step.regex_match` | Matches a regular expression against a template-resolved input |
103155
| `step.jq` | Applies a JQ expression to pipeline data for complex transformations |
104156
| `step.ai_complete` | AI text completion using a configured provider |
105157
| `step.ai_classify` | AI text classification into named categories |
@@ -121,17 +173,60 @@ All modules are registered in `engine.go` and instantiated from YAML config. Org
121173

122174
Pipeline steps support Go template syntax with these built-in functions:
123175

124-
| Function | Description | Example |
125-
|----------|-------------|---------|
126-
| `uuidv4` | Generates a UUID v4 | `{{ uuidv4 }}` |
127-
| `now` | Current time (RFC3339 default, or named/custom layout) | `{{ now }}`, `{{ now "DateOnly" }}`, `{{ now "2006-01-02" }}` |
128-
| `lower` | Lowercase string | `{{ lower .name }}` |
129-
| `default` | Default value when empty | `{{ default "pending" .status }}` |
130-
| `json` | Marshal value to JSON string | `{{ json .data }}` |
131-
| `trimPrefix` | Remove prefix from string | `{{ .phone | trimPrefix "+" }}` |
132-
| `trimSuffix` | Remove suffix from string | `{{ .file | trimSuffix ".txt" }}` |
133-
| `step` | Access step outputs by name and keys | `{{ step "parse-request" "path_params" "id" }}` |
134-
| `trigger` | Access trigger data by keys | `{{ trigger "path_params" "id" }}` |
176+
#### Core
177+
178+
| Function | Signature | Description |
179+
|----------|-----------|-------------|
180+
| `uuid` | `uuid` | Generate UUID v4 |
181+
| `uuidv4` | `uuidv4` | Generate UUID v4 (alias for `uuid`) |
182+
| `now` | `now [layout]` | Current UTC time (default RFC3339); accepts named constants (`RFC3339`, `DateOnly`, etc.) or a Go layout string |
183+
| `lower` | `lower STRING` | Lowercase |
184+
| `default` | `default FALLBACK VALUE` | Return fallback if value is nil/empty |
185+
| `json` | `json VALUE` | Marshal to JSON string |
186+
| `config` | `config KEY` | Look up a value from the config registry (populated by a `config.provider` module) |
187+
188+
#### String
189+
190+
| Function | Signature | Description |
191+
|----------|-----------|-------------|
192+
| `upper` | `upper STRING` | Uppercase |
193+
| `title` | `title STRING` | Title case (first letter of each word capitalized) |
194+
| `replace` | `replace OLD NEW STRING` | Replace all occurrences of OLD with NEW |
195+
| `contains` | `contains SUBSTR STRING` | Check if STRING contains SUBSTR |
196+
| `hasPrefix` | `hasPrefix PREFIX STRING` | Check if STRING starts with PREFIX |
197+
| `hasSuffix` | `hasSuffix SUFFIX STRING` | Check if STRING ends with SUFFIX |
198+
| `split` | `split SEP STRING` | Split STRING by SEP into a slice |
199+
| `join` | `join SEP SLICE` | Join slice elements with SEP |
200+
| `trimSpace` | `trimSpace STRING` | Trim leading and trailing whitespace |
201+
| `trimPrefix` | `trimPrefix PREFIX STRING` | Remove PREFIX from STRING if present |
202+
| `trimSuffix` | `trimSuffix SUFFIX STRING` | Remove SUFFIX from STRING if present |
203+
| `urlEncode` | `urlEncode STRING` | URL percent-encode a string |
204+
205+
#### Math
206+
207+
| Function | Signature | Description |
208+
|----------|-----------|-------------|
209+
| `add` | `add A B` | Addition (int if both ints, float64 otherwise) |
210+
| `sub` | `sub A B` | Subtraction |
211+
| `mul` | `mul A B` | Multiplication |
212+
| `div` | `div A B` | Division as float64; returns 0 on divide-by-zero |
213+
214+
#### Type / Utility
215+
216+
| Function | Signature | Description |
217+
|----------|-----------|-------------|
218+
| `toInt` | `toInt VALUE` | Convert to int64 |
219+
| `toFloat` | `toFloat VALUE` | Convert to float64 |
220+
| `toString` | `toString VALUE` | Convert to string |
221+
| `length` | `length VALUE` | Length of string, slice, array, or map |
222+
| `coalesce` | `coalesce VAL1 VAL2 ...` | First non-nil, non-empty value |
223+
224+
#### Context (added per-pipeline by the engine)
225+
226+
| Function | Signature | Description |
227+
|----------|-----------|-------------|
228+
| `step` | `step NAME KEY...` | Access a prior step's output by step name and nested keys |
229+
| `trigger` | `trigger KEY...` | Access trigger data by keys |
135230

136231
#### Template Data Context
137232

README.md

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Go](https://img.shields.io/badge/Go-1.26+-00ADD8?logo=go&logoColor=white)](https://go.dev)
44
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
55
[![Built on Modular](https://img.shields.io/badge/Built%20on-CrisisTextLine%2Fmodular-green)](https://github.com/CrisisTextLine/modular)
6+
[![Go Reference](https://pkg.go.dev/badge/github.com/GoCodeAlone/workflow.svg)](https://pkg.go.dev/github.com/GoCodeAlone/workflow)
67

78
A production-grade, configuration-driven workflow orchestration engine built on [CrisisTextLine/modular](https://github.com/CrisisTextLine/modular) v1.11.11. Define entire applications in YAML -- from API servers to multi-service chat platforms -- with 48+ module types, dynamic hot-reload, AI-powered generation, and a visual builder UI.
89

@@ -161,6 +162,40 @@ cd example/ecommerce-app
161162
docker compose up
162163
```
163164

165+
## CLI Tool (wfctl)
166+
167+
`wfctl` is a command-line tool for inspecting, validating, and generating workflow configurations.
168+
169+
**Install from GitHub Releases:**
170+
```bash
171+
curl -sL https://github.com/GoCodeAlone/workflow/releases/latest/download/wfctl-$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') -o wfctl && chmod +x wfctl
172+
```
173+
174+
**Install from source:**
175+
```bash
176+
go install github.com/GoCodeAlone/workflow/cmd/wfctl@latest
177+
```
178+
179+
**Commands:**
180+
- `wfctl inspect <config.yaml>` — summarize modules, workflows, triggers, and dependencies
181+
- `wfctl validate <config.yaml>` — deep validation against known module/step types
182+
- `wfctl api-extract <config.yaml>` — generate OpenAPI 3.0 spec from HTTP workflows
183+
- `wfctl diff <old.yaml> <new.yaml>` — compare configs and detect breaking changes
184+
- `wfctl manifest <config.yaml>` — produce infrastructure requirements manifest
185+
- `wfctl scaffold --modules <types>` — generate a skeleton config for given module types
186+
187+
See [docs/WFCTL.md](docs/WFCTL.md) for the full CLI reference.
188+
189+
## Library Usage
190+
191+
Use the workflow engine as a Go library:
192+
193+
```go
194+
go get github.com/GoCodeAlone/workflow@latest
195+
```
196+
197+
See the [Go package documentation](https://pkg.go.dev/github.com/GoCodeAlone/workflow) for API reference.
198+
164199
## Example Applications
165200

166201
### Chat Platform -- Production-Grade Mental Health Support
@@ -208,23 +243,30 @@ Each example includes a companion `.md` file documenting its architecture and us
208243

209244
## Architecture
210245

211-
```
212-
cmd/server/ Server binary, HTTP mux, graceful shutdown
213-
main.go Entry point with CLI flags and AI provider init
214-
215-
config/ YAML config structs (WorkflowConfig, ModuleConfig)
216-
module/ 65+ built-in module implementations
217-
handlers/ 5 workflow handler types:
218-
HTTP, Messaging, StateMachine, Scheduler, Integration
219-
dynamic/ Yaegi-based hot-reload system
220-
ai/ AI integration layer
221-
llm/ Anthropic Claude direct API with tool use
222-
copilot/ GitHub Copilot SDK with session management
223-
service.go Provider selection and orchestration
224-
deploy.go Validation loop and deployment to dynamic components
225-
ui/ React + ReactFlow + Zustand visual builder (Vite, TypeScript)
226-
example/ Top-level example YAML configs and full application examples
227-
mock/ Test helpers and mock implementations
246+
```mermaid
247+
graph TD
248+
A[YAML Config] --> B[StdEngine / BuildFromConfig]
249+
B --> C[Module Factories]
250+
C --> D[Modules]
251+
D --> E[Application\nDependency Injection]
252+
253+
E --> F[Workflow Handlers]
254+
F --> F1[HTTP]
255+
F --> F2[Messaging]
256+
F --> F3[StateMachine]
257+
F --> F4[Scheduler]
258+
F --> F5[Integration]
259+
260+
G[Triggers] --> G1[HTTP Endpoints]
261+
G --> G2[EventBus Subscriptions]
262+
G --> G3[Cron Schedules]
263+
264+
G1 --> H[TriggerWorkflow]
265+
G2 --> H
266+
G3 --> H
267+
H --> I[Handler Dispatch]
268+
I --> J[Pipeline Execution]
269+
J --> J1[Steps: validate, transform,\nconditional, http_call, db_query...]
228270
```
229271

230272
**Core flow:**
@@ -299,6 +341,13 @@ cd ui && npm run lint
299341
| Containers | Docker multi-stage builds, Docker Compose |
300342
| Testing | Go testing, Vitest, Playwright |
301343

344+
## Documentation
345+
346+
- [DOCUMENTATION.md](DOCUMENTATION.md) — Full module, step, and template reference
347+
- [docs/WFCTL.md](docs/WFCTL.md) — CLI tool reference
348+
- [deploy/README.md](deploy/README.md) — Deployment guide
349+
- [docs/tutorials/](docs/tutorials/) — Getting started and walkthrough tutorials
350+
302351
## Roadmap
303352

304353
See [ROADMAP.md](ROADMAP.md) for the full development history (Phases 1-6 complete) and planned work including JSON Schema config validation, performance benchmarks, Helm charts, and security hardening.

0 commit comments

Comments
 (0)