Technical reference
Everything you need to define, generate, and govern architecture with HexaGen Monaco.
Quick Start
HexaGen Monaco is a monorepo that generates monorepos. Clone, install, and build your own governance engine in under a minute.
git cloneClone the monorepo: git clone git@github.com:martinkrakowski/hexagen-monaco.git
cd hexagen-monacoEnter the project directory
corepack enableEnable Yarn 4 via corepack
yarn installInstall all dependencies across all packages
yarn buildBuild all 27 packages in parallel via Turborepo
yarn syncGenerate hexagonal boilerplate from manifest. Idempotent — safe to run twice.
yarn sync:dryPreview changes without writing files
yarn sync:forceOverwrite non-generated files (hand-written code)
yarn lintRun ESLint on all packages + architecture validation
yarn lint:archValidate manifest against boundary rules. Add to CI.
yarn typecheckTypeScript type checking across all packages
Manifest Schema
The manifest at .architecture/manifest.yaml is the single source of truth for your system topology. It declares bounded contexts, ports, adapters, layer rules, and module types. Every generated file and governance rule derives from this file.
systemProject identifier used in generated package names and @hexagen/* path aliases.
scopeNPM scope for packages (e.g. @hexagen).
architectureArchitecture style: 'modular-monolith' (currently supported).
monorepoMonorepo config: packageManager, workspaces, ESLint, TypeScript settings.
modulesArray of module declarations (see below).
The monorepo object configures Yarn 4, Turborepo, ESLint, and TypeScript. It defines workspaces, build rules, and path aliases for the entire project.
nameModule name in kebab-case. Used for directory and package naming.
typeOne of "core" | "supporting" | "driver" | "shared-kernel". Governance strictness varies.
portsDeclared port interfaces (e.g. ProjectGeneratorPort). Generates TS interfaces.
adaptersAdapter implementations for declared ports.
entitiesDomain entities in this module.
use_casesApplication use cases orchestrated by this module.
layersLayer stack override — e.g. ["domain", "application", "infrastructure"].
coreNo outbound dependencies. Only ports exposed. Innermost boundary.
supportingMay depend on core. Must use ports. Infrastructure implementations live here.
driverUI adapters, controllers, entry points. Depends on all other types.
shared-kernelTypes and utilities only. Can be imported by any module.
CLI Commands
HexaGen Monaco exposes a small, deterministic CLI surface. Every command is idempotent — running it twice produces the same result.
yarn syncRead manifest → generate hexagonal boilerplate. Idempotent.
yarn buildTurborepo-parallelized build across all packages. Incremental.
yarn devStart development mode with hot reload for Web UI and TUI.
yarn testRun Vitest across the monorepo. Supports --watch, --coverage.
yarn sync:dryPreview changes without writing files. Shows diffs.
yarn sync:forceOverwrite non-generated files (hand-written code).
yarn sync:strictFail on linter warnings.
yarn lintRun ESLint on all packages + architecture validation.
yarn lint:archValidate manifest against boundary rules. Add to CI pipelines.
yarn typecheckTypeScript across all packages.
yarn validateRun purity + boundary validation.
yarn formatFormat all TypeScript, Markdown, and JSON via Prettier.
Project Structure
HexaGen Monaco has 27 packages across 3 workspace roots plus 1 tool. All governed by the single manifest.
apps/webNext.js web UI with Monaco Editor + React Flow canvas. Main entry point.
apps/tuiTerminal UI built with Ink. Three-pane layout with navigation, rule engine, violation inspector.
apps/api-gatewayExpress-based API gateway for generated projects.
project-configurationManifest parsing and system topology.
code-generationManifest compiler. Generates hexagonal boilerplate.
architectural-enforcementRisk mitigation. Dependency linting + boundary validation.
core-domainDomain entities, value objects, use cases.
syncCLI for artifact generation. The yarn sync command.
governancePrompt compilation, rule engine, layer constraints.
mcp-serverMCP server exposing arch tools over stdio. For AI agents.
persistenceLifecycle engine. Tracks architectural evolution.
visualizationInteractive graph. Renders module→port→adapter mappings.
monaco-orchestrationAST-based patching. ts-morph with confidence scoring.
wizard-orchestrationUI engine. Intent → Use Case → Projection pipeline.
tools/arch-linterArchitecture validation tool. Validates manifest against rules.
.architecture/invariants/Custom rules as TypeScript functions asserting constraints.
Terminal UI
The TUI (apps/tui) is a full-featured terminal dashboard built with Ink (React for CLIs). It provides keyboard-driven architecture management from the command line.
Navigation treeModule and port browser. Navigate bounded contexts.
Rule engineActive invariants and layer constraints.
Violation inspectorBoundary breaches with contextual refactoring suggestions.
j / kNavigate up/down in the current pane.
TabSwitch between panes.
rRoute context to MCP server for AI-assisted refactoring.
uRefresh / update the view.
qQuit the TUI.
Filesystem watching keeps all three panes live. The dashboard updates when the manifest or dependency graph changes without manual refresh.
Web UI & Canvas
The Web UI (apps/web) provides a visual architecture canvas for navigating bounded contexts, ports, adapters, and dependency flows. Built with Next.js and React Flow.
Bounded context nodesEach module renders as a hexagonal node on the graph.
Port adaptersDependencies flow between contexts visualized as edges.
Drag & zoomPan and zoom the canvas to explore large architectures.
Detail panelsClick nodes to view port/adapter details.
The manifest can be edited directly in the browser via Monaco Editor with syntax highlighting and semantic validation.
Monaco Orchestration (packages/monaco-orchestration) uses ts-morph for semantic patching. Confidence scoring gates mutations based on structural certainty.
MCP Server
The MCP Server (packages/mcp-server) exposes architectural tools over stdio transport. AI agents like Claude Code, Copilot, or any MCP-compatible client can interact with the manifest programmatically.
auditAudit architecture boundaries and report violations.
scaffoldScaffold new bounded contexts, ports, or adapters.
diffShow manifest changes between commits.
governance readQuery active invariants and layer constraints.
When the TUI detects a boundary violation, pressing 'r' routes the context to the MCP server for AI-assisted refactoring. The LLM is modeled behind a port (LLMProviderPort), making it swappable and testable.
The agentic-interaction bounded context treats AI as infrastructure behind a port. LLMProviderPort abstracts OpenAI, Anthropic, local WebLLM, or future providers without coupling domain code to a specific provider.
Governance Rules
Governance is enforced at build time, not post-deploy. Three complementary mechanisms catch architectural violations before they reach production.
ESLint BoundariesImport restriction rules prevent cross-boundary access. Configured per manifest.
ts-morph ASTStructural analysis verifies generated hexagonal interfaces remain intact.
Manifest InvariantsCustom rules in .architecture/invariants/ — TypeScript functions asserting constraints on the manifest itself.
coreNo outbound dependencies. Only declared ports exposed.
supportingMay depend on core modules. Must go through ports.
driverEntry points. Can depend on all other types.
shared-kernelTypes only. Importable by any module.
Add 'yarn lint:arch' to your CI pipeline. The architecture linter runs in ~500ms and catches boundary violations on every commit.
Architecture Patterns
Every module follows the ports-and-adapters pattern. Domain logic sits at the center with no framework dependencies. External systems connect through declared port interfaces.
domainPure business logic, no I/O, no framework imports. Innermost ring.
applicationUse cases / orchestration. Depends on domain + port interfaces.
infrastructureAdapters — databases, HTTP clients, framework bindings. Implements ports.
Dependencies point inward only. Infrastructure → Application → Domain. Domain depends on nothing. Violations caught by yarn lint:arch.
Wizard Orchestration routes every user interaction through I→U→P: Intent (entry), Use Case (system action), Projection (UI render). Intent is the only entry point; projections are pure.
The LLM is modeled behind LLMProviderPort in agentic-interaction. This makes the inference layer swappable, testable, and incapable of leaking into domain logic.
Need more detail?
The full source code, examples, and advanced configuration options are available on GitHub.