# unclebob/arch-view architecture

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

- Interactive diagram: https://gitdiagram.com/unclebob/arch-view
- Repository: https://github.com/unclebob/arch-view

## Overview

#### Purpose and entry point
`architecture-viewer` is a Clojure CLI tool that analyzes a target Clojure project, constructs a namespace dependency architecture, optionally exports it as EDN, and presents an interactive layered diagram. The application entry point is `src/arch_view/core.clj`; it supports project scanning, EDN-oriented headless output, and GUI sessions.

#### Input acquisition and dependency discovery
The analysis boundary is the target project directory and configured source paths. Source scanning locates Clojure files and captures namespace-to-source-path associations in `src/arch_view/input/source_scan.clj`. Namespace forms are parsed to extract project-local `:require` edges in `src/arch_view/input/dependency_extract.clj`, while `src/arch_view/input/dependency_checker.clj` filters or validates dependencies against the discovered project namespace set.

#### Domain projection and graph model
Raw namespace/dependency facts are transformed into an architecture projection in `src/arch_view/domain/architecture_projection.cljc`. The central dependency graph representation and graph operations live in `src/arch_view/model/graph.clj`. This model preserves dependency relationships, source locations, and cycle-related information for both output and rendering.

#### Component classification
Namespaces are classified into architectural roles, including leaf/source modules and higher-level groupings, by `src/arch_view/model/classify.clj`. Component/tree construction is handled by `src/arch_view/model/components.clj`. The classification also recognizes abstract namespaces from constructs such as protocols, multimethods, and interfaces, which affects visual treatment.

#### Cycle handling and layered layout
The architecture graph is made rankable by identifying cyclic dependencies and removing offending edges from the ordering graph, while retaining them as visible cycle indicators. `src/arch_view/layout/layers.clj` topologically ranks the resulting acyclic graph into vertical levels and peer groups. This creates the top-down view: high-level namespaces above leaf modules.

#### Interactive rendering and navigation
The desktop UI is a Quil-based canvas view, coordinated by `src/arch_view/render/ui/quil/view.clj`, `src/arch_view/render/ui/quil/canvas.clj`, and `src/arch_view/render/ui/quil/events.clj`. It renders modules, dependency triangles, cycle labels, scrollable content, and drill-down scenes. UI state—current root, navigation history, scrolling, and reanalysis state—is maintained through `src/arch_view/render/ui/util/scene_state.clj` and `src/arch_view/render/ui/util/view_bootstrap.clj`.

#### Source inspection and runtime boundaries
Clicking a leaf namespace opens a Swing source viewer implemented in `src/arch_view/render/ui/swing/source_window.clj`, with source markup support in `src/arch_view/render/ui/util/source_html.clj`. The tool runs on the Clojure/JVM runtime (`deps.edn`), uses Quil for the graphical canvas and Swing for source windows, and has no server or external service dependency. Target projects are read from the local filesystem; `--no-gui` keeps execution headless and emits architecture data rather than initializing UI runtime components.

