How ix-infrastructure/ix works
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: api.ts Backend API client · parse-worker.ts Parallel Tree-sitter parsing · main.ts Command dispatch · ingest.ts Incremental ingestion
Components 20
CLI
Local command orchestration and graph workflows.
- ix executable
ix-cli/src/index.ts - Command dispatch
ix-cli/src/cli/main.ts - Command suite · Mapping, exploration, service, and lifecycle commands.
- Backend API client · Commands access graph state through this boundary.
ix-cli/src/client/api.ts - Workspace safeguards · Resolves workspace containment, configuration, and staleness.
ix-cli/src/cli/resolve.ts - Incremental ingestion · Coordinates revision-aware ingest and watch behavior.
ix-cli/src/cli/commands/ingest.ts - Engine loader and parse pool
ix-cli/src/cli/commands/ingestion-loader.ts - Graph exploration · Dependency, caller, search, read, trace, and impact outputs.
ix-cli/src/cli/commands/depends.ts - Graph explanations · Infers roles, hierarchy, flows, subsystem meaning, and ranking.
Ingestion engine
Independent source parsing and patch construction.
- Ingestion public API
core-ingestion/src/index.ts - Parallel Tree-sitter parsing · Parses supported source files concurrently.
core-ingestion/src/parse-worker.ts - Languages and queries
core-ingestion/src/languages.ts - Typed source facts · Symbols, imports, and calls extracted from source.
core-ingestion/src/types.ts - Graph patch builder · Resolves cross-file edges and emits graph patches.
core-ingestion/src/patch-builder.ts
Local backend
Docker-managed persistent graph services.
- Docker Compose stack · Starts the memory-layer backend and ArangoDB.
docker-compose.standalone.yml - Memory-layer backend · Persistent graph state consumed through the client contract.
- ArangoDB
AI and MCP
AI-client integration over authoritative graph retrieval.
- MCP server · Canonical AI integration with in-process or isolated CLI execution.
ix-cli/src/mcp/server.ts - MCP runner
ix-cli/src/mcp/runner.ts - AI host registration · Discovers supported hosts and safely registers the server.
ix-cli/src/mcp/install.ts
Connections 22
- 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