# ajmalbuv/blamr architecture

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

- Interactive diagram: https://gitdiagram.com/ajmalbuv/blamr
- Repository: https://github.com/ajmalbuv/blamr

## Overview

blamr is a Go CLI for concurrent Git blame attribution and per-author line statistics. Users invoke either command, configure file scope and attribution options, then receive terminal tables or JSON. The main runtime discovers tracked files, filters generated and non-text content, runs whitespace-resilient blame workers, parses porcelain attribution, aggregates statistics, and renders results. Both entry points share the same coordinator. The workflow and major README capabilities are represented; the graph uses the sampled source and README, without assuming unsampled implementation details.

Main entry points: [`internal/app/app.go`](https://github.com/ajmalbuv/blamr/blob/main/internal/app/app.go) (App coordinator), [`internal/blame/runner.go`](https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go) (Tracked-file discovery), [`internal/filter/filter.go`](https://github.com/ajmalbuv/blamr/blob/main/internal/filter/filter.go) (Unified file filter), [`cmd/blamr/main.go`](https://github.com/ajmalbuv/blamr/blob/main/cmd/blamr/main.go) (Standalone CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_standalone["Standalone CLI<br/>[main.go]"]
  node_gitcommand["Git subcommand<br/>[main.go]"]
  node_coordinator["App coordinator<br/>[app.go]"]
  node_configuration["CLI configuration<br/>[flags.go]"]
end

subgraph group_workflow["Attribution workflow"]
  node_discovery["Tracked-file discovery<br/>[runner.go]"]
  node_workers["Blame workers<br/>[runner.go]"]
  node_parser["Porcelain parser<br/>[parser.go]"]
  node_aggregation["Statistics aggregation<br/>[runner.go]"]
end

subgraph group_filtering["File filtering"]
  node_filefilter["Unified file filter<br/>[filter.go]"]
  node_generated["Generated-file rules<br/>[generated.go]"]
  node_binary["Binary inspection<br/>[binary.go]"]
end

subgraph group_presentation["Results"]
  node_terminal["Terminal output<br/>[terminal.go]"]
  node_json["JSON output<br/>[json.go]"]
end

node_user(("CLI user"))
node_git["Git"]

node_user -->|"invokes"| node_standalone
node_user -->|"invokes"| node_gitcommand
node_standalone -->|"runs"| node_coordinator
node_gitcommand -->|"runs"| node_coordinator
node_coordinator -->|"parses flags"| node_configuration
node_coordinator -->|"runs analysis"| node_discovery
node_discovery -->|"lists tracked files"| node_git
node_discovery -->|"filters files"| node_filefilter
node_filefilter -->|"checks generated names"| node_generated
node_filefilter -->|"checks binary content"| node_binary
node_discovery -->|"returns file list"| node_workers
node_workers -->|"runs blame"| node_git
node_workers -->|"parses output"| node_parser
node_workers -->|"collects results"| node_aggregation
node_coordinator -->|"checks terminal and renders"| node_terminal
node_coordinator -->|"serializes results"| node_json

click node_standalone "https://github.com/ajmalbuv/blamr/blob/main/cmd/blamr/main.go"
click node_gitcommand "https://github.com/ajmalbuv/blamr/blob/main/cmd/git-blamr/main.go"
click node_coordinator "https://github.com/ajmalbuv/blamr/blob/main/internal/app/app.go"
click node_configuration "https://github.com/ajmalbuv/blamr/blob/main/internal/config/flags.go"
click node_discovery "https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go"
click node_filefilter "https://github.com/ajmalbuv/blamr/blob/main/internal/filter/filter.go"
click node_generated "https://github.com/ajmalbuv/blamr/blob/main/internal/filter/generated.go"
click node_binary "https://github.com/ajmalbuv/blamr/blob/main/internal/filter/binary.go"
click node_workers "https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go"
click node_parser "https://github.com/ajmalbuv/blamr/blob/main/internal/blame/parser.go"
click node_aggregation "https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go"
click node_terminal "https://github.com/ajmalbuv/blamr/blob/main/internal/output/terminal.go"
click node_json "https://github.com/ajmalbuv/blamr/blob/main/internal/output/json.go"

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_standalone,node_gitcommand,node_coordinator,node_configuration,node_user toneBlue
class node_discovery,node_workers,node_parser,node_aggregation toneAmber
class node_filefilter,node_generated,node_binary toneMint
class node_terminal,node_json toneRose
class node_git toneIndigo
```

## Components

### CLI entry

- [Standalone CLI](https://github.com/ajmalbuv/blamr/blob/main/cmd/blamr/main.go): `cmd/blamr/main.go`
- [Git subcommand](https://github.com/ajmalbuv/blamr/blob/main/cmd/git-blamr/main.go): `cmd/git-blamr/main.go`
- [App coordinator](https://github.com/ajmalbuv/blamr/blob/main/internal/app/app.go): `internal/app/app.go`
- [CLI configuration](https://github.com/ajmalbuv/blamr/blob/main/internal/config/flags.go): `internal/config/flags.go`

### Attribution workflow

- [Tracked-file discovery](https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go): `internal/blame/runner.go`
- [Blame workers](https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go): `internal/blame/runner.go`
- [Porcelain parser](https://github.com/ajmalbuv/blamr/blob/main/internal/blame/parser.go): `internal/blame/parser.go`
- [Statistics aggregation](https://github.com/ajmalbuv/blamr/blob/main/internal/blame/runner.go): `internal/blame/runner.go`

### File filtering

- [Unified file filter](https://github.com/ajmalbuv/blamr/blob/main/internal/filter/filter.go): `internal/filter/filter.go`
- [Generated-file rules](https://github.com/ajmalbuv/blamr/blob/main/internal/filter/generated.go): `internal/filter/generated.go`
- [Binary inspection](https://github.com/ajmalbuv/blamr/blob/main/internal/filter/binary.go): `internal/filter/binary.go`

### Results

- [Terminal output](https://github.com/ajmalbuv/blamr/blob/main/internal/output/terminal.go): `internal/output/terminal.go`
- [JSON output](https://github.com/ajmalbuv/blamr/blob/main/internal/output/json.go): `internal/output/json.go`

### Other components

- **CLI user**
- **Git**

## Connections

- CLI user → Standalone CLI: invokes (evidence: `README.md`)
- CLI user → Git subcommand: invokes (evidence: `README.md`)
- Standalone CLI → App coordinator: runs (evidence: `cmd/blamr/main.go`)
- Git subcommand → App coordinator: runs (evidence: `cmd/git-blamr/main.go`)
- App coordinator → CLI configuration: parses flags (evidence: `internal/app/app.go`)
- App coordinator → Tracked-file discovery: runs analysis (evidence: `internal/app/app.go`)
- Tracked-file discovery → Git: lists tracked files (evidence: `internal/blame/runner.go`)
- Tracked-file discovery → Unified file filter: filters files (evidence: `internal/blame/runner.go`)
- Unified file filter → Generated-file rules: checks generated names (evidence: `internal/filter/filter.go`)
- Unified file filter → Binary inspection: checks binary content (evidence: `internal/filter/filter.go`)
- Tracked-file discovery → Blame workers: returns file list (evidence: `internal/blame/runner.go`)
- Blame workers → Git: runs blame (evidence: `internal/blame/runner.go`)
- Blame workers → Porcelain parser: parses output (evidence: `internal/blame/runner.go`)
- Blame workers → Statistics aggregation: collects results (evidence: `internal/blame/runner.go`)
- App coordinator → Terminal output: checks terminal and renders (evidence: `internal/app/app.go`)
- App coordinator → JSON output: serializes results (evidence: `internal/app/app.go`)
