# enactprotocol/enact architecture

> Architecture diagram of the GitHub repository enactprotocol/enact, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enactprotocol/enact
- Repository: https://github.com/enactprotocol/enact

## Overview

##### Project type and purpose
- Enact CLI is a **monorepo** providing:
- A **command-line interface** (CLI) for packaging, signing, discovering, and executing AI tools
- A minimal **MCP (Model Context Protocol) server** exposing tool execution over HTTP + a built-in web UI for environment management
- A **shared library** that implements core logic, security, and pluggable execution providers

##### File structure
- Top-level:
- `packages/cli` – CLI commands and entry point (`src/index.ts`)
- `packages/mcp-server` – HTTP server & MCP handlers (`src/mcp/server.ts`)
- `packages/shared` – Core services, API clients, exec providers, security, web-static assets
- Support files:
- `docs/` – design & usage docs
- `examples/` – sample tool YAMLs
- `scripts/` – build, deploy, test helpers
- Config: Bun (`bunfig.toml`), TypeScript (`tsconfig.json`), npm (`package.json`)

##### Extract architecture details from README
- **Execution providers**:
- **Dagger** (containerized) – default for running external tools
- **Direct** (host) – for fast CLI operations
- **Security**: cryptographic signing + verification before execution
- **MCP server**: exposes 7 core tools via MCP protocol + serves static web UI at port 5555
- **External dependencies**:
- Enact Registry HTTP API
- Dagger engine (container runtime)
- File system (for local tools, cache, `.env`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    CLI["Enact CLI"]:::cli
    click CLI "https://github.com/enactprotocol/enact/blob/main/packages/cli/src/index.ts"
    click CLI "https://github.com/enactprotocol/enact/blob/main/packages/cli/src/commands/*.ts"

    %% Server Layer
    MCP["MCP Server @ :5555"]:::server
    click MCP "https://github.com/enactprotocol/enact/blob/main/packages/mcp-server/src/index.ts"
    click MCP "https://github.com/enactprotocol/enact/blob/main/packages/mcp-server/src/mcp/server.ts"
    click MCP "https://github.com/enactprotocol/enact/blob/main/packages/mcp-server/src/minimal.ts"

    %% Shared Library
    subgraph "Shared Library" 
        direction TB
        Core["EnactCore"]:::lib
        click Core "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/core/index.ts"
        DaggerProv["Dagger Execution Provider"]:::lib
        click DaggerProv "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/core/DaggerExecutionProvider.ts"
        DirectProv["Direct Execution Provider"]:::lib
        click DirectProv "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/core/DirectExecutionProvider.ts"
        Security["Security Module"]:::lib
        click Security "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/security/security.ts"
        APIClient["Enact API Client"]:::lib
        click APIClient "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/api/index.ts"
        McpService["MCP Core Service"]:::lib
        click McpService "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/services/McpCoreService.ts"
        LocalResolver["Local FS Resolver"]:::lib
        click LocalResolver "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/LocalToolResolver.ts"
        WebUIComp["Env Manager Web UI"]:::lib
        click WebUIComp "https://github.com/enactprotocol/enact/blob/main/packages/shared/src/web/index.ts"
    end

    %% Execution Providers Resources
    DaggerDaemon[(Dagger Daemon)]:::external
    FileSystem[(Local File System)]:::resource

    %% External Services
    Registry[(Enact Registry API)]:::external

    %% Web Browser
    Browser["Web Browser"]:::external

    %% Relationships
    CLI -->|"uses Core"| Core
    CLI -->|"reads/writes"| FileSystem
    CLI -->|"search→registry"| Registry
    Core -->|"exec→"| DaggerProv
    Core -->|"exec→"| DirectProv
    DaggerProv -->|"exec→container"| DaggerDaemon
    DirectProv -->|"exec→host"| FileSystem
    Core -->|"sign/verify"| Security
    Core -->|"api calls"| APIClient
    MCP -->|"uses MCP Ops"| McpService
    MCP -->|"serves UI"| WebUIComp
    WebUIComp -->|"static files"| Browser
    Browser -->|"HTTP"| MCP
    McpService -->|"exec→"| Core
    McpService -->|"fs ops"| FileSystem

    %% Styles
    classDef cli fill:#e0f8e9,stroke:#2d8f5f,color:#2d8f5f
    classDef server fill:#e8f4fa,stroke:#4a90e2,color:#4a90e2
    classDef lib fill:#fff7e6,stroke:#f5a623,color:#f5a623
    classDef external fill:#fdecea,stroke:#d64541,color:#d64541
    classDef resource fill:#f0f0f0,stroke:#888888,color:#888888
```
