# cplieger/vibekit architecture

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

- Interactive diagram: https://gitdiagram.com/cplieger/vibekit
- Repository: https://github.com/cplieger/vibekit

## Overview

1. **Top-level shape**
   Vibekit is a two-part system: a Go backend that owns all state and orchestration, and a TypeScript frontend under `static-src` that renders a live UI from server events. The server is the source of truth; the browser never mutates state locally except by sending commands.

2. **Primary runtime and entrypoints**
   The Go app starts from `main.go` / `cmd/wire-codegen`, with the main server code in `internal/server`. The repo also builds a container image and includes `compose.yaml`, so deployment is typically a single self-hosted service exposing one HTTP port.

3. **Core interaction loop**
   The user interface sends mutations as `POST /api/command`-style requests, and the server broadcasts resulting state changes back to all connected clients over Server-Sent Events. This fan-out model is what enables multi-device, multi-tab synchronization without local optimistic state.

4. **Chat orchestration center**
   `internal/hub` is the central application coordinator. It ties together chat state, command dispatch, terminal sessions, SSE streaming, permissions, model switching, pending actions, and bridge lifecycle management. If you are drawing the architecture, this is the main hub connecting most subsystems.

5. **Agent bridge to Kiro**
   Each active chat owns a `kiro-cli acp` subprocess, managed by `internal/bridge`. This bridge converts between Vibekit’s internal command/event model and the Agent Client Protocol used by Kiro, and it streams model output, tool calls, and lifecycle events back into the hub.

6. **Persistent chat and replay state**
   `internal/chat`, `internal/buffer`, `internal/sessions`, and `internal/dedup` implement chat storage, buffering, history retention, and replay behavior. The README describes one JSON file per chat with atomic writes, and the code tree shows dedicated archive/purge paths for retention and cleanup.

7. **Workspace, files, and editor boundaries**
   `internal/filehandler`, `internal/fileutil`, `internal/workspace`, `internal/steering`, and parts of `internal/hub` handle filesystem access into `/workspace`. The frontend’s editor, diff, conflict, and file-browser modules mirror these server-side capabilities, but the server remains the gatekeeper for reads, writes, staging, and conflict handling.

8. **Checkpoint and restore subsystem**
   `internal/checkpoint` implements a content-addressed snapshot system for workspace files, including indexing, diffing, restore, and garbage collection. This is separate from git: it supports atomic per-file restore and cross-chat conflict detection, so it should be shown as its own storage/restore boundary.

9. **Supervised write gate and pending operations**
   In supervised mode, file writes are not applied directly. Instead they flow through `internal/pending`, `internal/permissions`, and hub-side staging logic so the user can accept/reject/merge at a per-hunk level before changes touch disk. This is a distinct control point between agent output and filesystem mutation.

10. **Git and forge integrations**
   `internal/git`, `internal/gitexec`, `internal/forges`, and `internal/steering` cover repository introspection plus GitHub/GitLab/Gitea workflows. The system can inspect branches, commits, PRs, and sync state, and it uses first-party CLIs such as `gh`, `glab`, and `tea` through forge adapters and auth flows.

11. **Authentication and identity**
   `internal/auth` manages login, logout, and who-am-I flows for the web UI, while `TRUSTED_PROXIES` affects how client IPs are resolved for audit logs. This is an application-level auth boundary; it protects the UI, but it does not reduce the underlying power of the agent over shell and workspace access.

12. **MCP and tool ecosystem**
   `internal/mcp` plus hub-side MCP registry code manage Model Context Protocol server configuration, persistence, and prewarming. The frontend has dedicated MCP screens, but on the backend MCP is treated as a registry and routing concern for tools exposed to the agent.

13. **Live terminal and subprocess control**
   `internal/hub` and `internal/command` coordinate a real browser terminal, per-agent command terminals, shell execution, and slash-command style actions. The server owns the PTY/subprocess lifecycle; the browser is only a transport and display layer.

14. **Push notifications and external delivery**
   `internal/push` handles web-push subscription storage, crypto, validation, and sending. This is a separate outbound integration path used for turn-complete and permission prompts, and it depends on browser push infrastructure rather than the chat SSE channel.

15. **Frontend structure**
   `static-src` is a large client-side application with action modules, handlers, UI primitives, transport/SSE plumbing, editor and chat views, and generated wire code. It is organized as a projection of server state: it listens to SSE, dispatches commands, and renders specialized screens for chat, files, git, MCP, settings, and terminal behavior.

