Skip to main content
Version: 0.1.0-alpha.2

C4 Container Diagram (C2)

This diagram zooms into Invowk to show its internal containers - the major applications, components, and data stores that make up the system.

note

In C4 terminology, "container" refers to a separately runnable/deployable unit (not Docker containers). Since Invowk is a single CLI binary, we show the major internal components as logical containers.

Diagram

Diagram: architecture/c4-container

Internal Components

Entry Points

ComponentTechnologyResponsibility
CLI CommandsGo/CobraEntry points for all user interactions: cmd, init, config, module, tui, completion subcommands

Core Engine

ComponentTechnologyResponsibility
Discovery EngineGoFinds invkfile.cue and *.invkmod directories with precedence ordering. Builds unified command tree.
Configuration ManagerGo/Viper+CUELoads config from ~/.config/invowk/config.cue. Validates against CUE schema.
CUE ParserGo/cuelangImplements 3-step parsing: compile schema → unify with data → decode to Go structs. Provides rich error messages.
Module ResolverGoResolves Git-based dependencies. Manages cache at ~/.invowk/modules/. Handles lock files for reproducibility.

Runtimes

ComponentTechnologyResponsibility
Native RuntimeGoExecutes commands via host shell (bash/sh on Unix, PowerShell on Windows). Fastest option.
Virtual RuntimeGo/mvdan-shEmbedded POSIX shell interpreter. Includes u-root builtins for portability. No host shell dependency.
Container RuntimeGoExecutes commands inside Docker/Podman containers. Provides isolation and reproducibility.

Container Infrastructure

ComponentTechnologyResponsibility
Container Engine AbstractionGoUnified interface for Docker and Podman. Auto-detects available engine with fallback.
Image ProvisionerGoCreates ephemeral image layers containing invowk binary and required modules. Enables seamless container execution.

Servers

ComponentTechnologyResponsibility
SSH ServerGo/WishToken-based SSH server for container-to-host callbacks. Enables enable_host_ssh feature.
TUI ServerGo/Bubble TeaHTTP server handling TUI component requests from child processes. Enables interactive prompts in any runtime.

Data Stores

StoreFormatLocationPurpose
Config FileCUE~/.config/invowk/config.cueUser preferences: container engine, search paths, etc.
InvkfilesCUE./invkfile.cue, search pathsCommand definitions with implementations
ModulesDirectories*.invkmod/Packaged commands with invkmod.cue metadata
Module CacheFilesystem~/.invowk/modules/Cached Git-fetched remote modules

Component Interactions

Command Execution Flow

  1. User invokes invowk cmd <name>
  2. CLI Commands receives request
  3. Discovery Engine finds all available commands
  4. CUE Parser parses invkfile.cue and module files
  5. Command is matched, runtime is selected
  6. Appropriate Runtime executes the command
  7. For containers: Image Provisioner prepares the environment

Configuration Loading

  1. Configuration Manager checks for config file
  2. CUE Parser validates against schema
  3. Config values influence runtime selection and behavior

Module Resolution

  1. Discovery Engine finds module requirements
  2. Module Resolver checks cache, fetches from Git if needed
  3. Dependencies are resolved transitively
  4. Commands from required modules become available

Design Rationale

Why Three Runtimes?

RuntimeUse CaseTrade-off
NativeSpeed, full shell featuresPlatform-dependent
VirtualPortability, no shell dependencyLimited shell features
ContainerIsolation, reproducibilityOverhead, Linux only

Why Separate Servers?

  • SSH Server: Enables commands inside containers to call back to the host (e.g., for secrets management)
  • TUI Server: Allows any subprocess (native, virtual, container) to request interactive UI components

Why CUE for Configuration?

  • Schema validation built-in
  • Type checking before runtime
  • Composable configurations
  • Better error messages than YAML/JSON