# brandon1024/gitchat architecture

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

- Interactive diagram: https://gitdiagram.com/brandon1024/gitchat
- Repository: https://github.com/brandon1024/gitchat

## Overview

git-chat is a command-line messaging application that stores channel conversations as Git commits and encrypts message text with GnuPG. The principal workflow is to compose a message, encrypt it, commit it on the current channel, publish it through Git, and later read messages; joining a channel involves importing public keys. The README documents channel management, configuration, and initialization as additional capabilities. Some command implementations were not sampled, so edges for those operations are limited to documented behavior; dashed edges mark relationships whose implementation was not verified.

Main entry points: [`src/git-chat.c`](https://github.com/brandon1024/gitchat/blob/master/src/git-chat.c) (Command dispatcher), [`src/builtin/message.c`](https://github.com/brandon1024/gitchat/blob/master/src/builtin/message.c) (Compose message), [`src/builtin/init.c`](https://github.com/brandon1024/gitchat/blob/master/src/builtin/init.c) (Initialize space), [`src/gnupg/gpg-common.c`](https://github.com/brandon1024/gitchat/blob/master/src/gnupg/gpg-common.c) (GPG context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["CLI commands"]
  node_cli["Command dispatcher<br/>[git-chat.c]"]
  node_init["Initialize space<br/>[init.c]"]
  node_channels["Manage channels<br/>[channel-create.c]"]
  node_channel_list["List channels<br/>[channel-list.c]"]
  node_import_key["Import keys<br/>[import-key.c]"]
  node_message["Compose message<br/>[message.c]"]
  node_read["Read messages<br/>[read.c]"]
  node_config_cmd["Manage config<br/>[config.c]"]
end

subgraph group_conversation["Conversation and Git"]
  node_git_repo[("Git repository")]
  node_git_ops["Git operations<br/>[git.c]"]
  node_commit["Commit handling<br/>[commit.c]"]
  node_history["History traversal<br/>[graph-traversal.c]"]
  node_index["Stage files<br/>[index.c]"]
end

subgraph group_crypto["Keys and encryption"]
  node_key_store["Channel key files<br/>[key-manager.c]"]
  node_gpg_context["GPG context<br/>[gpg-common.c]"]
  node_encryption["Encrypt messages<br/>[encryption.c]"]
  node_decryption["Decrypt messages<br/>[decryption.c]"]
end

subgraph group_foundation["Configuration and runtime"]
  node_config_parser["Parse config<br/>[parse-config.c]"]
  node_config_data["Config data<br/>[config-data.c]"]
  node_run_command["Run subprocesses<br/>[run-command.c]"]
  node_options["Parse options<br/>[parse-options.c]"]
end

node_user(("CLI user"))
node_upstream[("Git upstream")]

node_user -->|"runs commands"| node_cli
node_cli -.->|"dispatches"| node_init
node_cli -.->|"dispatches"| node_channels
node_cli -.->|"dispatches"| node_channel_list
node_cli -.->|"dispatches"| node_import_key
node_cli -.->|"dispatches"| node_message
node_cli -.->|"dispatches"| node_read
node_cli -.->|"dispatches"| node_config_cmd
node_init -->|"initializes"| node_git_repo
node_channels -->|"manages branches"| node_git_repo
node_channel_list -->|"lists refs"| node_git_repo
node_import_key -->|"imports keys"| node_key_store
node_import_key -->|"commits public keys"| node_git_repo
node_message -->|"encrypts text"| node_encryption
node_message -->|"commits message"| node_commit
node_read -.->|"reads history"| node_history
node_read -.->|"decrypts messages"| node_decryption
node_commit -->|"writes commits"| node_git_repo
node_git_repo -->|"pushes commits"| node_upstream
node_upstream -->|"pulls updates"| node_git_repo
node_config_cmd -.->|"reads or writes"| node_config_parser
node_config_parser -->|"parses data"| node_config_data
node_init -->|"invokes Git"| node_git_ops
node_init -->|"stages files"| node_index
node_message -->|"traverses commits"| node_history
node_message -->|"uses recipient keys"| node_key_store
node_message -->|"uses GPG"| node_gpg_context
node_encryption -->|"uses context"| node_gpg_context
node_decryption -.->|"uses context"| node_gpg_context
node_key_store -->|"manages keyring"| node_gpg_context
node_init -->|"sets up config"| node_config_parser
node_init -->|"runs subprocesses"| node_run_command
node_message -->|"runs subprocesses"| node_run_command
node_channel_list -->|"captures Git output"| node_run_command
node_message -->|"parses options"| node_options

click node_cli "https://github.com/brandon1024/gitchat/blob/master/src/git-chat.c"
click node_init "https://github.com/brandon1024/gitchat/blob/master/src/builtin/init.c"
click node_channels "https://github.com/brandon1024/gitchat/blob/master/src/builtin/channel-create.c"
click node_channel_list "https://github.com/brandon1024/gitchat/blob/master/src/builtin/channel-list.c"
click node_import_key "https://github.com/brandon1024/gitchat/blob/master/src/builtin/import-key.c"
click node_message "https://github.com/brandon1024/gitchat/blob/master/src/builtin/message.c"
click node_read "https://github.com/brandon1024/gitchat/blob/master/src/builtin/read.c"
click node_config_cmd "https://github.com/brandon1024/gitchat/blob/master/src/builtin/config.c"
click node_git_ops "https://github.com/brandon1024/gitchat/blob/master/src/git/git.c"
click node_commit "https://github.com/brandon1024/gitchat/blob/master/src/git/commit.c"
click node_history "https://github.com/brandon1024/gitchat/blob/master/src/git/graph-traversal.c"
click node_index "https://github.com/brandon1024/gitchat/blob/master/src/git/index.c"
click node_key_store "https://github.com/brandon1024/gitchat/blob/master/src/gnupg/key-manager.c"
click node_gpg_context "https://github.com/brandon1024/gitchat/blob/master/src/gnupg/gpg-common.c"
click node_encryption "https://github.com/brandon1024/gitchat/blob/master/src/gnupg/encryption.c"
click node_decryption "https://github.com/brandon1024/gitchat/blob/master/src/gnupg/decryption.c"
click node_config_parser "https://github.com/brandon1024/gitchat/blob/master/src/config/parse-config.c"
click node_config_data "https://github.com/brandon1024/gitchat/blob/master/src/config/config-data.c"
click node_run_command "https://github.com/brandon1024/gitchat/blob/master/src/run-command.c"
click node_options "https://github.com/brandon1024/gitchat/blob/master/src/parse-options.c"

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_init,node_channels,node_channel_list,node_import_key,node_message,node_read,node_config_cmd,node_user toneBlue
class node_git_repo,node_git_ops,node_commit,node_history,node_index,node_upstream toneAmber
class node_key_store,node_gpg_context,node_encryption,node_decryption toneMint
class node_config_parser,node_config_data,node_run_command,node_options toneRose
```

## Components

### CLI commands

- [Command dispatcher](https://github.com/brandon1024/gitchat/blob/master/src/git-chat.c): `src/git-chat.c`
- [Initialize space](https://github.com/brandon1024/gitchat/blob/master/src/builtin/init.c): `src/builtin/init.c`
- [Manage channels](https://github.com/brandon1024/gitchat/blob/master/src/builtin/channel-create.c): `src/builtin/channel-create.c`
- [List channels](https://github.com/brandon1024/gitchat/blob/master/src/builtin/channel-list.c): `src/builtin/channel-list.c`
- [Import keys](https://github.com/brandon1024/gitchat/blob/master/src/builtin/import-key.c): `src/builtin/import-key.c`
- [Compose message](https://github.com/brandon1024/gitchat/blob/master/src/builtin/message.c): `src/builtin/message.c`
- [Read messages](https://github.com/brandon1024/gitchat/blob/master/src/builtin/read.c): `src/builtin/read.c`
- [Manage config](https://github.com/brandon1024/gitchat/blob/master/src/builtin/config.c): `src/builtin/config.c`

### Conversation and Git

- **Git repository**
- [Git operations](https://github.com/brandon1024/gitchat/blob/master/src/git/git.c): `src/git/git.c`
- [Commit handling](https://github.com/brandon1024/gitchat/blob/master/src/git/commit.c): `src/git/commit.c`
- [History traversal](https://github.com/brandon1024/gitchat/blob/master/src/git/graph-traversal.c): `src/git/graph-traversal.c`
- [Stage files](https://github.com/brandon1024/gitchat/blob/master/src/git/index.c): `src/git/index.c`

### Keys and encryption

- [Channel key files](https://github.com/brandon1024/gitchat/blob/master/src/gnupg/key-manager.c): `src/gnupg/key-manager.c`
- [GPG context](https://github.com/brandon1024/gitchat/blob/master/src/gnupg/gpg-common.c): `src/gnupg/gpg-common.c`
- [Encrypt messages](https://github.com/brandon1024/gitchat/blob/master/src/gnupg/encryption.c): `src/gnupg/encryption.c`
- [Decrypt messages](https://github.com/brandon1024/gitchat/blob/master/src/gnupg/decryption.c): `src/gnupg/decryption.c`

### Configuration and runtime

- [Parse config](https://github.com/brandon1024/gitchat/blob/master/src/config/parse-config.c): `src/config/parse-config.c`
- [Config data](https://github.com/brandon1024/gitchat/blob/master/src/config/config-data.c): `src/config/config-data.c`
- [Run subprocesses](https://github.com/brandon1024/gitchat/blob/master/src/run-command.c): `src/run-command.c`
- [Parse options](https://github.com/brandon1024/gitchat/blob/master/src/parse-options.c): `src/parse-options.c`

### Other components

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

## Connections

- CLI user → Command dispatcher: runs commands
- Command dispatcher → Initialize space: dispatches
- Command dispatcher → Manage channels: dispatches
- Command dispatcher → List channels: dispatches
- Command dispatcher → Import keys: dispatches
- Command dispatcher → Compose message: dispatches
- Command dispatcher → Read messages: dispatches
- Command dispatcher → Manage config: dispatches
- Initialize space → Git repository: initializes
- Manage channels → Git repository: manages branches
- List channels → Git repository: lists refs (evidence: `src/builtin/channel-list.c`)
- Import keys → Channel key files: imports keys
- Import keys → Git repository: commits public keys
- Compose message → Encrypt messages: encrypts text
- Compose message → Commit handling: commits message
- Read messages → History traversal: reads history
- Read messages → Decrypt messages: decrypts messages
- Commit handling → Git repository: writes commits
- Git repository → Git upstream: pushes commits
- Git upstream → Git repository: pulls updates
- Manage config → Parse config: reads or writes
- Parse config → Config data: parses data (evidence: `src/config/parse-config.c`)
- Initialize space → Git operations: invokes Git (evidence: `src/builtin/init.c`)
- Initialize space → Stage files: stages files (evidence: `src/builtin/init.c`)
- Compose message → History traversal: traverses commits (evidence: `src/builtin/message.c`)
- Compose message → Channel key files: uses recipient keys (evidence: `src/builtin/message.c`)
- Compose message → GPG context: uses GPG (evidence: `src/builtin/message.c`)
- Encrypt messages → GPG context: uses context (evidence: `src/gnupg/encryption.c`)
- Decrypt messages → GPG context: uses context
- Channel key files → GPG context: manages keyring (evidence: `src/gnupg/key-manager.c`)
- Initialize space → Parse config: sets up config (evidence: `src/builtin/init.c`)
- Initialize space → Run subprocesses: runs subprocesses (evidence: `src/builtin/init.c`)
- Compose message → Run subprocesses: runs subprocesses (evidence: `src/builtin/message.c`)
- List channels → Run subprocesses: captures Git output (evidence: `src/builtin/channel-list.c`)
- Compose message → Parse options: parses options (evidence: `src/builtin/message.c`)
