# technologicat/pyan architecture

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

- Interactive diagram: https://gitdiagram.com/technologicat/pyan
- Repository: https://github.com/technologicat/pyan

## Overview

Pyan3 is an offline Python static-analysis tool: a user supplies source files through the CLI or Python API, the analyzer builds a graph of definitions and uses, and the tool emits a visual or text representation. A separate module-level mode analyzes import dependencies and detects cycles. The graph model, postprocessing, and rendering form the principal internal layer; documented filtering, path queries, and Sphinx integration are represented without assuming details of unsampled implementations. Relationships are limited to README statements and sampled source references.

Main entry points: [`pyan/main.py`](https://github.com/technologicat/pyan/blob/master/pyan/main.py) (CLI and API), [`pyan/analyzer.py`](https://github.com/technologicat/pyan/blob/master/pyan/analyzer.py) (AST analysis), [`pyan/callgraph.py`](https://github.com/technologicat/pyan/blob/master/pyan/callgraph.py) (Call graph state), [`pyan/visgraph.py`](https://github.com/technologicat/pyan/blob/master/pyan/visgraph.py) (Visual graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Inputs and entry points"]
  node_python_sources["Python sources"]
  node_entrypoint["CLI and API<br/>[main.py]"]
end

subgraph group_analysis["Static analysis"]
  node_ast_analysis["AST analysis<br/>[analyzer.py]"]
  node_anonymous_scopes["Anonymous scopes<br/>[anonscopes.py]"]
  node_recognizers["Pattern recognizers<br/>[recognizers.py]"]
  node_analysis_utilities["Analysis utilities<br/>[anutils.py]"]
  node_module_analysis["Import analysis<br/>[modvis.py]"]
end

subgraph group_graph["Graph processing"]
  node_graph_state["Call graph state<br/>[callgraph.py]"]
  node_graph_nodes["Graph nodes<br/>[node.py]"]
  node_postprocessing["Graph postprocessing<br/>[postprocessor.py]"]
  node_graph_queries["Graph queries<br/>[callgraph.py]"]
end

subgraph group_output["Output and integrations"]
  node_visual_graph["Visual graph<br/>[visgraph.py]"]
  node_writers["Format writers<br/>[writers.py]"]
  node_results["Graph output"]
  node_sphinx["Sphinx integration<br/>[sphinx.py]"]
end

node_user(("User"))

node_user -->|"invokes"| node_entrypoint
node_python_sources -->|"provides inputs"| node_entrypoint
node_entrypoint -->|"runs analysis"| node_ast_analysis
node_entrypoint -->|"dispatches mode"| node_module_analysis
node_ast_analysis -->|"uses scope plans"| node_anonymous_scopes
node_ast_analysis -->|"uses recognizers"| node_recognizers
node_ast_analysis -->|"uses utilities"| node_analysis_utilities
node_ast_analysis -->|"populates graph"| node_graph_state
node_graph_state -->|"stores nodes"| node_graph_nodes
node_ast_analysis -->|"postprocesses graph"| node_postprocessing
node_graph_state -->|"supports queries"| node_graph_queries
node_entrypoint -->|"prepares output graph"| node_visual_graph
node_visual_graph -->|"labels nodes"| node_graph_nodes
node_entrypoint -->|"selects writer"| node_writers
node_visual_graph -.->|"provides graph"| node_writers
node_writers -->|"emits formats"| node_results
node_entrypoint -->|"supports integration"| node_sphinx

click node_entrypoint "https://github.com/technologicat/pyan/blob/master/pyan/main.py"
click node_ast_analysis "https://github.com/technologicat/pyan/blob/master/pyan/analyzer.py"
click node_anonymous_scopes "https://github.com/technologicat/pyan/blob/master/pyan/anonscopes.py"
click node_recognizers "https://github.com/technologicat/pyan/blob/master/pyan/recognizers.py"
click node_analysis_utilities "https://github.com/technologicat/pyan/blob/master/pyan/anutils.py"
click node_module_analysis "https://github.com/technologicat/pyan/blob/master/pyan/modvis.py"
click node_graph_state "https://github.com/technologicat/pyan/blob/master/pyan/callgraph.py"
click node_graph_nodes "https://github.com/technologicat/pyan/blob/master/pyan/node.py"
click node_postprocessing "https://github.com/technologicat/pyan/blob/master/pyan/postprocessor.py"
click node_graph_queries "https://github.com/technologicat/pyan/blob/master/pyan/callgraph.py"
click node_visual_graph "https://github.com/technologicat/pyan/blob/master/pyan/visgraph.py"
click node_writers "https://github.com/technologicat/pyan/blob/master/pyan/writers.py"
click node_sphinx "https://github.com/technologicat/pyan/blob/master/pyan/sphinx.py"

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_python_sources,node_entrypoint,node_user toneBlue
class node_ast_analysis,node_anonymous_scopes,node_recognizers,node_analysis_utilities,node_module_analysis toneAmber
class node_graph_state,node_graph_nodes,node_postprocessing,node_graph_queries toneMint
class node_visual_graph,node_writers,node_results,node_sphinx toneRose
```

## Components

### Inputs and entry points

- **Python sources**
- [CLI and API](https://github.com/technologicat/pyan/blob/master/pyan/main.py): `pyan/main.py`

### Static analysis

- [AST analysis](https://github.com/technologicat/pyan/blob/master/pyan/analyzer.py): `pyan/analyzer.py`
- [Anonymous scopes](https://github.com/technologicat/pyan/blob/master/pyan/anonscopes.py): `pyan/anonscopes.py`
- [Pattern recognizers](https://github.com/technologicat/pyan/blob/master/pyan/recognizers.py): `pyan/recognizers.py`
- [Analysis utilities](https://github.com/technologicat/pyan/blob/master/pyan/anutils.py): `pyan/anutils.py`
- [Import analysis](https://github.com/technologicat/pyan/blob/master/pyan/modvis.py): `pyan/modvis.py`

### Graph processing

- [Call graph state](https://github.com/technologicat/pyan/blob/master/pyan/callgraph.py): `pyan/callgraph.py`
- [Graph nodes](https://github.com/technologicat/pyan/blob/master/pyan/node.py): `pyan/node.py`
- [Graph postprocessing](https://github.com/technologicat/pyan/blob/master/pyan/postprocessor.py): `pyan/postprocessor.py`
- [Graph queries](https://github.com/technologicat/pyan/blob/master/pyan/callgraph.py): `pyan/callgraph.py`

### Output and integrations

- [Visual graph](https://github.com/technologicat/pyan/blob/master/pyan/visgraph.py): `pyan/visgraph.py`
- [Format writers](https://github.com/technologicat/pyan/blob/master/pyan/writers.py): `pyan/writers.py`
- **Graph output**
- [Sphinx integration](https://github.com/technologicat/pyan/blob/master/pyan/sphinx.py): `pyan/sphinx.py`

### Other components

- **User**

## Connections

- User → CLI and API: invokes (evidence: `README.md`)
- Python sources → CLI and API: provides inputs (evidence: `README.md`)
- CLI and API → AST analysis: runs analysis (evidence: `pyan/main.py`)
- CLI and API → Import analysis: dispatches mode (evidence: `pyan/main.py`)
- AST analysis → Anonymous scopes: uses scope plans (evidence: `pyan/analyzer.py`)
- AST analysis → Pattern recognizers: uses recognizers (evidence: `pyan/analyzer.py`)
- AST analysis → Analysis utilities: uses utilities (evidence: `pyan/analyzer.py`)
- AST analysis → Call graph state: populates graph (evidence: `pyan/analyzer.py`)
- Call graph state → Graph nodes: stores nodes (evidence: `pyan/callgraph.py`)
- AST analysis → Graph postprocessing: postprocesses graph (evidence: `pyan/analyzer.py`)
- Call graph state → Graph queries: supports queries (evidence: `pyan/callgraph.py`)
- CLI and API → Visual graph: prepares output graph (evidence: `pyan/main.py`)
- Visual graph → Graph nodes: labels nodes (evidence: `pyan/visgraph.py`)
- CLI and API → Format writers: selects writer (evidence: `pyan/main.py`)
- Visual graph → Format writers: provides graph
- Format writers → Graph output: emits formats (evidence: `README.md`)
- CLI and API → Sphinx integration: supports integration (evidence: `README.md`)
