# nikkel/gitaway architecture

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

- Interactive diagram: https://gitdiagram.com/nikkel/gitaway
- Repository: https://github.com/nikkel/gitaway

## Overview

gitaway wraps Git so users can keep their repository remotes unchanged: `git away` classifies the command and resolves a profile, checks whether the server is reachable at home by its pinned SSH host key, then either runs Git directly or routes that command through a local proxy and an in-process WireGuard tunnel. Separate CLI capabilities support guided setup, profile and key management, and a persistent tunnel for the server’s web interface. Several runtime modules are unsampled; those branches are included where the README or source index supports them, without inferring internal calls.

Main entry points: [`src/cli/away.rs`](https://github.com/nikkel/gitaway/blob/main/src/cli/away.rs) (Away workflow), [`src/cli/mod.rs`](https://github.com/nikkel/gitaway/blob/main/src/cli/mod.rs) (CLI dispatcher), [`src/cli/setup_cmd.rs`](https://github.com/nikkel/gitaway/blob/main/src/cli/setup_cmd.rs) (Guided setup), [`src/cli/tunnel_cmd.rs`](https://github.com/nikkel/gitaway/blob/main/src/cli/tunnel_cmd.rs) (Tunnel command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["CLI commands"]
  node_cli["CLI dispatcher<br/>[mod.rs]"]
  node_setup["Guided setup<br/>[setup_cmd.rs]"]
  node_profilecmd["Profile commands<br/>[profile_cmd.rs]"]
  node_tunnelcmd["Tunnel command<br/>[tunnel_cmd.rs]"]
  node_checkcmd["Home check command<br/>[check_cmd.rs]"]
end

subgraph group_profiles["Profiles and secrets"]
  node_profile["Profile model<br/>[profile.rs]"]
  node_configstore[("Config store<br/>[store.rs]")]
  node_resolver["Profile resolution<br/>[resolve.rs]"]
  node_keycmd["Key commands<br/>[key_cmd.rs]"]
  node_keystore[("Device key store<br/>[store.rs]")]
  node_setupimport["VPN config import<br/>[client_config.rs]"]
end

subgraph group_gitflow["Git command routing"]
  node_away["Away workflow<br/>[away.rs]"]
  node_classify["Git command classification<br/>[classify.rs]"]
  node_repo["Repository profile lookup<br/>[repo.rs]"]
  node_gitrunner["Git process runner<br/>[runner.rs]"]
  node_gitenv["Git proxy environment<br/>[git_env.rs]"]
end

subgraph group_connectivity["Home and tunnel"]
  node_homecheck["Pinned-key home check<br/>[home_check.rs]"]
  node_proxy["Per-command proxy<br/>[mod.rs]"]
  node_socks["SOCKS server<br/>[socks.rs]"]
  node_transport["Transport interface<br/>[mod.rs]"]
  node_wireguard["WireGuard tunnel<br/>[mod.rs]"]
  node_webguard["Web access guard<br/>[web_guard.rs]"]
end

node_user(("User"))
node_webserver(("Self-hosted Git server"))
node_git(("Installed Git"))

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_away
node_cli -->|"dispatches"| node_setup
node_cli -->|"dispatches"| node_profilecmd
node_cli -->|"dispatches"| node_tunnelcmd
node_cli -->|"dispatches"| node_checkcmd
node_cli -->|"dispatches"| node_keycmd
node_setup -->|"imports config"| node_setupimport
node_setup -->|"creates profile"| node_configstore
node_setup -->|"checks server"| node_homecheck
node_profilecmd -->|"manages profiles"| node_configstore
node_keycmd -.->|"manages keys"| node_keystore
node_configstore -->|"parses profiles"| node_profile
node_away -->|"classifies command"| node_classify
node_away -->|"queries repository"| node_repo
node_away -.->|"resolves profile"| node_resolver
node_away -.->|"checks home"| node_homecheck
node_away -->|"runs Git"| node_gitrunner
node_away -->|"starts proxy"| node_proxy
node_away -->|"configures Git"| node_gitenv
node_gitrunner -->|"executes"| node_git
node_gitenv -->|"sets proxy options"| node_git
node_proxy -->|"accepts connections"| node_socks
node_proxy -->|"opens tunnel streams"| node_transport
node_transport -->|"implements"| node_wireguard
node_transport -->|"loads tunnel secrets"| node_keystore
node_homecheck -->|"uses profile settings"| node_profile
node_tunnelcmd -->|"checks server"| node_homecheck
node_tunnelcmd -->|"guards web access"| node_webguard
node_tunnelcmd -->|"opens persistent tunnel"| node_transport
node_webguard -.->|"serves web access"| node_webserver
node_wireguard -.->|"connects through VPN"| node_webserver
node_wireguard -->|"uses device key"| node_keystore

click node_cli "https://github.com/nikkel/gitaway/blob/main/src/cli/mod.rs"
click node_setup "https://github.com/nikkel/gitaway/blob/main/src/cli/setup_cmd.rs"
click node_profilecmd "https://github.com/nikkel/gitaway/blob/main/src/cli/profile_cmd.rs"
click node_tunnelcmd "https://github.com/nikkel/gitaway/blob/main/src/cli/tunnel_cmd.rs"
click node_checkcmd "https://github.com/nikkel/gitaway/blob/main/src/cli/check_cmd.rs"
click node_profile "https://github.com/nikkel/gitaway/blob/main/src/config/profile.rs"
click node_configstore "https://github.com/nikkel/gitaway/blob/main/src/config/store.rs"
click node_resolver "https://github.com/nikkel/gitaway/blob/main/src/config/resolve.rs"
click node_keycmd "https://github.com/nikkel/gitaway/blob/main/src/cli/key_cmd.rs"
click node_keystore "https://github.com/nikkel/gitaway/blob/main/src/keys/store.rs"
click node_setupimport "https://github.com/nikkel/gitaway/blob/main/src/transport/client_config.rs"
click node_away "https://github.com/nikkel/gitaway/blob/main/src/cli/away.rs"
click node_classify "https://github.com/nikkel/gitaway/blob/main/src/git/classify.rs"
click node_repo "https://github.com/nikkel/gitaway/blob/main/src/git/repo.rs"
click node_gitrunner "https://github.com/nikkel/gitaway/blob/main/src/git/runner.rs"
click node_gitenv "https://github.com/nikkel/gitaway/blob/main/src/proxy/git_env.rs"
click node_homecheck "https://github.com/nikkel/gitaway/blob/main/src/home_check.rs"
click node_proxy "https://github.com/nikkel/gitaway/blob/main/src/proxy/mod.rs"
click node_socks "https://github.com/nikkel/gitaway/blob/main/src/proxy/socks.rs"
click node_transport "https://github.com/nikkel/gitaway/blob/main/src/transport/mod.rs"
click node_wireguard "https://github.com/nikkel/gitaway/blob/main/src/transport/wireguard/mod.rs"
click node_webguard "https://github.com/nikkel/gitaway/blob/main/src/cli/web_guard.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_cli,node_setup,node_profilecmd,node_tunnelcmd,node_checkcmd,node_user toneBlue
class node_profile,node_configstore,node_resolver,node_keycmd,node_keystore,node_setupimport toneAmber
class node_away,node_classify,node_repo,node_gitrunner,node_gitenv,node_webserver toneMint
class node_homecheck,node_proxy,node_socks,node_transport,node_wireguard,node_webguard toneRose
class node_git toneIndigo
```

## Components

### CLI commands

- [CLI dispatcher](https://github.com/nikkel/gitaway/blob/main/src/cli/mod.rs): `src/cli/mod.rs`
- [Guided setup](https://github.com/nikkel/gitaway/blob/main/src/cli/setup_cmd.rs): `src/cli/setup_cmd.rs`
- [Profile commands](https://github.com/nikkel/gitaway/blob/main/src/cli/profile_cmd.rs): `src/cli/profile_cmd.rs`
- [Tunnel command](https://github.com/nikkel/gitaway/blob/main/src/cli/tunnel_cmd.rs): `src/cli/tunnel_cmd.rs`
- [Home check command](https://github.com/nikkel/gitaway/blob/main/src/cli/check_cmd.rs): `src/cli/check_cmd.rs`

### Profiles and secrets

- [Profile model](https://github.com/nikkel/gitaway/blob/main/src/config/profile.rs): `src/config/profile.rs`
- [Config store](https://github.com/nikkel/gitaway/blob/main/src/config/store.rs): `src/config/store.rs`
- [Profile resolution](https://github.com/nikkel/gitaway/blob/main/src/config/resolve.rs): `src/config/resolve.rs`
- [Key commands](https://github.com/nikkel/gitaway/blob/main/src/cli/key_cmd.rs): `src/cli/key_cmd.rs`
- [Device key store](https://github.com/nikkel/gitaway/blob/main/src/keys/store.rs): `src/keys/store.rs`
- [VPN config import](https://github.com/nikkel/gitaway/blob/main/src/transport/client_config.rs): `src/transport/client_config.rs`

### Git command routing

- [Away workflow](https://github.com/nikkel/gitaway/blob/main/src/cli/away.rs): `src/cli/away.rs`
- [Git command classification](https://github.com/nikkel/gitaway/blob/main/src/git/classify.rs): `src/git/classify.rs`
- [Repository profile lookup](https://github.com/nikkel/gitaway/blob/main/src/git/repo.rs): `src/git/repo.rs`
- [Git process runner](https://github.com/nikkel/gitaway/blob/main/src/git/runner.rs): `src/git/runner.rs`
- [Git proxy environment](https://github.com/nikkel/gitaway/blob/main/src/proxy/git_env.rs): `src/proxy/git_env.rs`

### Home and tunnel

- [Pinned-key home check](https://github.com/nikkel/gitaway/blob/main/src/home_check.rs): `src/home_check.rs`
- [Per-command proxy](https://github.com/nikkel/gitaway/blob/main/src/proxy/mod.rs): `src/proxy/mod.rs`
- [SOCKS server](https://github.com/nikkel/gitaway/blob/main/src/proxy/socks.rs): `src/proxy/socks.rs`
- [Transport interface](https://github.com/nikkel/gitaway/blob/main/src/transport/mod.rs): `src/transport/mod.rs`
- [WireGuard tunnel](https://github.com/nikkel/gitaway/blob/main/src/transport/wireguard/mod.rs): `src/transport/wireguard/mod.rs`
- [Web access guard](https://github.com/nikkel/gitaway/blob/main/src/cli/web_guard.rs): `src/cli/web_guard.rs`

### Other components

- **User**
- **Self-hosted Git server**
- **Installed Git**

## Connections

- User → CLI dispatcher: invokes (evidence: `README.md`)
- CLI dispatcher → Away workflow: dispatches (evidence: `src/cli/mod.rs`)
- CLI dispatcher → Guided setup: dispatches (evidence: `src/cli/mod.rs`)
- CLI dispatcher → Profile commands: dispatches (evidence: `src/cli/mod.rs`)
- CLI dispatcher → Tunnel command: dispatches (evidence: `src/cli/mod.rs`)
- CLI dispatcher → Home check command: dispatches (evidence: `src/cli/mod.rs`)
- CLI dispatcher → Key commands: dispatches (evidence: `src/cli/mod.rs`)
- Guided setup → VPN config import: imports config (evidence: `src/cli/setup_cmd.rs`)
- Guided setup → Config store: creates profile (evidence: `src/cli/setup_cmd.rs`)
- Guided setup → Pinned-key home check: checks server (evidence: `src/cli/setup_cmd.rs`)
- Profile commands → Config store: manages profiles (evidence: `src/cli/profile_cmd.rs`)
- Key commands → Device key store: manages keys
- Config store → Profile model: parses profiles (evidence: `src/config/store.rs`)
- Away workflow → Git command classification: classifies command (evidence: `src/cli/mod.rs`)
- Away workflow → Repository profile lookup: queries repository (evidence: `src/cli/away.rs`)
- Away workflow → Profile resolution: resolves profile
- Away workflow → Pinned-key home check: checks home
- Away workflow → Git process runner: runs Git (evidence: `src/cli/away.rs`)
- Away workflow → Per-command proxy: starts proxy (evidence: `src/cli/away.rs`)
- Away workflow → Git proxy environment: configures Git (evidence: `src/cli/away.rs`)
- Git process runner → Installed Git: executes (evidence: `README.md`)
- Git proxy environment → Installed Git: sets proxy options (evidence: `README.md`)
- Per-command proxy → SOCKS server: accepts connections (evidence: `src/proxy/mod.rs`)
- Per-command proxy → Transport interface: opens tunnel streams (evidence: `src/proxy/mod.rs`)
- Transport interface → WireGuard tunnel: implements (evidence: `src/transport/mod.rs`)
- Transport interface → Device key store: loads tunnel secrets (evidence: `src/transport/mod.rs`)
- Pinned-key home check → Profile model: uses profile settings (evidence: `src/home_check.rs`)
- Tunnel command → Pinned-key home check: checks server (evidence: `src/cli/tunnel_cmd.rs`)
- Tunnel command → Web access guard: guards web access (evidence: `src/cli/tunnel_cmd.rs`)
- Tunnel command → Transport interface: opens persistent tunnel (evidence: `src/cli/tunnel_cmd.rs`)
- Web access guard → Self-hosted Git server: serves web access
- WireGuard tunnel → Self-hosted Git server: connects through VPN
- WireGuard tunnel → Device key store: uses device key (evidence: `src/transport/wireguard/mod.rs`)
