Skip to content

Focused Architecture View

Large codebases have hundreds of files. A full architecture diagram is overwhelming and unreadable. When onboarding to a module, reviewing a PR, or assessing change impact, you need a scoped view — just the target file and its neighbourhood.

iw index focus builds exactly that: an N-hop subgraph around any target, with layer context, hub detection, and an interactive HTML report. Programmatically, the same data is available via CariIndex.focus() (or the focus() function from @intentweave/index) and rendered to HTML by focusReport.

Terminal window
# Build the index (if not already done)
iw index build
# Text output: see the neighbourhood of a file
iw index focus src/auth/service.ts
# Interactive HTML report
iw index export --focus src/auth/service.ts
open focus.html
Terminal window
iw index focus packages/cli/src/commands/indexBuild.ts
🔍 Focus: packages/cli/src/commands/indexBuild.ts
15 nodes · 17 edges · 2-hop view (25 in full neighbourhood)
Node Layer Dependents Hop
─────────────────────────── ──────────────────────────────── ────────── ────
⭐ indexBuild packages/cli + packages/index 1 0
cli packages/analyzer + packages/core 0 1
embed packages/cli + packages/index 0 1
evidence packages/cli + packages/index 0 1
impact packages/cli + packages/index 0 1
constants packages/cli + packages/index 13 2
...

The HTML report is a self-contained file (~200 KB) with three interactive views, pan/zoom controls, and an architecture insights panel.

Full Graph — import dependencies with architectural layer clusters

The target node (⭐ yellow) sits in the centre. Files are grouped into coloured architectural layer clusters derived from the import hierarchy. Arrows show import dependencies flowing from consumer to dependency.

The default view. Shows all edge types:

  • Solid dark arrows — import dependencies (A → B means A imports B)
  • Dashed orange lines — co-change signals (files that change together in git)
  • Dotted blue lines — documentation co-mentions (files discussed together in docs)

Nodes are grouped into layer clusters. Node size reflects transitive dependents: bigger nodes have more downstream impact if changed.

A linearised import flow through the target. Entry points (callers) on the left, the target in the middle, dependencies on the right. Useful for understanding data flow direction through a module.

The flow view filters the imports table to a directed path through the target, using the same focus() subgraph query with edge-type filtering applied by focusReport.

Nodes are collapsed by community into meta-groups. Instead of individual files, you see community clusters as single nodes connected by aggregate edges. Useful for understanding high-level module relationships when the full graph is too detailed.

Click the Insights button (top-right) to open the architecture insights panel. It provides automated analysis of the focused subgraph:

Architecture Insights panel — reading guide, data flow, layer breakdown, and hub alerts

SectionWhat It Shows
Target SummaryWhere the target sits, its layer, and transitive dependent count
How to Read This DiagramLegend explaining node colours, edge types, and interactions
Data FlowEntry points, connection depth, and leaf modules
Layer BreakdownPer-layer cards listing files, their role, and average hop distance
Hub NodesHigh-connectivity nodes with risk badges and splitting recommendations
Key ObservationsWarnings about truncation, same-layer coupling, upward violations
AI NarrativeLLM-generated architecture explanation (only with --explain)

The <target> argument is flexible. CARI tries to resolve it in order:

  1. Exact file pathsrc/auth/service.ts
  2. Partial filenameservice.ts (matches shortest path)
  3. Symbol nameAuthService (looks up the symbol registry)
  4. Annotation keywordauthentication (finds files annotated with the term)
  5. Natural language"user login flow" (TF-IDF ranked retrieval)
Terminal window
# All of these work:
iw index focus src/auth/service.ts # exact path
iw index focus service.ts # partial filename
iw index focus AuthService # symbol name
iw index focus "authentication" # keyword
iw index focus "user login flow" # natural language
FlagDefaultDescription
<target>(required)File path, symbol name, or keyword
-h, --hops <n>2Number of import-graph hops to expand
-n, --max-nodes <n>25Maximum nodes in the subgraph
-f, --format <fmt>textOutput format: text or json
--db <path>(auto)Path to index.db
FlagDefaultDescription
--focus <target>(required)File path, symbol name, or keyword
--hops <n>2Number of import-graph hops
--max-nodes <n>25Maximum nodes in the subgraph
-o, --output <path>focus.htmlOutput file path
--explain(off)Add LLM-narrated architecture explanation
--provider <name>LLM provider (openai or smart-mock)
--model <name>gpt-4o-miniModel for --explain
--db <path>(auto)Path to index.db

Add --explain to generate an AI architecture narrative in the insights panel:

Terminal window
iw index export --focus src/auth/service.ts --explain --provider openai

The narrative covers:

  • What the target module does and its responsibilities
  • How the layers are organized around it
  • Data and control flow patterns
  • Architectural risks and coupling concerns
  • Recommendations for newcomers exploring this area

The focused view is available as a Copilot tool:

"Show me the architecture around auth.ts" → cari_focus
ParameterDefaultDescription
target(required)File path, symbol, or keyword
hops2Expansion depth
maxNodes25Node limit
Terminal window
iw index export --focus src/pipeline/orchestrator.ts --hops 3 --explain --provider openai

New team members get an interactive map of the module’s neighbourhood with an AI-written explanation of what each layer does and how data flows through it.

Terminal window
iw index focus src/database/schema.ts --hops 2

Before merging a schema change, see exactly which files are in the blast radius — how many transitive dependents exist, which layers are affected, and where hub nodes concentrate risk.

Terminal window
iw index export --focus "AuthService" --hops 2 -o auth-architecture.html

Generate a focused report for a design review, scoped to just the authentication subsystem. Share the self-contained HTML with reviewers who don’t have the project checked out.