# hexmostech/git-lrc architecture

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

- Interactive diagram: https://gitdiagram.com/hexmostech/git-lrc
- Repository: https://github.com/hexmostech/git-lrc

## Overview

#### Purpose and Entry Points
`git-lrc` is a Go CLI that enforces AI-assisted code review at Git commit time, plus manual review, setup, connector management, hook management, and self-update commands. The executable starts at `main.go`; command registration/dispatch is centered in `cmd/app.go`. It is invoked as `lrc` or `git lrc`, and Git hooks route commit events into the CLI.

#### Commit Hook Enforcement
Global/per-repository Git hook installation and lifecycle management form the enforcement boundary. Shell hook templates invoke a dispatcher, which calls the binary before a commit proceeds; repository enablement can override global behavior.
- `hooks/managed.go`
- `hooks/operations.go`
- `hooks/dispatcher.sh`

The pre-commit path launches the review/vouch/skip decision flow; commit-message handling appends the review attestation to Git history.
- `hooks/pre-commit.sh`
- `hooks/prepare-commit-msg.sh`
- `internal/appcore/attestation_flow.go`

#### Review Orchestration and State
`internal/appcore` is the application service layer coordinating repository inspection, diff selection, review launch, user decisions, and final commit continuation/abort. It separates command/UI concerns from review protocol, persistence, and Git-facing operations.
- `internal/appcore/review_runtime.go`
- `internal/appcore/repository_context.go`
- `internal/appcore/review_state.go`

Review modes accept staged diffs, commits, or ranges. Review iterations and final-diff coverage are computed and attached as `ran`, `vouched`, or `skipped` attestations.
- `attestation/coverage_compute.go`
- `attestation/diffparse.go`
- `attestation/db.go`

#### Local Review Service and Browser UI
A local HTTP server exposes review data and actions, then opens a browser-based diff viewer. The backend contract/model layers isolate review responses and persistence from rendering; static HTML/JS supplies the issue navigator, inline comments, event log, decision controls, and summary UI.
- `internal/reviewapi/helpers.go`
- `internal/reviewdb/service.go`
- `internal/reviewhtml/template.go`
- `internal/staticserve/static_serve.go`
- `internal/staticserve/static/index.html`

This is a local browser UI, not a hosted web application; it communicates with the CLI-hosted local service.

#### Remote Services and AI Connectors
The network layer encapsulates HTTP calls for review execution, setup/authentication, UI connector operations, and update manifests. LiveReview coordinates reviews/account functions, while the selected BYOK provider supplies model inference. Supported providers include Gemini, OpenAI, Claude/Anthropic-compatible endpoints, DeepSeek, OpenRouter, and Atlas Cloud.
- `network/review_client.go`
- `network/setup_client.go`
- `network/ui_client.go`
- `config/ai_connectors.go`

Connector configuration is managed through a separate local UI flow and persisted locally.
- `internal/appui/ui_connectors.go`
- `internal/appui/ui_connectors_handlers.go`
- `internal/staticserve/static/ui-connectors.html`

#### Setup, Authentication, and Local Persistence
Guided setup provisions credentials and deployment configuration, using a local login/callback server to complete browser-based authentication. App state, connector config, review sessions, hook files, and SQLite-backed review/attestation records are mediated through `storage`, keeping filesystem/database I/O outside orchestration logic.
- `setup/login_server.go`
- `setup/provision.go`
- `storage/config_io.go`
- `storage/sqlite_query_io.go`
- `storage/review_sessions_queries.go`

#### Repository Policy Context and Distribution
Per-repo `.lrc` rules and ignore patterns are loaded, validated, and assembled into bounded reviewer context; ignored paths are excluded before external review submission. Claude Code integration installs/maintains complementary hooks and assets. Binary updates use signed/checksummed manifest-oriented update logic.
- `internal/lrcrules/lrcrules.go`
- `internal/lrcrules/ignore.go`
- `internal/appcore/claude_hooks_management.go`
- `internal/selfupdate/self_update.go`