16. **Cross-cutting assurance and quality**
   The repo is heavily test-driven, with fuzz, property, and contract tests across most packages, plus CI, CodeQL, and security workflows. That matters architecturally because many boundaries are enforced by tests rather than by runtime frameworks, especially around protocol decoding, permissions, checkpointing, and state replay.

Main entry points: [`internal/hub/hub.go`](https://github.com/cplieger/vibekit/blob/main/internal/hub/hub.go) (Chat hub), [`internal/server/server.go`](https://github.com/cplieger/vibekit/blob/main/internal/server/server.go) (HTTP server), [`static-src/transport.ts`](https://github.com/cplieger/vibekit/blob/main/static-src/transport.ts) (Transport), [`static-src/actions/index.ts`](https://github.com/cplieger/vibekit/blob/main/static-src/actions/index.ts) (Action modules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_go_backend["Go backend"]
  node_server["HTTP server<br/>web server<br/>[server.go]"]
  node_hub{{"Chat hub<br/>orchestrator<br/>[hub.go]"}}
  node_command["Commands<br/>dispatch layer<br/>[command.go]"]
  node_bridge["Kiro bridge<br/>acp bridge<br/>[bridge.go]"]
  node_chat[("Chat store<br/>conversation storage<br/>[store.go]")]
  node_sessions[("Sessions<br/>session state<br/>[sessions.go]")]
  node_buffer["Output buffer<br/>stream buffer<br/>[buffer.go]"]
  node_dedup(("Dedup<br/>event filter<br/>[dedup.go]"))
  node_filehandler["File gate<br/>workspace io<br/>[filehandler.go]"]
  node_permissions["Permissions<br/>policy engine<br/>[permissions.go]"]
  node_pending["Pending ops<br/>staging queue<br/>[pending.go]"]
  node_auth["Auth<br/>identity<br/>[auth.go]"]
end

subgraph group_client_ui["TypeScript UI"]
  node_static_src["Frontend app<br/>typescript client<br/>[app.ts]"]
  node_transport["Transport<br/>sse client<br/>[transport.ts]"]
  node_actions["Action modules<br/>ui actions<br/>[index.ts]"]
  node_views["UI views<br/>screens<br/>[chat.ts]"]
end

subgraph group_storage_integrations["Storage and external systems"]
  node_checkpoint[("Checkpoints<br/>snapshot store<br/>[manager.go]")]
  node_mcp[("MCP registry<br/>tool registry<br/>[store.go]")]
  node_git["Git layer<br/>repo workflow<br/>[handlers.go]"]
  node_forges["Forge adapters<br/>integration adapters<br/>[manager.go]"]
  node_push["Push service<br/>notification service<br/>[service.go]"]
end

subgraph group_infra["Packaging and entrypoints"]
  node_main_entry["Main entry<br/>entrypoint<br/>[main.go]"]
  node_wire_codegen["Wire codegen<br/>build tool<br/>[main.go]"]
end

node_main_entry -->|"starts"| node_server
node_wire_codegen -.->|"generates wiring"| node_main_entry
node_server -->|"routes to"| node_hub
node_server -->|"authenticates"| node_auth
node_server -->|"serves UI"| node_static_src
node_static_src -->|"listens/sends"| node_transport
node_transport -->|"API + SSE"| node_server
node_transport -->|"dispatches"| node_actions
node_actions -->|"updates"| node_views
node_actions -->|"commands"| node_hub
node_hub -->|"executes"| node_command
node_hub -->|"spawns"| node_bridge
node_hub -->|"persists"| node_chat
node_hub -->|"tracks"| node_sessions
node_hub -->|"buffers"| node_buffer
node_hub -->|"filters"| node_dedup
node_hub -->|"gates files"| node_filehandler
node_hub -->|"snapshots"| node_checkpoint
node_hub -->|"checks policy"| node_permissions
node_hub -->|"stages writes"| node_pending
node_hub -->|"routes tools"| node_mcp
node_hub -->|"inspects repo"| node_git
node_git -->|"integrates"| node_forges
node_hub -->|"notifies"| node_push
node_filehandler -->|"restore/diff"| node_checkpoint
node_permissions -->|"governs"| node_pending

click node_main_entry "https://github.com/cplieger/vibekit/blob/main/main.go"
click node_wire_codegen "https://github.com/cplieger/vibekit/blob/main/cmd/wire-codegen/main.go"
click node_server "https://github.com/cplieger/vibekit/blob/main/internal/server/server.go"
click node_hub "https://github.com/cplieger/vibekit/blob/main/internal/hub/hub.go"
click node_command "https://github.com/cplieger/vibekit/blob/main/internal/command/command.go"
click node_bridge "https://github.com/cplieger/vibekit/blob/main/internal/bridge/bridge.go"
click node_chat "https://github.com/cplieger/vibekit/blob/main/internal/chat/store.go"
click node_sessions "https://github.com/cplieger/vibekit/blob/main/internal/sessions/sessions.go"
click node_buffer "https://github.com/cplieger/vibekit/blob/main/internal/buffer/buffer.go"
click node_dedup "https://github.com/cplieger/vibekit/blob/main/internal/dedup/dedup.go"
click node_filehandler "https://github.com/cplieger/vibekit/blob/main/internal/filehandler/filehandler.go"
click node_checkpoint "https://github.com/cplieger/vibekit/blob/main/internal/checkpoint/manager.go"
click node_permissions "https://github.com/cplieger/vibekit/blob/main/internal/permissions/permissions.go"
click node_pending "https://github.com/cplieger/vibekit/blob/main/internal/pending/pending.go"
click node_mcp "https://github.com/cplieger/vibekit/blob/main/internal/mcp/store.go"
click node_git "https://github.com/cplieger/vibekit/blob/main/internal/git/handlers.go"
click node_forges "https://github.com/cplieger/vibekit/blob/main/internal/forges/manager.go"
click node_push "https://github.com/cplieger/vibekit/blob/main/internal/push/service.go"
click node_auth "https://github.com/cplieger/vibekit/blob/main/internal/auth/auth.go"
click node_static_src "https://github.com/cplieger/vibekit/blob/main/static-src/app.ts"
click node_transport "https://github.com/cplieger/vibekit/blob/main/static-src/transport.ts"
click node_actions "https://github.com/cplieger/vibekit/blob/main/static-src/actions/index.ts"
click node_views "https://github.com/cplieger/vibekit/blob/main/static-src/chat.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_hub,node_command,node_bridge,node_chat,node_sessions,node_buffer,node_dedup,node_filehandler,node_permissions,node_pending,node_auth toneBlue
class node_static_src,node_transport,node_actions,node_views toneAmber
class node_checkpoint,node_mcp,node_git,node_forges,node_push toneMint
class node_main_entry,node_wire_codegen toneRose
```

## Components

### Go backend

Server-side orchestration, state, and integrations

- [HTTP server](https://github.com/cplieger/vibekit/blob/main/internal/server/server.go): web server · Routes UI, API, static assets, and security middleware · `internal/server/server.go`
- [Chat hub](https://github.com/cplieger/vibekit/blob/main/internal/hub/hub.go): orchestrator · Central coordinator for chat, commands, SSE, bridges, and workspace actions · `internal/hub/hub.go`
- [Commands](https://github.com/cplieger/vibekit/blob/main/internal/command/command.go): dispatch layer · Turns UI and agent actions into executable operations · `internal/command/command.go`
- [Kiro bridge](https://github.com/cplieger/vibekit/blob/main/internal/bridge/bridge.go): acp bridge · Manages per-chat kiro-cli subprocesses and protocol translation · `internal/bridge/bridge.go`
- [Chat store](https://github.com/cplieger/vibekit/blob/main/internal/chat/store.go): conversation storage · Persistent chat history, archive, purge, and replay state · `internal/chat/store.go`
- [Sessions](https://github.com/cplieger/vibekit/blob/main/internal/sessions/sessions.go): session state · Tracks active conversations and replay/session continuity · `internal/sessions/sessions.go`
- [Output buffer](https://github.com/cplieger/vibekit/blob/main/internal/buffer/buffer.go): stream buffer · Buffers partial and replayable terminal/model output · `internal/buffer/buffer.go`
- [Dedup](https://github.com/cplieger/vibekit/blob/main/internal/dedup/dedup.go): event filter · Suppresses repeated events and noisy updates · `internal/dedup/dedup.go`
- [File gate](https://github.com/cplieger/vibekit/blob/main/internal/filehandler/filehandler.go): workspace io · Reads, writes, uploads, listings, and download handling for workspace files · `internal/filehandler/filehandler.go`
- [Permissions](https://github.com/cplieger/vibekit/blob/main/internal/permissions/permissions.go): policy engine · Supervised approval rules for commands and file mutations · `internal/permissions/permissions.go`
- [Pending ops](https://github.com/cplieger/vibekit/blob/main/internal/pending/pending.go): staging queue · Tracks writes and merges awaiting user decision · `internal/pending/pending.go`
- [Auth](https://github.com/cplieger/vibekit/blob/main/internal/auth/auth.go): identity · UI login, logout, and who-am-I flows · `internal/auth/auth.go`

### TypeScript UI

Browser app that renders server state and sends commands

- [Frontend app](https://github.com/cplieger/vibekit/blob/main/static-src/app.ts): typescript client · Browser UI that renders server state and dispatches commands · `static-src/app.ts`
- [Transport](https://github.com/cplieger/vibekit/blob/main/static-src/transport.ts): sse client · Client-side SSE and API plumbing for state sync · `static-src/transport.ts`
- [Action modules](https://github.com/cplieger/vibekit/blob/main/static-src/actions/index.ts): ui actions · UI command dispatchers for chat, files, git, MCP, permissions, and settings · `static-src/actions/index.ts`
- [UI views](https://github.com/cplieger/vibekit/blob/main/static-src/chat.ts): screens · Chat, editor, diff, files, terminal, git, MCP, and settings screens · `static-src/chat.ts`

### Storage and external systems

Persistent state, git/forge, and outbound delivery boundaries

- [Checkpoints](https://github.com/cplieger/vibekit/blob/main/internal/checkpoint/manager.go): snapshot store · Content-addressed workspace snapshots, diff, restore, and GC · `internal/checkpoint/manager.go`
- [MCP registry](https://github.com/cplieger/vibekit/blob/main/internal/mcp/store.go): tool registry · Persists and prewarms Model Context Protocol servers and tools · `internal/mcp/store.go`
- [Git layer](https://github.com/cplieger/vibekit/blob/main/internal/git/handlers.go): repo workflow · Repository introspection, staging, sync, and AI-assisted git actions · `internal/git/handlers.go`
- [Forge adapters](https://github.com/cplieger/vibekit/blob/main/internal/forges/manager.go): integration adapters · GitHub, GitLab, and Gitea auth and repo workflows via CLI and HTTP · `internal/forges/manager.go`
- [Push service](https://github.com/cplieger/vibekit/blob/main/internal/push/service.go): notification service · Web-push subscription storage and outbound notifications · `internal/push/service.go`

### Packaging and entrypoints

Process startup and deployment surfaces

- [Main entry](https://github.com/cplieger/vibekit/blob/main/main.go): entrypoint · Go process startup and dependency wiring · `main.go`
- [Wire codegen](https://github.com/cplieger/vibekit/blob/main/cmd/wire-codegen/main.go): build tool · Generates dependency wiring for the Go app · `cmd/wire-codegen/main.go`

## Connections

- Main entry → HTTP server: starts · Main process boots the HTTP server
- Wire codegen → Main entry: generates wiring · Dependency injection code supports startup composition
- HTTP server → Chat hub: routes to · Server hands application requests to the hub
- HTTP server → Auth: authenticates · Login and identity endpoints protect the web UI
- HTTP server → Frontend app: serves UI · Server delivers the browser application and assets
- Frontend app → Transport: listens/sends · Frontend consumes SSE and posts commands through transport
- Transport → HTTP server: API + SSE · Client talks to the server over command requests and event streams
- Transport → Action modules: dispatches · Transport feeds UI action handlers
- Action modules → UI views: updates · Actions drive specialized UI screens and panels
- Action modules → Chat hub: commands · UI mutations are sent as hub-facing commands
- Chat hub → Commands: executes · Central coordinator dispatches chat and shell operations
- Chat hub → Kiro bridge: spawns · Each active chat gets a managed Kiro bridge process
- Chat hub → Chat store: persists · Chat state and replay history are stored durably
- Chat hub → Sessions: tracks · Session lifecycle and active conversation state
- Chat hub → Output buffer: buffers · Output and replay data are buffered for streaming clients
- Chat hub → Dedup: filters · Repeated events are suppressed before fan-out
- Chat hub → File gate: gates files · Workspace reads and writes flow through file handling boundaries
- Chat hub → Checkpoints: snapshots · Workspace restore and diff use the checkpoint subsystem
- Chat hub → Permissions: checks policy · Supervised operations are validated before mutation
- Chat hub → Pending ops: stages writes · Pending mutations are held for approve/reject/merge flows
- Chat hub → MCP registry: routes tools · Hub exposes MCP registry and prewarm state
- Chat hub → Git layer: inspects repo · Git status, staging, sync, and repo workflows are coordinated here
- Git layer → Forge adapters: integrates · Forge adapters support hosting-provider workflows and auth
- Chat hub → Push service: notifies · Turn-complete and permission prompts can be delivered via push
- File gate → Checkpoints: restore/diff · Workspace file mutation boundary connects to snapshots and restore
- Permissions → Pending ops: governs · Approval policy determines whether staged operations can proceed
