# ix-infrastructure/ix architecture

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

- Interactive diagram: https://gitdiagram.com/ix-infrastructure/ix
- Repository: https://github.com/ix-infrastructure/ix
- Video tour (about a minute): https://gitdiagram.com/ix-infrastructure/ix/video

## Overview

#### Purpose and Entry Points
Ix is a cross-platform Node.js CLI that maps a local source repository into a persistent code graph, then exposes structural exploration, impact, tracing, and explanation commands. The executable enters through `ix-cli/src/index.ts` and CLI dispatch is centered in `ix-cli/src/cli/main.ts`. It targets a local Docker-managed backend rather than a web application.

#### CLI Orchestration and Backend Boundary
Command implementations live under `ix-cli/src/cli/commands/`, covering graph lifecycle (`map`, `ingest`, `watch`), graph navigation (`query`, `search`, `trace`, `impact`, `read`), and local service management (`docker`, `status`, `doctor`, `upgrade`). The CLI’s backend/API boundary is represented by `ix-cli/src/client/api.ts` and `ix-cli/src/client/types.ts`; commands should depend on this client contract rather than backend internals. Shell workflows and lifecycle scripts are rooted at `scripts/backend.sh`, `scripts/ingest.sh`, and `docker-compose.standalone.yml`.

#### Parsing and Graph Ingestion
The independently packaged `core-ingestion` module performs source analysis. Its public entry is `core-ingestion/src/index.ts`; `core-ingestion/src/parse-worker.ts` supports parallel parsing, while `core-ingestion/src/languages.ts` and `core-ingestion/src/queries.ts` define Tree-sitter language/query support. Parsing produces typed symbol, import, and call information (`core-ingestion/src/types.ts`), then resolves relationships and emits graph patches through `core-ingestion/src/patch-builder.ts`. The CLI loads and coordinates this engine via `ix-cli/src/cli/commands/ingestion-loader.ts` and `ix-cli/src/cli/commands/parse-pool.ts`.

#### Mapping Control Flow
`ix map`/ingestion discovers repository files, applies supported-language handling, parses files concurrently, resolves cross-file edges, and submits patches to the local backend. Incremental and revision-aware behavior is organized around `ix-cli/src/cli/commands/ingest.ts`, `ix-cli/src/cli/ingest-baseline.ts`, and `ix-cli/src/cli/commands/watch.ts`. This is the core boundary between untrusted/on-disk project content and persisted graph state; workspace resolution, containment, and staleness logic is centralized in `ix-cli/src/cli/resolve.ts`, `ix-cli/src/cli/config.ts`, and `ix-cli/src/cli/stale.ts`.

#### Graph Exploration and Interpretation
Commands convert backend graph results into task-oriented outputs: dependency and caller traversal in `ix-cli/src/cli/commands/depends.ts` and `ix-cli/src/cli/commands/callers.ts`; impact analysis in `ix-cli/src/cli/commands/impact.ts` with semantics in `ix-cli/src/cli/impact/risk-semantics.ts`; and execution-flow tracing in `ix-cli/src/cli/commands/trace.ts`. Explanations layer inferred roles, hierarchy, flow facts, subsystem meaning, and ranking over graph data in `ix-cli/src/cli/explain/` and are surfaced by `ix-cli/src/cli/commands/explain.ts`.

#### AI and MCP Interface
The canonical AI integration is a stdio MCP server in `ix-cli/src/mcp/server.ts`, with process/command execution in `ix-cli/src/mcp/runner.ts`. It can call tools in-process or via isolated CLI subprocesses. Host discovery and safe registration across supported AI clients are implemented in `ix-cli/src/mcp/hosts.ts` and `ix-cli/src/mcp/install.ts`. LLM-oriented response construction is separated into `ix-cli/src/cli/llm.ts` and `ix-cli/src/cli/explain/llm.ts`, retaining graph retrieval as the authoritative data source.

#### Infrastructure and External Services
Runtime requirements are Node.js 22+, Docker/Compose, Git, and optionally ripgrep for text search. Docker hosts local ArangoDB plus the repository’s memory-layer backend, configured through `docker-compose.standalone.yml`; the CLI reaches it through its API client. GitHub integration for fetching and transforming remote repository/PR data is isolated under `ix-cli/src/cli/github/`. Distribution supports installer scripts, platform packages, and Homebrew via `scripts/install/`, `scripts/release.sh`, and `Formula/ix.rb`.

