Skip to main content

Architectural Layers

1. Application Layer (engine.go, engine/domain/application.go)

The entry point that initializes the application and coordinates all components.

type Application struct {
EngineName string
Env *Environment
EmbedFS embed.FS
EmbedFSRootPath string
}

Responsibilities:

  • Initialize dependency injection
  • Fetch environment configuration
  • Provide application-wide context

2. Bootstrap Layer (boot/)

Handles system initialization, environment setup, and dependency injection configuration.

FilePurpose
bootstrap.goMain DI container initialization
env.goEnvironment and configuration loading
services.goService registration
entities.goEntity configuration
transitions.goTransition handlers
helpers.goBootstrap utilities
enable.goFeature enablement

Key Functions:

  • DependencyInjection(): Initializes the DI container
  • InitializeEnvironment(): Loads configuration from .env and INI files
  • LoadConfig(): Parses configuration files

3. Core Layer (engine/)

Contains domain models, helpers, and foundational services.

Domain Models (engine/domain/)

ModelDescription
FlowRepresents a workflow execution context
FlowStateIndividual state in a workflow
FlowTransitionTransition between states
FlowStepResultResult of a state transition
ConfigApplication configuration
WorkflowWorkflow definition

Helpers (engine/helpers/)

Utility functions for common operations:

  • String manipulation
  • Map merging
  • Type assertions
  • File operations
  • Memory management
  • Logging

Services (engine/services/)

  • atomic/: Atomic operations
  • caches/: Caching implementations

4. Workflow Engine Layer (engine/workflow/)

The heart of the engine that executes workflows.

ComponentDescription
engine.goMain workflow engine implementation
worker.goWorker that processes workflow states
worker_context.goContext management for workers
worker_session_context.goSession-scoped context
handle_workflow.goWorkflow handling logic
run_sync.goSynchronous execution
run_async.goAsynchronous execution
wsl_integration.goWSL to engine integration

5. WSL Layer (internal/wsl/)

The Workflow Specification Language compiler and runtime.

ComponentDescription
lexer.goTokenizes WSL source code
tokens.goToken definitions
parser.goParses tokens into CST
cst.goConcrete Syntax Tree
build_ast.goBuilds Abstract Syntax Tree
ast.goAST node definitions
ir.goIntermediate Representation (Graph)
api.goPublic API for parsing
errors.goError handling

6. Module System (modules/)

Extensible plugin architecture for custom functionality.

modules/
├── di.go # Dependency injection for modules
├── modules.go # Module registration
├── meta.go # Module metadata
├── converse/ # Example: conversation module
│ └── transitions/ # Transition handlers
└── services/ # Service modules
└── common/ # Common services
└── transitions/

7. Event System (event/)

Event-driven communication using an event bus pattern.

// event/bus.go
var Bus EventBus.Bus

func init() {
Bus = EventBus.New()
}