High-Level Architecture
Execution Flow
Layer Responsibilities
CLI / API Layer
Location:pkg/cli/, pkg/server/
- Parse command-line arguments
- Handle REST API requests
- Validate user input
- Initiate workflow execution
- Return results to user
Executor Layer
Location:internal/executor/
Components:
- Executor (
executor.go) - Orchestrates workflow execution - StepDispatcher (
dispatcher.go) - Routes steps to appropriate handlers - Step Executors - Handle specific step types:
BashExecutor- Shell commandsFunctionExecutor- Utility functionsForeachExecutor- Loop iterationParallelExecutor- Concurrent stepsRemoteBashExecutor- Per-step Docker/SSHHTTPExecutor- HTTP requestsLLMExecutor- AI-powered steps
- Initialize execution context
- Inject built-in variables
- Dispatch steps to handlers
- Process exports and conditions
- Handle errors and decision routing
Runner Layer
Location:internal/runner/
Interface:
- HostRunner - Local shell execution (
sh -c) - DockerRunner - Container execution (ephemeral or persistent)
- SSHRunner - Remote SSH execution
Support Systems
Template Engine (internal/template/)
- Renders
{{variable}}and[[variable]]syntax - Provides value generators (UUID, date, etc.)
internal/functions/)
- Otto JavaScript VM for function evaluation
- Built-in functions for file, string, JSON operations
internal/scheduler/)
- Cron-based scheduling
- Event-driven triggers
- File watch triggers
Data Layer
Parser/Loader (internal/parser/)
- YAML parsing and validation
- Workflow caching
- Name resolution
internal/database/)
- SQLite (default) and PostgreSQL support
- Bun ORM for data access
- Repository pattern for queries
internal/workspace/)
- Workspace directory creation
- Output path management
Project Structure
Key Data Types
Defined ininternal/core/:
Execution Context
TheExecutionContext carries state through the execution pipeline:
- Variables - Set by executor (Target, Output, threads, etc.)
- Params - Provided by user via CLI or API
- Exports - Step outputs that propagate to subsequent steps