Main entry points: [`internal/appcore/review_runtime.go`](https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/review_runtime.go) (Review orchestration), [`cmd/app.go`](https://github.com/hexmostech/git-lrc/blob/main/cmd/app.go) (Command dispatch), [`storage/config_io.go`](https://github.com/hexmostech/git-lrc/blob/main/storage/config_io.go) (Local storage I/O), [`hooks/dispatcher.sh`](https://github.com/hexmostech/git-lrc/blob/main/hooks/dispatcher.sh) (Hook dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI &amp; Git Enforcement"]
  node_entry["CLI entrypoint<br/>Go executable<br/>[main.go]"]
  node_commands["Command dispatch<br/>Cobra app<br/>[app.go]"]
  node_hook_management["Hook lifecycle<br/>Git hook manager<br/>[managed.go]"]
  node_hook_dispatcher["Hook dispatcher<br/>shell dispatcher<br/>[dispatcher.sh]"]
  node_precommit["Pre-commit review gate<br/>Git hook<br/>[pre-commit.sh]"]
  node_commit_message["Commit attestation hook<br/>Git hook"]
end

subgraph group_core["Review Runtime"]
  node_review_runtime["Review orchestration<br/>application service<br/>[review_runtime.go]"]
  node_repository_context["Repository context<br/>Git inspection"]
  node_review_state["Review state<br/>review lifecycle<br/>[review_state.go]"]
  node_attestation_flow["Attestation decisions<br/>commit decision flow"]
  node_policy["Repository policy<br/>.lrc rules<br/>[lrcrules.go]"]
  node_attestations["Coverage &amp; attestations<br/>diff coverage"]
end

subgraph group_local["Local UI &amp; Persistence"]
  node_review_api["Local review API<br/>HTTP service<br/>[helpers.go]"]
  node_browser_ui["Browser diff viewer<br/>local static UI<br/>[index.html]"]
  node_review_store[("Review persistence<br/>SQLite service<br/>[service.go]")]
  node_storage[("Local storage I/O<br/>persistence boundary<br/>[config_io.go]")]
  node_setup_auth["Setup &amp; browser login<br/>provisioning service<br/>[login_server.go]"]
  node_connector_ui["Connector management UI<br/>local configuration UI<br/>[ui_connectors.go]"]
end

subgraph group_remote["Remote Services"]
  node_review_service{{"LiveReview service<br/>remote review API<br/>[review_client.go]"}}
  node_ai_connectors{{"BYOK model providers<br/>AI connector config<br/>[ai_connectors.go]"}}
  node_self_update["Signed self-update<br/>update client<br/>[self_update.go]"]
end

node_entry -->|"starts"| node_commands
node_commands -->|"manages hooks"| node_hook_management
node_hook_management -->|"installs"| node_hook_dispatcher
node_hook_dispatcher -->|"routes pre-commit"| node_precommit
node_hook_dispatcher -->|"routes commit message"| node_commit_message
node_precommit -->|"enforces review"| node_review_runtime
node_commands -->|"manual review"| node_review_runtime
node_review_runtime -->|"inspects repository"| node_repository_context
node_repository_context -->|"loads rules"| node_policy
node_policy -->|"filtered context"| node_review_runtime
node_review_runtime -->|"tracks session"| node_review_state
node_review_runtime -->|"submits review"| node_review_service
node_review_service -->|"uses selected provider"| node_ai_connectors
node_review_runtime -->|"hosts local review"| node_review_api
node_review_api -->|"serves data and actions"| node_browser_ui
node_review_api -->|"reads and writes"| node_review_store
node_review_state -->|"persists sessions"| node_storage
node_review_store -->|"SQLite I/O"| node_storage
node_review_runtime -->|"computes coverage"| node_attestations
node_attestations -->|"attaches outcome"| node_attestation_flow
node_attestation_flow -->|"appends attestation"| node_commit_message
node_commands -->|"runs setup"| node_setup_auth
node_setup_auth -->|"stores credentials"| node_storage
node_commands -->|"manages connectors"| node_connector_ui
node_connector_ui -->|"configures"| node_ai_connectors
node_connector_ui -->|"persists configuration"| node_storage
node_commands -->|"updates binary"| node_self_update

click node_entry "https://github.com/hexmostech/git-lrc/blob/main/main.go"
click node_commands "https://github.com/hexmostech/git-lrc/blob/main/cmd/app.go"
click node_hook_management "https://github.com/hexmostech/git-lrc/blob/main/hooks/managed.go"
click node_hook_dispatcher "https://github.com/hexmostech/git-lrc/blob/main/hooks/dispatcher.sh"
click node_precommit "https://github.com/hexmostech/git-lrc/blob/main/hooks/pre-commit.sh"
click node_commit_message "https://github.com/hexmostech/git-lrc/blob/main/hooks/prepare-commit-msg.sh"
click node_review_runtime "https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/review_runtime.go"
click node_repository_context "https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/repository_context.go"
click node_review_state "https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/review_state.go"
click node_attestation_flow "https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/attestation_flow.go"
click node_policy "https://github.com/hexmostech/git-lrc/blob/main/internal/lrcrules/lrcrules.go"
click node_attestations "https://github.com/hexmostech/git-lrc/blob/main/attestation/coverage_compute.go"
click node_review_api "https://github.com/hexmostech/git-lrc/blob/main/internal/reviewapi/helpers.go"
click node_browser_ui "https://github.com/hexmostech/git-lrc/blob/main/internal/staticserve/static/index.html"
click node_review_store "https://github.com/hexmostech/git-lrc/blob/main/internal/reviewdb/service.go"
click node_storage "https://github.com/hexmostech/git-lrc/blob/main/storage/config_io.go"
click node_setup_auth "https://github.com/hexmostech/git-lrc/blob/main/setup/login_server.go"
click node_connector_ui "https://github.com/hexmostech/git-lrc/blob/main/internal/appui/ui_connectors.go"
click node_review_service "https://github.com/hexmostech/git-lrc/blob/main/network/review_client.go"
click node_ai_connectors "https://github.com/hexmostech/git-lrc/blob/main/config/ai_connectors.go"
click node_self_update "https://github.com/hexmostech/git-lrc/blob/main/internal/selfupdate/self_update.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_entry,node_commands,node_hook_management,node_hook_dispatcher,node_precommit,node_commit_message toneBlue
class node_review_runtime,node_repository_context,node_review_state,node_attestation_flow,node_policy,node_attestations toneAmber
class node_review_api,node_browser_ui,node_review_store,node_storage,node_setup_auth,node_connector_ui toneMint
class node_review_service,node_ai_connectors,node_self_update toneRose
```

## Components

### CLI & Git Enforcement

- [CLI entrypoint](https://github.com/hexmostech/git-lrc/blob/main/main.go): Go executable · `main.go`
- [Command dispatch](https://github.com/hexmostech/git-lrc/blob/main/cmd/app.go): Cobra app · `cmd/app.go`
- [Hook lifecycle](https://github.com/hexmostech/git-lrc/blob/main/hooks/managed.go): Git hook manager · Installs and manages global or repository hook behavior. · `hooks/managed.go`
- [Hook dispatcher](https://github.com/hexmostech/git-lrc/blob/main/hooks/dispatcher.sh): shell dispatcher · `hooks/dispatcher.sh`
- [Pre-commit review gate](https://github.com/hexmostech/git-lrc/blob/main/hooks/pre-commit.sh): Git hook · `hooks/pre-commit.sh`
- [Commit attestation hook](https://github.com/hexmostech/git-lrc/blob/main/hooks/prepare-commit-msg.sh): Git hook · `hooks/prepare-commit-msg.sh`

### Review Runtime

- [Review orchestration](https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/review_runtime.go): application service · Selects diffs, launches review, and continues or aborts commits. · `internal/appcore/review_runtime.go`
- [Repository context](https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/repository_context.go): Git inspection · `internal/appcore/repository_context.go`
- [Review state](https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/review_state.go): review lifecycle · `internal/appcore/review_state.go`
- [Attestation decisions](https://github.com/hexmostech/git-lrc/blob/main/internal/appcore/attestation_flow.go): commit decision flow · Records ran, vouched, or skipped review outcomes. · `internal/appcore/attestation_flow.go`
- [Repository policy](https://github.com/hexmostech/git-lrc/blob/main/internal/lrcrules/lrcrules.go): .lrc rules · Filters ignored paths and bounds reviewer context. · `internal/lrcrules/lrcrules.go`
- [Coverage & attestations](https://github.com/hexmostech/git-lrc/blob/main/attestation/coverage_compute.go): diff coverage · `attestation/coverage_compute.go`

### Local UI & Persistence

- [Local review API](https://github.com/hexmostech/git-lrc/blob/main/internal/reviewapi/helpers.go): HTTP service · `internal/reviewapi/helpers.go`
- [Browser diff viewer](https://github.com/hexmostech/git-lrc/blob/main/internal/staticserve/static/index.html): local static UI · Displays diffs, comments, events, and decision controls. · `internal/staticserve/static/index.html`
- [Review persistence](https://github.com/hexmostech/git-lrc/blob/main/internal/reviewdb/service.go): SQLite service · Stores review sessions and attestation records. · `internal/reviewdb/service.go`
- [Local storage I/O](https://github.com/hexmostech/git-lrc/blob/main/storage/config_io.go): persistence boundary · Mediates config, sessions, files, and SQLite access. · `storage/config_io.go`
- [Setup & browser login](https://github.com/hexmostech/git-lrc/blob/main/setup/login_server.go): provisioning service · `setup/login_server.go`
- [Connector management UI](https://github.com/hexmostech/git-lrc/blob/main/internal/appui/ui_connectors.go): local configuration UI · `internal/appui/ui_connectors.go`

### Remote Services

- [LiveReview service](https://github.com/hexmostech/git-lrc/blob/main/network/review_client.go): remote review API · Executes reviews and account operations. · `network/review_client.go`
- [BYOK model providers](https://github.com/hexmostech/git-lrc/blob/main/config/ai_connectors.go): AI connector config · Selects Gemini, OpenAI, Anthropic-compatible, DeepSeek, OpenRouter, or Atlas Cloud. · `config/ai_connectors.go`
- [Signed self-update](https://github.com/hexmostech/git-lrc/blob/main/internal/selfupdate/self_update.go): update client · `internal/selfupdate/self_update.go`

## Connections

- CLI entrypoint → Command dispatch: starts
- Command dispatch → Hook lifecycle: manages hooks
- Hook lifecycle → Hook dispatcher: installs
- Hook dispatcher → Pre-commit review gate: routes pre-commit
- Hook dispatcher → Commit attestation hook: routes commit message
- Pre-commit review gate → Review orchestration: enforces review
- Command dispatch → Review orchestration: manual review
- Review orchestration → Repository context: inspects repository
- Repository context → Repository policy: loads rules
- Repository policy → Review orchestration: filtered context
- Review orchestration → Review state: tracks session
- Review orchestration → LiveReview service: submits review
- LiveReview service → BYOK model providers: uses selected provider
- Review orchestration → Local review API: hosts local review
- Local review API → Browser diff viewer: serves data and actions
- Local review API → Review persistence: reads and writes
- Review state → Local storage I/O: persists sessions
- Review persistence → Local storage I/O: SQLite I/O
- Review orchestration → Coverage & attestations: computes coverage
- Coverage & attestations → Attestation decisions: attaches outcome
- Attestation decisions → Commit attestation hook: appends attestation
- Command dispatch → Setup & browser login: runs setup
- Setup & browser login → Local storage I/O: stores credentials
- Command dispatch → Connector management UI: manages connectors
- Connector management UI → BYOK model providers: configures
- Connector management UI → Local storage I/O: persists configuration
- Command dispatch → Signed self-update: updates binary
