# elias-phy-ja/lernperiode-2 architecture

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

- Interactive diagram: https://gitdiagram.com/elias-phy-ja/lernperiode-2
- Repository: https://github.com/elias-phy-ja/lernperiode-2

## Overview

Shellmate is a terminal-based Gemini chatbot. On launch it loads local configuration, guides first-time users through API-key setup when needed, then routes slash commands or prompts through the chat loop; prompts go to Gemini with conversation history and responses render as Markdown. Settings support changing the model or key, resetting configuration and chat, and restoring the conversation. The README also documents help, usage guidance, chat clearing, and exit. Edges reflect the shown calls and documented Gemini integration; the HTTP service is represented by its implementation, not an inspected remote API.

Main entry points: [`src/Shellmate/Program.cs`](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Program.cs) (Chat loop), [`src/Shellmate/Services/GeminiService.cs`](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/GeminiService.cs) (Gemini service), [`src/Shellmate/Commands/CommandHandler.cs`](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Commands/CommandHandler.cs) (Command handler), [`src/Shellmate/UI/SettingsMenu.cs`](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/SettingsMenu.cs) (Settings menu)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Terminal runtime"]
  node_program["Chat loop<br/>[Program.cs]"]
  node_commands["Command handler<br/>[CommandHandler.cs]"]
end

subgraph group_setup["Setup and settings"]
  node_config["App configuration<br/>[AppConfig.cs]"]
  node_configservice[("Config persistence<br/>[ConfigService.cs]")]
  node_wizard["Setup wizard<br/>[SetupWizard.cs]"]
  node_settings["Settings menu<br/>[SettingsMenu.cs]"]
end

subgraph group_conversation["Gemini conversation"]
  node_gemini["Gemini service<br/>[GeminiService.cs]"]
  node_history["Chat messages<br/>[ChatMessage.cs]"]
  node_geminiapi{{"Gemini API"}}
  node_geminiexception["Gemini errors<br/>[GeminiException.cs]"]
end

subgraph group_presentation["Terminal presentation"]
  node_markdown["Markdown renderer"]
end

node_user(("Terminal user"))

node_user -->|"enters input"| node_program
node_program -->|"loads config"| node_configservice
node_configservice -->|"deserializes"| node_config
node_program -->|"starts setup"| node_wizard
node_wizard -->|"saves config"| node_configservice
node_wizard -->|"handles setup commands"| node_commands
node_program -->|"creates service"| node_gemini
node_program -->|"dispatches commands"| node_commands
node_program -->|"sends prompts"| node_gemini
node_program -->|"renders answers"| node_markdown
node_commands -->|"opens settings"| node_settings
node_commands -->|"clears history"| node_gemini
node_commands -->|"redraws replies"| node_markdown
node_gemini -->|"stores messages"| node_history
node_gemini -->|"posts prompt history"| node_geminiapi
node_gemini -->|"throws user errors"| node_geminiexception
node_settings -->|"saves or deletes"| node_configservice
node_settings -->|"applies config"| node_gemini
node_settings -->|"restarts setup"| node_wizard
node_settings -->|"restores chat"| node_commands

click node_program "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Program.cs"
click node_commands "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Commands/CommandHandler.cs"
click node_config "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Models/AppConfig.cs"
click node_configservice "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/ConfigService.cs"
click node_wizard "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/SetupWizard.cs"
click node_settings "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/SettingsMenu.cs"
click node_gemini "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/GeminiService.cs"
click node_history "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Models/ChatMessage.cs"
click node_geminiexception "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/GeminiException.cs"
click node_markdown "https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/MarkdownRenderer.cs"

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_program,node_commands,node_user toneBlue
class node_config,node_configservice,node_wizard,node_settings toneAmber
class node_gemini,node_history,node_geminiapi,node_geminiexception toneMint
class node_markdown toneRose
```

## Components

### Terminal runtime

- [Chat loop](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Program.cs): `src/Shellmate/Program.cs`
- [Command handler](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Commands/CommandHandler.cs): `src/Shellmate/Commands/CommandHandler.cs`

### Setup and settings

- [App configuration](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Models/AppConfig.cs): `src/Shellmate/Models/AppConfig.cs`
- [Config persistence](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/ConfigService.cs): `src/Shellmate/Services/ConfigService.cs`
- [Setup wizard](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/SetupWizard.cs): `src/Shellmate/UI/SetupWizard.cs`
- [Settings menu](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/SettingsMenu.cs): `src/Shellmate/UI/SettingsMenu.cs`

### Gemini conversation

- [Gemini service](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/GeminiService.cs): `src/Shellmate/Services/GeminiService.cs`
- [Chat messages](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Models/ChatMessage.cs): `src/Shellmate/Models/ChatMessage.cs`
- **Gemini API**
- [Gemini errors](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/Services/GeminiException.cs): `src/Shellmate/Services/GeminiException.cs`

### Terminal presentation

- [Markdown renderer](https://github.com/elias-phy-ja/lernperiode-2/blob/main/src/Shellmate/UI/MarkdownRenderer.cs): `src/Shellmate/UI/MarkdownRenderer.cs`

### Other components

- **Terminal user**

## Connections

- Terminal user → Chat loop: enters input (evidence: `src/Shellmate/Program.cs`)
- Chat loop → Config persistence: loads config (evidence: `src/Shellmate/Program.cs`)
- Config persistence → App configuration: deserializes (evidence: `src/Shellmate/Services/ConfigService.cs`)
- Chat loop → Setup wizard: starts setup (evidence: `src/Shellmate/Program.cs`)
- Setup wizard → Config persistence: saves config (evidence: `src/Shellmate/UI/SetupWizard.cs`)
- Setup wizard → Command handler: handles setup commands (evidence: `src/Shellmate/UI/SetupWizard.cs`)
- Chat loop → Gemini service: creates service (evidence: `src/Shellmate/Program.cs`)
- Chat loop → Command handler: dispatches commands (evidence: `src/Shellmate/Program.cs`)
- Chat loop → Gemini service: sends prompts (evidence: `src/Shellmate/Program.cs`)
- Chat loop → Markdown renderer: renders answers (evidence: `src/Shellmate/Program.cs`)
- Command handler → Settings menu: opens settings (evidence: `src/Shellmate/Commands/CommandHandler.cs`)
- Command handler → Gemini service: clears history (evidence: `src/Shellmate/Commands/CommandHandler.cs`)
- Command handler → Markdown renderer: redraws replies (evidence: `src/Shellmate/Commands/CommandHandler.cs`)
- Gemini service → Chat messages: stores messages (evidence: `src/Shellmate/Services/GeminiService.cs`)
- Gemini service → Gemini API: posts prompt history (evidence: `src/Shellmate/Services/GeminiService.cs`)
- Gemini service → Gemini errors: throws user errors (evidence: `src/Shellmate/Services/GeminiService.cs`)
- Settings menu → Config persistence: saves or deletes (evidence: `src/Shellmate/UI/SettingsMenu.cs`)
- Settings menu → Gemini service: applies config (evidence: `src/Shellmate/UI/SettingsMenu.cs`)
- Settings menu → Setup wizard: restarts setup (evidence: `src/Shellmate/UI/SettingsMenu.cs`)
- Settings menu → Command handler: restores chat (evidence: `src/Shellmate/UI/SettingsMenu.cs`)