Main entry points: [`ix-cli/src/client/api.ts`](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/client/api.ts) (Backend API client), [`core-ingestion/src/parse-worker.ts`](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/parse-worker.ts) (Parallel Tree-sitter parsing), [`ix-cli/src/cli/main.ts`](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/main.ts) (Command dispatch), [`ix-cli/src/cli/commands/ingest.ts`](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/ingest.ts) (Incremental ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_entry{{"ix executable<br/>Node.js entry<br/>[index.ts]"}}
  node_dispatch["Command dispatch<br/>CLI router<br/>[main.ts]"]
  node_commands["Command suite<br/>CLI commands"]
  node_client["Backend API client<br/>client contract<br/>[api.ts]"]
  node_workspace["Workspace safeguards<br/>workspace control<br/>[resolve.ts]"]
  node_ingest_control["Incremental ingestion<br/>ingestion control<br/>[ingest.ts]"]
  node_loader_pool["Engine loader and parse pool<br/>parallel coordinator"]
  node_exploration["Graph exploration<br/>navigation commands<br/>[depends.ts]"]
  node_explanations["Graph explanations<br/>interpretation layer"]
end

subgraph group_ingestion["Ingestion engine"]
  node_core_api{{"Ingestion public API<br/>package entry<br/>[index.ts]"}}
  node_parsing["Parallel Tree-sitter parsing<br/>parser workers<br/>[parse-worker.ts]"]
  node_language_support["Languages and queries<br/>Tree-sitter support<br/>[languages.ts]"]
  node_symbols["Typed source facts<br/>analysis types<br/>[types.ts]"]
  node_patches["Graph patch builder<br/>relationship resolver<br/>[patch-builder.ts]"]
end

subgraph group_backend["Local backend"]
  node_compose["Docker Compose stack<br/>local runtime"]
  node_graph_backend["Memory-layer backend<br/>graph API service"]
  node_arangodb[("ArangoDB<br/>graph database")]
end

subgraph group_ai["AI and MCP"]
  node_mcp_server{{"MCP server<br/>[server.ts]"}}
  node_mcp_runner["MCP runner<br/>process executor<br/>[runner.ts]"]
  node_mcp_install["AI host registration<br/>MCP installer<br/>[install.ts]"]
end

node_entry -->|"starts"| node_dispatch
node_dispatch -->|"routes"| node_commands
node_commands -->|"validates workspace"| node_workspace
node_commands -->|"map / ingest / watch"| node_ingest_control
node_commands -->|"navigation commands"| node_exploration
node_commands -->|"explain command"| node_explanations
node_commands -->|"uses"| node_client
node_ingest_control -->|"coordinates"| node_loader_pool
node_loader_pool -->|"loads"| node_core_api
node_core_api -->|"parses files"| node_parsing
node_parsing -->|"uses"| node_language_support
node_parsing -->|"produces"| node_symbols
node_symbols -->|"feeds"| node_patches
node_patches -->|"submits patches"| node_client
node_client -->|"API requests"| node_graph_backend
node_exploration -->|"retrieves graph data"| node_client
node_explanations -->|"retrieves graph facts"| node_client
node_compose -->|"runs"| node_graph_backend
node_graph_backend -->|"persists in"| node_arangodb
node_mcp_server -->|"executes tools"| node_mcp_runner
node_mcp_runner -.->|"invokes CLI"| node_dispatch
node_mcp_install -->|"registers"| node_mcp_server

click node_entry "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/index.ts"
click node_dispatch "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/main.ts"
click node_client "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/client/api.ts"
click node_workspace "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/resolve.ts"
click node_ingest_control "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/ingest.ts"
click node_loader_pool "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/ingestion-loader.ts"
click node_exploration "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/depends.ts"
click node_core_api "https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/index.ts"
click node_parsing "https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/parse-worker.ts"
click node_language_support "https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/languages.ts"
click node_symbols "https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/types.ts"
click node_patches "https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/patch-builder.ts"
click node_compose "https://github.com/ix-infrastructure/ix/blob/main/docker-compose.standalone.yml"
click node_mcp_server "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/server.ts"
click node_mcp_runner "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/runner.ts"
click node_mcp_install "https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/install.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_entry,node_dispatch,node_commands,node_client,node_workspace,node_ingest_control,node_loader_pool,node_exploration,node_explanations toneBlue
class node_core_api,node_parsing,node_language_support,node_symbols,node_patches toneAmber
class node_compose,node_graph_backend,node_arangodb toneMint
class node_mcp_server,node_mcp_runner,node_mcp_install toneRose
```

## Components

### CLI

Local command orchestration and graph workflows.

- [ix executable](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/index.ts): Node.js entry · `ix-cli/src/index.ts`
- [Command dispatch](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/main.ts): CLI router · `ix-cli/src/cli/main.ts`
- **Command suite**: CLI commands · Mapping, exploration, service, and lifecycle commands.
- [Backend API client](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/client/api.ts): client contract · Commands access graph state through this boundary. · `ix-cli/src/client/api.ts`
- [Workspace safeguards](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/resolve.ts): workspace control · Resolves workspace containment, configuration, and staleness. · `ix-cli/src/cli/resolve.ts`
- [Incremental ingestion](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/ingest.ts): ingestion control · Coordinates revision-aware ingest and watch behavior. · `ix-cli/src/cli/commands/ingest.ts`
- [Engine loader and parse pool](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/ingestion-loader.ts): parallel coordinator · `ix-cli/src/cli/commands/ingestion-loader.ts`
- [Graph exploration](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/cli/commands/depends.ts): navigation commands · Dependency, caller, search, read, trace, and impact outputs. · `ix-cli/src/cli/commands/depends.ts`
- **Graph explanations**: interpretation layer · Infers roles, hierarchy, flows, subsystem meaning, and ranking.

### Ingestion engine

Independent source parsing and patch construction.

- [Ingestion public API](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/index.ts): package entry · `core-ingestion/src/index.ts`
- [Parallel Tree-sitter parsing](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/parse-worker.ts): parser workers · Parses supported source files concurrently. · `core-ingestion/src/parse-worker.ts`
- [Languages and queries](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/languages.ts): Tree-sitter support · `core-ingestion/src/languages.ts`
- [Typed source facts](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/types.ts): analysis types · Symbols, imports, and calls extracted from source. · `core-ingestion/src/types.ts`
- [Graph patch builder](https://github.com/ix-infrastructure/ix/blob/main/core-ingestion/src/patch-builder.ts): relationship resolver · Resolves cross-file edges and emits graph patches. · `core-ingestion/src/patch-builder.ts`

### Local backend

Docker-managed persistent graph services.

- [Docker Compose stack](https://github.com/ix-infrastructure/ix/blob/main/docker-compose.standalone.yml): local runtime · Starts the memory-layer backend and ArangoDB. · `docker-compose.standalone.yml`
- **Memory-layer backend**: graph API service · Persistent graph state consumed through the client contract.
- **ArangoDB**: graph database

### AI and MCP

AI-client integration over authoritative graph retrieval.

- [MCP server](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/server.ts): stdio MCP server · Canonical AI integration with in-process or isolated CLI execution. · `ix-cli/src/mcp/server.ts`
- [MCP runner](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/runner.ts): process executor · `ix-cli/src/mcp/runner.ts`
- [AI host registration](https://github.com/ix-infrastructure/ix/blob/main/ix-cli/src/mcp/install.ts): MCP installer · Discovers supported hosts and safely registers the server. · `ix-cli/src/mcp/install.ts`

## Connections

- ix executable → Command dispatch: starts
- Command dispatch → Command suite: routes
- Command suite → Workspace safeguards: validates workspace
- Command suite → Incremental ingestion: map / ingest / watch
- Command suite → Graph exploration: navigation commands
- Command suite → Graph explanations: explain command
- Command suite → Backend API client: uses
- Incremental ingestion → Engine loader and parse pool: coordinates
- Engine loader and parse pool → Ingestion public API: loads
- Ingestion public API → Parallel Tree-sitter parsing: parses files
- Parallel Tree-sitter parsing → Languages and queries: uses
- Parallel Tree-sitter parsing → Typed source facts: produces
- Typed source facts → Graph patch builder: feeds
- Graph patch builder → Backend API client: submits patches
- Backend API client → Memory-layer backend: API requests
- Graph exploration → Backend API client: retrieves graph data
- Graph explanations → Backend API client: retrieves graph facts
- Docker Compose stack → Memory-layer backend: runs
- Memory-layer backend → ArangoDB: persists in
- MCP server → MCP runner: executes tools
- MCP runner → Command dispatch: invokes CLI
- AI host registration → MCP server: registers
