# grimoire-rs/grimoire architecture

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

- Interactive diagram: https://gitdiagram.com/grimoire-rs/grimoire
- Repository: https://github.com/grimoire-rs/grimoire

## Overview

Grimoire (`grim`) is a package manager for AI-agent configuration artifacts. Its main workflow declares artifacts, resolves registry references, pins content in `grimoire.lock`, fetches OCI content, then materializes client-specific files. The graph also preserves documented catalog browsing, publishing, export, hooks, TUI, and MCP capabilities. Edges are limited to relationships shown by the README or SOURCE INDEX; unsampled subsystem internals are represented at their existing directory paths.

Main entry points: [`src/command/add.rs`](https://github.com/grimoire-rs/grimoire/blob/main/src/command/add.rs) (Add workflow), [`src/resolve/resolver.rs`](https://github.com/grimoire-rs/grimoire/blob/main/src/resolve/resolver.rs) (Artifact resolver), [`src/install/installer.rs`](https://github.com/grimoire-rs/grimoire/blob/main/src/install/installer.rs) (Install orchestration), [`src/main.rs`](https://github.com/grimoire-rs/grimoire/blob/main/src/main.rs) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and workflows"]
  node_entry["CLI entry<br/>[main.rs]"]
  node_dispatch["Command dispatch<br/>[command.rs]"]
  node_add["Add workflow<br/>[add.rs]"]
  node_declaration["Project declaration<br/>[declaration.rs]"]
end

subgraph group_resolution["Resolution and registry"]
  node_registry["Registry resolution"]
  node_resolver["Artifact resolver<br/>[resolver.rs]"]
  node_access["OCI access<br/>[registry_client.rs]"]
  node_registry_service["Registry service"]
  node_auth["Registry authentication<br/>[auth.rs]"]
end

subgraph group_artifacts["Artifact lifecycle"]
  node_lock["Lockfile<br/>[grimoire_lock.rs]"]
  node_lock_io["Lockfile I/O<br/>[lock_io.rs]"]
  node_fetch["Artifact fetch<br/>[fetch.rs]"]
  node_install["Install orchestration<br/>[installer.rs]"]
  node_export["Export<br/>[stage.rs]"]
  node_publish["Publish and release<br/>[publish.rs]"]
end

subgraph group_clients["Agent integrations"]
  node_target["Client transforms<br/>[client_target.rs]"]
  node_agent_files["Agent configuration<br/>[vendor.rs]"]
  node_hooks["Hook workflows<br/>[pipeline.rs]"]
end

subgraph group_discovery["Discovery and interfaces"]
  node_catalog["Catalog search<br/>[catalog_service.rs]"]
  node_search["Search command<br/>[search.rs]"]
  node_tui["Interactive browser<br/>[app.rs]"]
  node_mcp["MCP server<br/>[server.rs]"]
end

node_user(("User"))

node_user -->|"runs commands"| node_entry
node_entry -->|"routes commands"| node_dispatch
node_dispatch -->|"dispatches add"| node_add
node_add -.->|"updates declaration"| node_declaration
node_add -.->|"resolves registry"| node_registry
node_registry -.->|"supplies references"| node_resolver
node_resolver -->|"queries OCI"| node_access
node_access -->|"authenticates"| node_auth
node_resolver -->|"pins artifacts"| node_lock
node_lock_io -->|"loads and saves"| node_lock
node_user -->|"runs install"| node_install
node_install -.->|"fetches artifacts"| node_fetch
node_install -->|"materializes targets"| node_target
node_target -.->|"writes client layouts"| node_agent_files
node_user -->|"searches catalog"| node_search
node_search -->|"queries catalog"| node_catalog
node_catalog -->|"uses registry catalog"| node_registry_service
node_user -->|"browses index"| node_tui
node_user -.->|"connects MCP"| node_mcp
node_user -.->|"manages hooks"| node_hooks
node_user -.->|"exports artifacts"| node_export
node_user -.->|"publishes artifacts"| node_publish

click node_entry "https://github.com/grimoire-rs/grimoire/blob/main/src/main.rs"
click node_dispatch "https://github.com/grimoire-rs/grimoire/blob/main/src/command.rs"
click node_add "https://github.com/grimoire-rs/grimoire/blob/main/src/command/add.rs"
click node_declaration "https://github.com/grimoire-rs/grimoire/blob/main/src/config/declaration.rs"
click node_registry "https://github.com/grimoire-rs/grimoire/blob/main/src/config/registry_resolve.rs"
click node_resolver "https://github.com/grimoire-rs/grimoire/blob/main/src/resolve/resolver.rs"
click node_access "https://github.com/grimoire-rs/grimoire/blob/main/src/oci/access/registry_client.rs"
click node_registry_service "https://github.com/grimoire-rs/grimoire/blob/main/src/catalog/registry_catalog.rs"
click node_lock "https://github.com/grimoire-rs/grimoire/blob/main/src/lock/grimoire_lock.rs"
click node_lock_io "https://github.com/grimoire-rs/grimoire/blob/main/src/lock/lock_io.rs"
click node_fetch "https://github.com/grimoire-rs/grimoire/blob/main/src/fetch.rs"
click node_install "https://github.com/grimoire-rs/grimoire/blob/main/src/install/installer.rs"
click node_target "https://github.com/grimoire-rs/grimoire/blob/main/src/install/client_target.rs"
click node_agent_files "https://github.com/grimoire-rs/grimoire/blob/main/src/install/vendor.rs"
click node_auth "https://github.com/grimoire-rs/grimoire/blob/main/src/auth.rs"
click node_catalog "https://github.com/grimoire-rs/grimoire/blob/main/src/catalog/catalog_service.rs"
click node_search "https://github.com/grimoire-rs/grimoire/blob/main/src/command/search.rs"
click node_tui "https://github.com/grimoire-rs/grimoire/blob/main/src/tui/app.rs"
click node_mcp "https://github.com/grimoire-rs/grimoire/blob/main/src/mcp/server.rs"
click node_hooks "https://github.com/grimoire-rs/grimoire/blob/main/src/command/hook/pipeline.rs"
click node_export "https://github.com/grimoire-rs/grimoire/blob/main/src/export/stage.rs"
click node_publish "https://github.com/grimoire-rs/grimoire/blob/main/src/command/publish.rs"

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_entry,node_dispatch,node_add,node_declaration,node_user toneBlue
class node_registry,node_resolver,node_access,node_registry_service,node_auth toneAmber
class node_lock,node_lock_io,node_fetch,node_install,node_export,node_publish toneMint
class node_target,node_agent_files,node_hooks toneRose
class node_catalog,node_search,node_tui,node_mcp toneIndigo
```

## Components

### CLI and workflows

- [CLI entry](https://github.com/grimoire-rs/grimoire/blob/main/src/main.rs): `src/main.rs`
- [Command dispatch](https://github.com/grimoire-rs/grimoire/blob/main/src/command.rs): `src/command.rs`
- [Add workflow](https://github.com/grimoire-rs/grimoire/blob/main/src/command/add.rs): `src/command/add.rs`
- [Project declaration](https://github.com/grimoire-rs/grimoire/blob/main/src/config/declaration.rs): `src/config/declaration.rs`

### Resolution and registry

- [Registry resolution](https://github.com/grimoire-rs/grimoire/blob/main/src/config/registry_resolve.rs): `src/config/registry_resolve.rs`
- [Artifact resolver](https://github.com/grimoire-rs/grimoire/blob/main/src/resolve/resolver.rs): `src/resolve/resolver.rs`
- [OCI access](https://github.com/grimoire-rs/grimoire/blob/main/src/oci/access/registry_client.rs): `src/oci/access/registry_client.rs`
- [Registry service](https://github.com/grimoire-rs/grimoire/blob/main/src/catalog/registry_catalog.rs): `src/catalog/registry_catalog.rs`
- [Registry authentication](https://github.com/grimoire-rs/grimoire/blob/main/src/auth.rs): `src/auth.rs`

### Artifact lifecycle

- [Lockfile](https://github.com/grimoire-rs/grimoire/blob/main/src/lock/grimoire_lock.rs): `src/lock/grimoire_lock.rs`
- [Lockfile I/O](https://github.com/grimoire-rs/grimoire/blob/main/src/lock/lock_io.rs): `src/lock/lock_io.rs`
- [Artifact fetch](https://github.com/grimoire-rs/grimoire/blob/main/src/fetch.rs): `src/fetch.rs`
- [Install orchestration](https://github.com/grimoire-rs/grimoire/blob/main/src/install/installer.rs): `src/install/installer.rs`
- [Export](https://github.com/grimoire-rs/grimoire/blob/main/src/export/stage.rs): `src/export/stage.rs`
- [Publish and release](https://github.com/grimoire-rs/grimoire/blob/main/src/command/publish.rs): `src/command/publish.rs`

### Agent integrations

- [Client transforms](https://github.com/grimoire-rs/grimoire/blob/main/src/install/client_target.rs): `src/install/client_target.rs`
- [Agent configuration](https://github.com/grimoire-rs/grimoire/blob/main/src/install/vendor.rs): `src/install/vendor.rs`
- [Hook workflows](https://github.com/grimoire-rs/grimoire/blob/main/src/command/hook/pipeline.rs): `src/command/hook/pipeline.rs`

### Discovery and interfaces

- [Catalog search](https://github.com/grimoire-rs/grimoire/blob/main/src/catalog/catalog_service.rs): `src/catalog/catalog_service.rs`
- [Search command](https://github.com/grimoire-rs/grimoire/blob/main/src/command/search.rs): `src/command/search.rs`
- [Interactive browser](https://github.com/grimoire-rs/grimoire/blob/main/src/tui/app.rs): `src/tui/app.rs`
- [MCP server](https://github.com/grimoire-rs/grimoire/blob/main/src/mcp/server.rs): `src/mcp/server.rs`

### Other components

- **User**

## Connections

- User → CLI entry: runs commands (evidence: `README.md`)
- CLI entry → Command dispatch: routes commands (evidence: `src/main.rs`)
- Command dispatch → Add workflow: dispatches add (evidence: `src/main.rs`)
- Add workflow → Project declaration: updates declaration (evidence: `src/command/add.rs`)
- Add workflow → Registry resolution: resolves registry (evidence: `src/command/add.rs`)
- Registry resolution → Artifact resolver: supplies references
- Artifact resolver → OCI access: queries OCI (evidence: `src/resolve/resolver.rs`)
- OCI access → Registry authentication: authenticates (evidence: `src/oci/access/registry_client.rs`)
- Artifact resolver → Lockfile: pins artifacts (evidence: `src/resolve/resolver.rs`)
- Lockfile I/O → Lockfile: loads and saves (evidence: `src/lock/lock_io.rs`)
- User → Install orchestration: runs install (evidence: `README.md`)
- Install orchestration → Artifact fetch: fetches artifacts
- Install orchestration → Client transforms: materializes targets (evidence: `src/install/client_target.rs`)
- Client transforms → Agent configuration: writes client layouts (evidence: `src/install/client_target.rs`)
- User → Search command: searches catalog (evidence: `README.md`)
- Search command → Catalog search: queries catalog (evidence: `src/command/search.rs`)
- Catalog search → Registry service: uses registry catalog (evidence: `src/catalog/catalog_service.rs`)
- User → Interactive browser: browses index (evidence: `README.md`)
- User → MCP server: connects MCP
- User → Hook workflows: manages hooks
- User → Export: exports artifacts
- User → Publish and release: publishes artifacts
