System Overview
High-level architecture, data flow, and component relationships
Architecture Diagram
The complete data flow from CLI invocation through workflow execution to node management and external integrations.
Execution Flow
When you run merobox run workflow.yaml, the following sequence occurs:
Parse & Validate
YAML file is loaded, environment variables (${ENV_VAR}) are expanded, and the workflow schema is validated. Node definitions and step sequences are extracted.
Nuke (optional)
If the workflow or CLI flags request it, all existing Docker containers and volumes matching the merobox prefix are removed. Binary processes are killed via PID files.
Image Pull
Docker images for merod are pulled (or verified to exist locally). The image tag comes from the workflow YAML or defaults.
NEAR Sandbox Start
If the workflow uses NEAR integration, SandboxManager downloads (if needed) and starts a local near-sandbox process. Waits for RPC readiness.
Contract Deploy
Smart contracts referenced by the workflow are resolved (path or URL), compiled if needed, and deployed to the NEAR Sandbox via NearDevnetClient.
Node Startup
NodeResolver determines the backend for each node. DockerManager creates containers (with Traefik routing) or BinaryManager spawns native merod processes. Config TOML is generated per node.
Remote Registration
If remote nodes are declared, RemoteNodeManager registers them via the portal API. AuthManager handles JWT authentication for each node.
Step Execution
Steps run sequentially (or in parallel for parallel steps). Each step resolves placeholders, executes via calimero-client-py JSON-RPC, and stores results in workflow_results.
Cleanup
On success or failure, cleanup runs: containers are stopped/removed, binary processes are killed, sandbox is shut down, and temporary files are cleaned.
Component Responsibilities
WorkflowExecutor
- Orchestrates the full lifecycle from YAML to completion
- Manages workflow_results dictionary
- Resolves placeholders and dynamic values between steps
- Handles step factory for creating step instances
- Coordinates cleanup on both success and failure paths
NodeResolver
- Determines backend for each declared node
- Resolution chain: registered remote → URL → Docker → binary
- Integrates AuthManager for authenticated endpoints
- Integrates RemoteNodeManager for portal registration
- Returns resolved node endpoints for step execution
AuthManager
- Manages JWT authentication tokens per node
- Calls /auth/token and /auth/refresh endpoints
- Implements disk-based token cache for persistence
- Handles automatic token refresh on expiry
Config System
- YAML workflow files with ${ENV_VAR} expansion
- TOML config for merod node configuration
- Bootstrap node injection (apply_bootstrap_nodes)
- E2E defaults (apply_e2e_defaults)
- NEAR devnet config (apply_near_devnet_config_to_file)
External Dependencies
calimero-client-py
JSON-RPC client library for communicating with merod nodes. Used by steps to execute methods, query state, and manage contexts.
library
Docker SDK (docker-py)
Python Docker API for container lifecycle management. Used by DockerManager for creating, starting, stopping, and removing containers.
library
aiohttp
Async HTTP client/server framework. Used for health checks, sandbox RPC communication, and async workflow execution.
library
py-near
Python NEAR SDK for account management, key operations, and contract interactions with the NEAR sandbox.
library
Click
CLI framework providing command groups, argument parsing, options, and help generation for all merobox commands.
cli
PyYAML
YAML parsing library for reading workflow definition files and configuration.
library