# carstenbund/gitview architecture

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

- Interactive diagram: https://gitdiagram.com/carstenbund/gitview
- Repository: https://github.com/carstenbund/gitview

## Overview

GitView is a Git-history analysis CLI that turns repository commits into structured phases, evidence-backed analysis, and narrative reports. Its principal workflow extracts commit and repository metadata, chunks history, summarizes phases, generates a global story, and writes outputs. Separate commands expose compact briefs, persistent repository graphs, structural observations and motif detection, storyline tracking, and file/branch history tools. Edges are limited to README-documented flows and relationships visible in the supplied excerpts or SOURCE INDEX; unsampled command wiring is not inferred.

Main entry points: [`gitview/commands/analyze.py`](https://github.com/carstenbund/gitview/blob/main/gitview/commands/analyze.py) (Analysis command), [`gitview/adaptive/agent.py`](https://github.com/carstenbund/gitview/blob/main/gitview/adaptive/agent.py) (Adaptive analysis), [`gitview/evidence.py`](https://github.com/carstenbund/gitview/blob/main/gitview/evidence.py) (Evidence synthesis), [`gitview/commands/brief.py`](https://github.com/carstenbund/gitview/blob/main/gitview/commands/brief.py) (Agent brief)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["History analysis"]
  node_extract["History extraction<br/>[extractor.py]"]
  node_chunk["Phase chunking<br/>[chunker.py]"]
  node_adaptive["Adaptive analysis<br/>[agent.py]"]
  node_significance["Significance analysis"]
end

subgraph group_evidence["Repository evidence"]
  node_evidence["Evidence synthesis<br/>[evidence.py]"]
  node_graphupdater["Graph synchronization<br/>[updater.py]"]
  node_graphstore[("Persistent graph<br/>[store.py]")]
  node_motifs["Motif detection<br/>[engine.py]"]
  node_structural["Structural analysis<br/>[graphify.py]"]
end

subgraph group_narrative["Narratives"]
  node_summarize["Phase summaries<br/>[summarizer.py]"]
  node_story["Global storytelling<br/>[storyteller.py]"]
  node_writer["Report output<br/>[writer.py]"]
  node_storylines["Storyline tracking<br/>[tracker.py]"]
end

subgraph group_integrations["LLM and GitHub"]
  node_github["GitHub enrichment<br/>[github_enricher.py]"]
  node_llmrouter["LLM routing<br/>[router.py]"]
  node_llmservice["LLM providers<br/>[base.py]"]
end

subgraph group_commands["CLI capabilities"]
  node_analyze["Analysis command<br/>[analyze.py]"]
  node_brief["Agent brief<br/>[brief.py]"]
  node_graphcmd["Graph command<br/>[graph.py]"]
  node_observe["Observe command<br/>[observe.py]"]
  node_motifcmd["Motifs command<br/>[motifs.py]"]
  node_storylinecmd["Storyline commands<br/>[list.py]"]
  node_filetools["File history tools<br/>[track_files.py]"]
  node_branchtools["Branch comparison"]
end

node_user(("Engineer"))
node_githubservice["GitHub API"]
node_llmexternal["LLM services"]

node_user -->|"runs analysis"| node_analyze
node_analyze -->|"extracts history"| node_extract
node_analyze -->|"chunks history"| node_chunk
node_analyze -->|"summarizes phases"| node_summarize
node_analyze -->|"generates story"| node_story
node_analyze -->|"writes report"| node_writer
node_analyze -->|"supports adaptive mode"| node_adaptive
node_adaptive -->|"extracts discoveries"| node_extract
node_adaptive -->|"rechunks phases"| node_chunk
node_adaptive -->|"requests summaries"| node_summarize
node_adaptive -->|"requests narrative"| node_story
node_summarize -->|"requests completion"| node_llmrouter
node_story -->|"requests completion"| node_llmrouter
node_llmrouter -->|"dispatches provider"| node_llmservice
node_llmservice -.->|"calls model"| node_llmexternal
node_analyze -->|"enriches commits"| node_github
node_github -.->|"queries GraphQL"| node_githubservice
node_analyze -->|"builds evidence"| node_evidence
node_evidence -->|"synchronizes graph"| node_graphupdater
node_graphupdater -->|"updates store"| node_graphstore
node_evidence -->|"runs motifs"| node_motifs
node_motifs -->|"reads graph"| node_graphstore
node_user -->|"builds graph"| node_graphcmd
node_graphcmd -.->|"updates graph"| node_graphupdater
node_user -->|"records observation"| node_observe
node_observe -.->|"requests analysis"| node_structural
node_structural -.->|"stores observations"| node_graphstore
node_user -->|"detects motifs"| node_motifcmd
node_motifcmd -.->|"runs detection"| node_motifs
node_user -->|"requests digest"| node_brief
node_brief -->|"loads history"| node_extract
node_brief -->|"chunks history"| node_chunk
node_user -->|"inspects storylines"| node_storylinecmd
node_storylinecmd -->|"reads tracking"| node_storylines
node_storylines -.->|"provides storyline data"| node_storylinecmd
node_analyze -.->|"tracks narrative threads"| node_storylines
node_user -->|"tracks files"| node_filetools
node_user -->|"compares branches"| node_branchtools

click node_analyze "https://github.com/carstenbund/gitview/blob/main/gitview/commands/analyze.py"
click node_extract "https://github.com/carstenbund/gitview/blob/main/gitview/extractor.py"
click node_chunk "https://github.com/carstenbund/gitview/blob/main/gitview/chunker.py"
click node_summarize "https://github.com/carstenbund/gitview/blob/main/gitview/summarizer.py"
click node_story "https://github.com/carstenbund/gitview/blob/main/gitview/storyteller.py"
click node_writer "https://github.com/carstenbund/gitview/blob/main/gitview/writer.py"
click node_adaptive "https://github.com/carstenbund/gitview/blob/main/gitview/adaptive/agent.py"
click node_significance "https://github.com/carstenbund/gitview/blob/main/gitview/significance_analyzer.py"
click node_evidence "https://github.com/carstenbund/gitview/blob/main/gitview/evidence.py"
click node_graphupdater "https://github.com/carstenbund/gitview/blob/main/gitview/graph/updater.py"
click node_graphstore "https://github.com/carstenbund/gitview/blob/main/gitview/graph/store.py"
click node_motifs "https://github.com/carstenbund/gitview/blob/main/gitview/motifs/engine.py"
click node_structural "https://github.com/carstenbund/gitview/blob/main/gitview/structural/graphify.py"
click node_storylines "https://github.com/carstenbund/gitview/blob/main/gitview/storyline/tracker.py"
click node_github "https://github.com/carstenbund/gitview/blob/main/gitview/github_enricher.py"
click node_llmrouter "https://github.com/carstenbund/gitview/blob/main/gitview/backends/router.py"
click node_llmservice "https://github.com/carstenbund/gitview/blob/main/gitview/backends/base.py"
click node_brief "https://github.com/carstenbund/gitview/blob/main/gitview/commands/brief.py"
click node_graphcmd "https://github.com/carstenbund/gitview/blob/main/gitview/commands/graph.py"
click node_observe "https://github.com/carstenbund/gitview/blob/main/gitview/structural/observe.py"
click node_motifcmd "https://github.com/carstenbund/gitview/blob/main/gitview/commands/motifs.py"
click node_storylinecmd "https://github.com/carstenbund/gitview/blob/main/gitview/commands/storyline/list.py"
click node_filetools "https://github.com/carstenbund/gitview/blob/main/gitview/commands/track_files.py"
click node_branchtools "https://github.com/carstenbund/gitview/blob/main/gitview/commands/compare_branches.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_extract,node_chunk,node_adaptive,node_significance toneBlue
class node_evidence,node_graphupdater,node_graphstore,node_motifs,node_structural toneAmber
class node_summarize,node_story,node_writer,node_storylines,node_githubservice toneMint
class node_github,node_llmrouter,node_llmservice toneRose
class node_analyze,node_brief,node_graphcmd,node_observe,node_motifcmd,node_storylinecmd,node_filetools,node_branchtools,node_user,node_llmexternal toneIndigo
```

## Components

### History analysis

- [History extraction](https://github.com/carstenbund/gitview/blob/main/gitview/extractor.py): `gitview/extractor.py`
- [Phase chunking](https://github.com/carstenbund/gitview/blob/main/gitview/chunker.py): `gitview/chunker.py`
- [Adaptive analysis](https://github.com/carstenbund/gitview/blob/main/gitview/adaptive/agent.py): `gitview/adaptive/agent.py`
- [Significance analysis](https://github.com/carstenbund/gitview/blob/main/gitview/significance_analyzer.py): `gitview/significance_analyzer.py`

### Repository evidence

- [Evidence synthesis](https://github.com/carstenbund/gitview/blob/main/gitview/evidence.py): `gitview/evidence.py`
- [Graph synchronization](https://github.com/carstenbund/gitview/blob/main/gitview/graph/updater.py): `gitview/graph/updater.py`
- [Persistent graph](https://github.com/carstenbund/gitview/blob/main/gitview/graph/store.py): `gitview/graph/store.py`
- [Motif detection](https://github.com/carstenbund/gitview/blob/main/gitview/motifs/engine.py): `gitview/motifs/engine.py`
- [Structural analysis](https://github.com/carstenbund/gitview/blob/main/gitview/structural/graphify.py): `gitview/structural/graphify.py`

### Narratives

- [Phase summaries](https://github.com/carstenbund/gitview/blob/main/gitview/summarizer.py): `gitview/summarizer.py`
- [Global storytelling](https://github.com/carstenbund/gitview/blob/main/gitview/storyteller.py): `gitview/storyteller.py`
- [Report output](https://github.com/carstenbund/gitview/blob/main/gitview/writer.py): `gitview/writer.py`
- [Storyline tracking](https://github.com/carstenbund/gitview/blob/main/gitview/storyline/tracker.py): `gitview/storyline/tracker.py`

### LLM and GitHub

- [GitHub enrichment](https://github.com/carstenbund/gitview/blob/main/gitview/github_enricher.py): `gitview/github_enricher.py`
- [LLM routing](https://github.com/carstenbund/gitview/blob/main/gitview/backends/router.py): `gitview/backends/router.py`
- [LLM providers](https://github.com/carstenbund/gitview/blob/main/gitview/backends/base.py): `gitview/backends/base.py`

### CLI capabilities

- [Analysis command](https://github.com/carstenbund/gitview/blob/main/gitview/commands/analyze.py): `gitview/commands/analyze.py`
- [Agent brief](https://github.com/carstenbund/gitview/blob/main/gitview/commands/brief.py): `gitview/commands/brief.py`
- [Graph command](https://github.com/carstenbund/gitview/blob/main/gitview/commands/graph.py): `gitview/commands/graph.py`
- [Observe command](https://github.com/carstenbund/gitview/blob/main/gitview/structural/observe.py): `gitview/structural/observe.py`
- [Motifs command](https://github.com/carstenbund/gitview/blob/main/gitview/commands/motifs.py): `gitview/commands/motifs.py`
- [Storyline commands](https://github.com/carstenbund/gitview/blob/main/gitview/commands/storyline/list.py): `gitview/commands/storyline/list.py`
- [File history tools](https://github.com/carstenbund/gitview/blob/main/gitview/commands/track_files.py): `gitview/commands/track_files.py`
- [Branch comparison](https://github.com/carstenbund/gitview/blob/main/gitview/commands/compare_branches.py): `gitview/commands/compare_branches.py`

### Other components

- **Engineer**
- **GitHub API**
- **LLM services**

## Connections

- Engineer → Analysis command: runs analysis
- Analysis command → History extraction: extracts history (evidence: `gitview/commands/analyze.py`)
- Analysis command → Phase chunking: chunks history (evidence: `gitview/commands/analyze.py`)
- Analysis command → Phase summaries: summarizes phases (evidence: `gitview/commands/analyze.py`)
- Analysis command → Global storytelling: generates story (evidence: `gitview/commands/analyze.py`)
- Analysis command → Report output: writes report (evidence: `gitview/commands/analyze.py`)
- Analysis command → Adaptive analysis: supports adaptive mode (evidence: `gitview/commands/analyze.py`)
- Adaptive analysis → History extraction: extracts discoveries (evidence: `gitview/adaptive/agent.py`)
- Adaptive analysis → Phase chunking: rechunks phases (evidence: `gitview/adaptive/agent.py`)
- Adaptive analysis → Phase summaries: requests summaries (evidence: `gitview/adaptive/agent.py`)
- Adaptive analysis → Global storytelling: requests narrative (evidence: `gitview/adaptive/agent.py`)
- Phase summaries → LLM routing: requests completion (evidence: `gitview/summarizer.py`)
- Global storytelling → LLM routing: requests completion (evidence: `gitview/storyteller.py`)
- LLM routing → LLM providers: dispatches provider (evidence: `gitview/backends/router.py`)
- LLM providers → LLM services: calls model
- Analysis command → GitHub enrichment: enriches commits (evidence: `gitview/commands/analyze.py`)
- GitHub enrichment → GitHub API: queries GraphQL
- Analysis command → Evidence synthesis: builds evidence (evidence: `gitview/commands/analyze.py`)
- Evidence synthesis → Graph synchronization: synchronizes graph (evidence: `gitview/evidence.py`)
- Graph synchronization → Persistent graph: updates store (evidence: `gitview/graph/updater.py`)
- Evidence synthesis → Motif detection: runs motifs (evidence: `gitview/evidence.py`)
- Motif detection → Persistent graph: reads graph (evidence: `gitview/motifs/engine.py`)
- Engineer → Graph command: builds graph
- Graph command → Graph synchronization: updates graph
- Engineer → Observe command: records observation
- Observe command → Structural analysis: requests analysis
- Structural analysis → Persistent graph: stores observations
- Engineer → Motifs command: detects motifs
- Motifs command → Motif detection: runs detection
- Engineer → Agent brief: requests digest
- Agent brief → History extraction: loads history (evidence: `gitview/commands/brief.py`)
- Agent brief → Phase chunking: chunks history (evidence: `gitview/commands/brief.py`)
- Engineer → Storyline commands: inspects storylines
- Storyline commands → Storyline tracking: reads tracking (evidence: `gitview/commands/storyline/list.py`)
- Storyline tracking → Storyline commands: provides storyline data
- Analysis command → Storyline tracking: tracks narrative threads
- Engineer → File history tools: tracks files
- Engineer → Branch comparison: compares branches
