# ulgut/minprof architecture

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

- Interactive diagram: https://gitdiagram.com/ulgut/minprof
- Repository: https://github.com/ulgut/minprof

## Overview

minprof is a streaming, multi-pass JVM heap-dump analyzer. Users parse a `.hprof` file into a reusable disk index, then generate histogram, retained-heap, leak, package, and optional object-to-GC-root reports without reparsing. The graph preserves the documented four-pass analysis and report-format branches. Some wiring is only described at the README level; dashed, uncited links indicate relationships whose implementation was not shown.

Main entry points: [`src/passes/index/mod.rs`](https://github.com/ulgut/minprof/blob/master/src/passes/index/mod.rs) (Object and class index), [`src/passes/edges/mod.rs`](https://github.com/ulgut/minprof/blob/master/src/passes/edges/mod.rs) (Reference edges), [`src/query/mod.rs`](https://github.com/ulgut/minprof/blob/master/src/query/mod.rs) (Heap queries), [`src/parser/record_stream_parser.rs`](https://github.com/ulgut/minprof/blob/master/src/parser/record_stream_parser.rs) (Record stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Dump ingestion"]
  node_stream["Record stream"]
  node_header["File header"]
  node_primitive["Primitive parsing"]
  node_gc["GC record types<br/>[gc_record.rs]"]
end

subgraph group_analysis["Heap analysis"]
  node_pass1["Object and class index<br/>[mod.rs]"]
  node_pass2["Reference edges<br/>[mod.rs]"]
  node_sort["External sorting<br/>[sort.rs]"]
  node_pass3["Dominator tree<br/>[mod.rs]"]
  node_pass4["Retained sizes<br/>[mod.rs]"]
end

subgraph group_indexing["Disk index"]
  node_indexfiles[("Reusable index files<br/>[mod.rs]")]
  node_manifest["Index manifest<br/>[manifest.rs]"]
end

subgraph group_reports["Queries and reports"]
  node_query["Heap queries<br/>[mod.rs]"]
  node_pathquery["GC-root path<br/>[mod.rs]"]
  node_html["HTML report<br/>[html.rs]"]
  node_outputs["Text and JSON reports<br/>[mod.rs]"]
end

node_user(("User"))
node_cli["CLI workflow<br/>[main.rs]"]
node_hprof["HPROF dump"]

node_user -->|"runs"| node_cli
node_cli -->|"selects input"| node_hprof
node_hprof -.->|"streams records"| node_stream
node_stream -->|"parses header"| node_header
node_header -->|"uses parsers"| node_primitive
node_stream -.->|"feeds pass 1"| node_pass1
node_stream -.->|"feeds pass 2"| node_pass2
node_pass1 -.->|"sorts index"| node_sort
node_pass2 -.->|"sorts edges"| node_sort
node_pass1 -.->|"interprets records"| node_gc
node_pass2 -.->|"interprets fields"| node_gc
node_pass1 -->|"provides class index"| node_pass2
node_pass2 -->|"provides edges"| node_pass3
node_pass3 -->|"provides dominators"| node_pass4
node_pass1 -->|"writes object data"| node_indexfiles
node_pass3 -->|"writes idom"| node_indexfiles
node_pass4 -->|"writes retained data"| node_indexfiles
node_cli -.->|"validates index"| node_manifest
node_cli -->|"selects reports"| node_query
node_indexfiles -->|"reads index"| node_query
node_query -->|"resolves requested path"| node_pathquery
node_query -->|"renders HTML"| node_html
node_query -->|"formats results"| node_outputs

click node_cli "https://github.com/ulgut/minprof/blob/master/src/main.rs"
click node_stream "https://github.com/ulgut/minprof/blob/master/src/parser/record_stream_parser.rs"
click node_header "https://github.com/ulgut/minprof/blob/master/src/parser/file_header_parser.rs"
click node_primitive "https://github.com/ulgut/minprof/blob/master/src/parser/primitive_parsers.rs"
click node_gc "https://github.com/ulgut/minprof/blob/master/src/parser/gc_record.rs"
click node_pass1 "https://github.com/ulgut/minprof/blob/master/src/passes/index/mod.rs"
click node_pass2 "https://github.com/ulgut/minprof/blob/master/src/passes/edges/mod.rs"
click node_sort "https://github.com/ulgut/minprof/blob/master/src/passes/sort.rs"
click node_pass3 "https://github.com/ulgut/minprof/blob/master/src/passes/dominators/mod.rs"
click node_pass4 "https://github.com/ulgut/minprof/blob/master/src/passes/retained/mod.rs"
click node_indexfiles "https://github.com/ulgut/minprof/blob/master/src/index/mod.rs"
click node_manifest "https://github.com/ulgut/minprof/blob/master/src/index/manifest.rs"
click node_query "https://github.com/ulgut/minprof/blob/master/src/query/mod.rs"
click node_pathquery "https://github.com/ulgut/minprof/blob/master/src/query/mod.rs"
click node_html "https://github.com/ulgut/minprof/blob/master/src/query/html.rs"
click node_outputs "https://github.com/ulgut/minprof/blob/master/src/query/mod.rs"

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_stream,node_header,node_primitive,node_gc,node_user toneBlue
class node_pass1,node_pass2,node_sort,node_pass3,node_pass4 toneAmber
class node_indexfiles,node_manifest toneMint
class node_query,node_pathquery,node_html,node_outputs toneRose
class node_cli toneTeal
class node_hprof toneIndigo
```

## Components

### Dump ingestion

- [Record stream](https://github.com/ulgut/minprof/blob/master/src/parser/record_stream_parser.rs): `src/parser/record_stream_parser.rs`
- [File header](https://github.com/ulgut/minprof/blob/master/src/parser/file_header_parser.rs): `src/parser/file_header_parser.rs`
- [Primitive parsing](https://github.com/ulgut/minprof/blob/master/src/parser/primitive_parsers.rs): `src/parser/primitive_parsers.rs`
- [GC record types](https://github.com/ulgut/minprof/blob/master/src/parser/gc_record.rs): `src/parser/gc_record.rs`

### Heap analysis

- [Object and class index](https://github.com/ulgut/minprof/blob/master/src/passes/index/mod.rs): `src/passes/index/mod.rs`
- [Reference edges](https://github.com/ulgut/minprof/blob/master/src/passes/edges/mod.rs): `src/passes/edges/mod.rs`
- [External sorting](https://github.com/ulgut/minprof/blob/master/src/passes/sort.rs): `src/passes/sort.rs`
- [Dominator tree](https://github.com/ulgut/minprof/blob/master/src/passes/dominators/mod.rs): `src/passes/dominators/mod.rs`
- [Retained sizes](https://github.com/ulgut/minprof/blob/master/src/passes/retained/mod.rs): `src/passes/retained/mod.rs`

### Disk index

- [Reusable index files](https://github.com/ulgut/minprof/blob/master/src/index/mod.rs): `src/index/mod.rs`
- [Index manifest](https://github.com/ulgut/minprof/blob/master/src/index/manifest.rs): `src/index/manifest.rs`

### Queries and reports

- [Heap queries](https://github.com/ulgut/minprof/blob/master/src/query/mod.rs): `src/query/mod.rs`
- [GC-root path](https://github.com/ulgut/minprof/blob/master/src/query/mod.rs): `src/query/mod.rs`
- [HTML report](https://github.com/ulgut/minprof/blob/master/src/query/html.rs): `src/query/html.rs`
- [Text and JSON reports](https://github.com/ulgut/minprof/blob/master/src/query/mod.rs): `src/query/mod.rs`

### Other components

- **User**
- [CLI workflow](https://github.com/ulgut/minprof/blob/master/src/main.rs): `src/main.rs`
- **HPROF dump**

## Connections

- User → CLI workflow: runs (evidence: `README.md`)
- CLI workflow → HPROF dump: selects input (evidence: `README.md`)
- HPROF dump → Record stream: streams records
- Record stream → File header: parses header (evidence: `src/parser/record_stream_parser.rs`)
- File header → Primitive parsing: uses parsers (evidence: `src/parser/file_header_parser.rs`)
- Record stream → Object and class index: feeds pass 1 (evidence: `src/passes/index/mod.rs`)
- Record stream → Reference edges: feeds pass 2 (evidence: `src/passes/edges/mod.rs`)
- Object and class index → External sorting: sorts index (evidence: `src/passes/index/mod.rs`)
- Reference edges → External sorting: sorts edges (evidence: `src/passes/edges/mod.rs`)
- Object and class index → GC record types: interprets records (evidence: `src/passes/index/mod.rs`)
- Reference edges → GC record types: interprets fields (evidence: `src/passes/edges/mod.rs`)
- Object and class index → Reference edges: provides class index (evidence: `README.md`)
- Reference edges → Dominator tree: provides edges (evidence: `README.md`)
- Dominator tree → Retained sizes: provides dominators (evidence: `README.md`)
- Object and class index → Reusable index files: writes object data (evidence: `README.md`)
- Dominator tree → Reusable index files: writes idom (evidence: `README.md`)
- Retained sizes → Reusable index files: writes retained data (evidence: `README.md`)
- CLI workflow → Index manifest: validates index
- CLI workflow → Heap queries: selects reports (evidence: `README.md`)
- Reusable index files → Heap queries: reads index (evidence: `README.md`)
- Heap queries → GC-root path: resolves requested path (evidence: `README.md`)
- Heap queries → HTML report: renders HTML (evidence: `src/query/mod.rs`)
- Heap queries → Text and JSON reports: formats results (evidence: `README.md`)