Main entry points: [`src/arch_view/model/graph.clj`](https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/graph.clj) (Dependency graph), [`src/arch_view/core.clj`](https://github.com/unclebob/arch-view/blob/master/src/arch_view/core.clj) (CLI entry point), [`src/arch_view/input/source_scan.clj`](https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/source_scan.clj) (Source scanner), [`src/arch_view/render/ui/quil/view.clj`](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/view.clj) (Quil view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Project Analysis"]
  node_target[("Target project<br/>local filesystem")]
  node_scan["Source scanner<br/>namespace discovery<br/>[source_scan.clj]"]
  node_extract["Dependency extractor<br/>require parser"]
  node_check["Dependency checker<br/>dependency filter"]
end

subgraph group_model["Architecture Model"]
  node_projection["Architecture projection<br/>domain projection"]
  node_graph[("Dependency graph<br/>graph model<br/>[graph.clj]")]
  node_classify["Role classifier<br/>component classification<br/>[classify.clj]"]
  node_components["Component tree<br/>component model<br/>[components.clj]"]
end

subgraph group_layout["Layout"]
  node_layers["Layer ranking<br/>graph layout<br/>[layers.clj]"]
end

subgraph group_ui["Interactive UI"]
  node_bootstrap["View bootstrap<br/>UI lifecycle<br/>[view_bootstrap.clj]"]
  node_scene["Scene state<br/>UI state<br/>[scene_state.clj]"]
  node_quil["Quil view<br/>desktop UI coordinator<br/>[view.clj]"]
  node_canvas["Canvas renderer<br/>Quil renderer<br/>[canvas.clj]"]
  node_events["Canvas events<br/>Quil input<br/>[events.clj]"]
  node_source["Swing source viewer<br/>source inspection<br/>[source_window.clj]"]
end

node_cli["CLI entry point<br/>Clojure CLI<br/>[core.clj]"]
node_headless["EDN export<br/>headless output"]

node_cli -->|"analyzes"| node_target
node_target -->|"source paths"| node_scan
node_scan -->|"namespace files"| node_extract
node_scan -->|"known namespaces"| node_check
node_extract -->|"require edges"| node_check
node_check -->|"validated facts"| node_projection
node_projection -->|"builds"| node_graph
node_graph -->|"namespace graph"| node_classify
node_classify -->|"roles"| node_components
node_graph -->|"relationships"| node_components
node_components -->|"component graph"| node_layers
node_graph -->|"cycles"| node_layers
node_cli -.->|"--no-gui"| node_headless
node_cli -->|"GUI mode"| node_bootstrap
node_layers -->|"layered architecture"| node_bootstrap
node_bootstrap -->|"initializes"| node_scene
node_scene -->|"scene state"| node_quil
node_quil -->|"renders"| node_canvas
node_quil -->|"receives input"| node_events
node_events -->|"updates navigation"| node_scene
node_events -->|"selected leaf"| node_source

click node_cli "https://github.com/unclebob/arch-view/blob/master/src/arch_view/core.clj"
click node_scan "https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/source_scan.clj"
click node_extract "https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/dependency_extract.clj"
click node_check "https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/dependency_checker.clj"
click node_projection "https://github.com/unclebob/arch-view/blob/master/src/arch_view/domain/architecture_projection.cljc"
click node_graph "https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/graph.clj"
click node_classify "https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/classify.clj"
click node_components "https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/components.clj"
click node_layers "https://github.com/unclebob/arch-view/blob/master/src/arch_view/layout/layers.clj"
click node_bootstrap "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/util/view_bootstrap.clj"
click node_scene "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/util/scene_state.clj"
click node_quil "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/view.clj"
click node_canvas "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/canvas.clj"
click node_events "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/events.clj"
click node_source "https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/swing/source_window.clj"

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_target,node_scan,node_extract,node_check toneBlue
class node_projection,node_graph,node_classify,node_components toneAmber
class node_layers toneMint
class node_bootstrap,node_scene,node_quil,node_canvas,node_events,node_source toneRose
class node_cli,node_headless toneNeutral
```

## Components

### Project Analysis

Discovers local namespaces and dependency facts.

- **Target project**: local filesystem · Directory and configured source paths being analyzed.
- [Source scanner](https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/source_scan.clj): namespace discovery · Maps namespaces to Clojure source files. · `src/arch_view/input/source_scan.clj`
- [Dependency extractor](https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/dependency_extract.clj): require parser · Extracts project-local require edges. · `src/arch_view/input/dependency_extract.clj`
- [Dependency checker](https://github.com/unclebob/arch-view/blob/master/src/arch_view/input/dependency_checker.clj): dependency filter · Validates edges against discovered namespaces. · `src/arch_view/input/dependency_checker.clj`

### Architecture Model

Projects dependencies into classified components.

- [Architecture projection](https://github.com/unclebob/arch-view/blob/master/src/arch_view/domain/architecture_projection.cljc): domain projection · Transforms raw namespace facts into architecture data. · `src/arch_view/domain/architecture_projection.cljc`
- [Dependency graph](https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/graph.clj): graph model · Preserves dependencies, source locations, and cycle information. · `src/arch_view/model/graph.clj`
- [Role classifier](https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/classify.clj): component classification · Identifies leaf, grouped, and abstract namespaces. · `src/arch_view/model/classify.clj`
- [Component tree](https://github.com/unclebob/arch-view/blob/master/src/arch_view/model/components.clj): component model · Builds architectural component and tree structure. · `src/arch_view/model/components.clj`

### Layout

Ranks the graph while preserving cycle indicators.

- [Layer ranking](https://github.com/unclebob/arch-view/blob/master/src/arch_view/layout/layers.clj): graph layout · Removes ordering-cycle edges and assigns levels and peer groups. · `src/arch_view/layout/layers.clj`

### Interactive UI

Quil canvas navigation and Swing source inspection.

- [View bootstrap](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/util/view_bootstrap.clj): UI lifecycle · Initializes scenes and reanalysis state. · `src/arch_view/render/ui/util/view_bootstrap.clj`
- [Scene state](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/util/scene_state.clj): UI state · Tracks root, history, scrolling, and reanalysis. · `src/arch_view/render/ui/util/scene_state.clj`
- [Quil view](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/view.clj): desktop UI coordinator · Coordinates canvas rendering and interaction. · `src/arch_view/render/ui/quil/view.clj`
- [Canvas renderer](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/canvas.clj): Quil renderer · Draws modules, dependencies, cycle labels, and scenes. · `src/arch_view/render/ui/quil/canvas.clj`
- [Canvas events](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/quil/events.clj): Quil input · Handles navigation and leaf selection. · `src/arch_view/render/ui/quil/events.clj`
- [Swing source viewer](https://github.com/unclebob/arch-view/blob/master/src/arch_view/render/ui/swing/source_window.clj): source inspection · Opens selected leaf namespace source with markup. · `src/arch_view/render/ui/swing/source_window.clj`

### Other components

- [CLI entry point](https://github.com/unclebob/arch-view/blob/master/src/arch_view/core.clj): Clojure CLI · Selects headless export or GUI analysis session. · `src/arch_view/core.clj`
- **EDN export**: headless output · Emits architecture data without UI initialization.

## Connections

- CLI entry point → Target project: analyzes
- Target project → Source scanner: source paths
- Source scanner → Dependency extractor: namespace files
- Source scanner → Dependency checker: known namespaces
- Dependency extractor → Dependency checker: require edges
- Dependency checker → Architecture projection: validated facts
- Architecture projection → Dependency graph: builds
- Dependency graph → Role classifier: namespace graph
- Role classifier → Component tree: roles
- Dependency graph → Component tree: relationships
- Component tree → Layer ranking: component graph
- Dependency graph → Layer ranking: cycles
- CLI entry point → EDN export: --no-gui
- CLI entry point → View bootstrap: GUI mode
- Layer ranking → View bootstrap: layered architecture
- View bootstrap → Scene state: initializes
- Scene state → Quil view: scene state
- Quil view → Canvas renderer: renders
- Quil view → Canvas events: receives input
- Canvas events → Scene state: updates navigation
- Canvas events → Swing source viewer: selected leaf
