# caarlos0/svu architecture

> Architecture diagram of the GitHub repository caarlos0/svu, 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/caarlos0/svu
- Repository: https://github.com/caarlos0/svu

## Overview

svu is a semantic-version utility exposed as a CLI and Go API. The main workflow selects an action, finds the relevant Git tag and (for automatic or prerelease calculations) reads commit history, then classifies changes and returns a formatted version. The CLI also loads YAML/environment configuration and can initialize a config file. The sampled sources show these calls directly; Git history and tag selection are implemented through subprocesses. The graph does not assume additional stages beyond the sampled implementation.

Main entry points: [`internal/svu/svu.go`](https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go) (Version engine), [`main.go`](https://github.com/caarlos0/svu/blob/main/main.go) (Commands and flags), [`internal/git/git.go`](https://github.com/caarlos0/svu/blob/main/internal/git/git.go) (Tag and log operations), [`pkg/svu/svu.go`](https://github.com/caarlos0/svu/blob/main/pkg/svu/svu.go) (Go API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_commands["Commands and flags<br/>[main.go]"]
  node_configuration["Configuration<br/>[main.go]"]
end

subgraph group_versioning["Versioning core"]
  node_version_engine["Version engine<br/>[svu.go]"]
  node_change_rules["Change classification<br/>[svu.go]"]
  node_version_output["Version formatting<br/>[svu.go]"]
end

subgraph group_integration["Git and API"]
  node_git_ops["Tag and log operations<br/>[git.go]"]
  node_go_api["Go API<br/>[svu.go]"]
end

node_user(("CLI user"))
node_git_repo[("Git repository")]
node_config_file["User config file"]
node_stdout(("Standard output"))

node_user -->|"runs command"| node_commands
node_commands -->|"calls Version"| node_version_engine
node_commands -->|"loads settings"| node_configuration
node_configuration -->|"reads or writes"| node_config_file
node_version_engine -->|"gets tag and log"| node_git_ops
node_git_ops -->|"runs Git commands"| node_git_repo
node_version_engine -->|"classifies commits"| node_change_rules
node_version_engine -->|"formats result"| node_version_output
node_commands -->|"prints version"| node_stdout
node_go_api -->|"calls Version"| node_version_engine

click node_commands "https://github.com/caarlos0/svu/blob/main/main.go"
click node_configuration "https://github.com/caarlos0/svu/blob/main/main.go"
click node_version_engine "https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go"
click node_change_rules "https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go"
click node_version_output "https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go"
click node_git_ops "https://github.com/caarlos0/svu/blob/main/internal/git/git.go"
click node_go_api "https://github.com/caarlos0/svu/blob/main/pkg/svu/svu.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_commands,node_configuration,node_user,node_config_file toneBlue
class node_version_engine,node_change_rules,node_version_output,node_git_repo toneAmber
class node_git_ops,node_go_api toneMint
class node_stdout toneIndigo
```

## Components

### CLI

- [Commands and flags](https://github.com/caarlos0/svu/blob/main/main.go): `main.go`
- [Configuration](https://github.com/caarlos0/svu/blob/main/main.go): `main.go`

### Versioning core

- [Version engine](https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go): `internal/svu/svu.go`
- [Change classification](https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go): `internal/svu/svu.go`
- [Version formatting](https://github.com/caarlos0/svu/blob/main/internal/svu/svu.go): `internal/svu/svu.go`

### Git and API

- [Tag and log operations](https://github.com/caarlos0/svu/blob/main/internal/git/git.go): `internal/git/git.go`
- [Go API](https://github.com/caarlos0/svu/blob/main/pkg/svu/svu.go): `pkg/svu/svu.go`

### Other components

- **CLI user**
- **Git repository**
- **User config file**
- **Standard output**

## Connections

- CLI user → Commands and flags: runs command (evidence: `main.go`)
- Commands and flags → Version engine: calls Version (evidence: `main.go`)
- Commands and flags → Configuration: loads settings (evidence: `main.go`)
- Configuration → User config file: reads or writes (evidence: `main.go`)
- Version engine → Tag and log operations: gets tag and log (evidence: `internal/svu/svu.go`)
- Tag and log operations → Git repository: runs Git commands (evidence: `internal/git/git.go`)
- Version engine → Change classification: classifies commits (evidence: `internal/svu/svu.go`)
- Version engine → Version formatting: formats result (evidence: `internal/svu/svu.go`)
- Commands and flags → Standard output: prints version (evidence: `main.go`)
- Go API → Version engine: calls Version (evidence: `pkg/svu/svu.go`)
