# otherjl0/oatmeal architecture

> Architecture diagram of the GitHub repository otherjl0/oatmeal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/otherjl0/oatmeal
- Repository: https://github.com/otherjl0/oatmeal

## Overview

##### Main Components Overview

a. Core Layers:
- Application Layer (UI/CLI interface)
- Domain Layer (Core business logic)
- Infrastructure Layer (External integrations)

b. External Components:
- LLM Backends (OpenAI, Ollama, LangChain, Claude, Gemini)
- Editor Integrations (Neovim, Clipboard)
- Configuration System
- Session Management

**┌─────────────────────────────────────────────────────────────┐**
- Application Layer                        │
- ┬─────────────────────────┬──────────────────┤
- CLI       │          UI             │  Configuration    │
- ┬───────┴──────────┬──────────────┴────────┬─────────┘

**┌───────▼───────┬──────────▼──────────┬───────────▼─────────┐**
- Models        │     Services        │     Session Mgmt    │
- Message     │   - App State      │     - Persistence   │
- Author      │   - Actions        │     - History       │
- Session     │   - Events         │                     │
- ┬───────┴──────────┬──────────┴───────────┬─────────┘

**┌───────▼───────┬──────────▼──────────┬──────────▼─────────┐**
- LLM Backends   │  Editor Integration │  Syntax Highlight  │
- OpenAI       │   - Neovim         │   - Theme Engine   │
- Ollama       │   - Clipboard      │   - Language Det.  │
- Claude       │                    │                    │
- Gemini       │                    │                    │
- ┴────────────────────┴────────────────────┘

##### Key Architectural Elements to Highlight

a. Backend Integration System:
- How different LLM backends are abstracted
- Backend trait implementation
- Configuration paths for each backend

b. Editor Integration:
- Editor trait implementation
- Communication flow between editor and core system
- Clipboard as the default integration

c. Session Management:
- Persistence layer
- How sessions are loaded/saved
- Interaction with chat history

##### Implementation Details

- src/application/: UI and CLI interfaces
- src/domain/: Core business logic and models
- src/infrastructure/: External integrations
- src/configuration/: Config management

##### Testing Boundaries

- Unit test coverage
- Integration test coverage
- Snapshot test locations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AL["Application Layer"]
        CLI["CLI Interface"]
        UI["UI Interface"]
        Config["Configuration"]
    end

    subgraph DL["Domain Layer"]
        subgraph Models["Domain Models"]
            Message["Message Model"]
            Author["Author Model"]
            Session["Session Model"]
            Backend["Backend Model"]
            Editor["Editor Model"]
        end

        subgraph Services["Domain Services"]
            AppState["App State"]
            Actions["Actions"]
            Events["Events"]
            SessionSvc["Session Services"]
            Syntax["Syntax Highlighting"]
            Theme["Theme Engine"]
            Bubble["Bubble Management"]
            BubbleList["Bubble List"]
        end
    end

    subgraph IL["Infrastructure Layer"]
        subgraph LLM["LLM Backends"]
            OpenAI["OpenAI"]
            Ollama["Ollama"]
            Claude["Claude"]
            Gemini["Gemini"]
            LangChain["LangChain"]
        end

        subgraph EditorInt["Editor Integration"]
            Neovim["Neovim"]
            Clipboard["Clipboard"]
        end
    end

    %% Relationships
    CLI --> AppState
    UI --> AppState
    Config --> AppState

    AppState --> Services
    Services --> Models
    Services --> IL

    SessionSvc --> Session
    Actions --> Events
    Events --> AppState

    LLM --> Backend
    EditorInt --> Editor

    %% Click Events
    click CLI "https://github.com/otherJL0/oatmeal/blob/main/src/application/cli.rs"
    click UI "https://github.com/otherJL0/oatmeal/blob/main/src/application/ui.rs"
    click Config "https://github.com/otherJL0/oatmeal/blob/main/src/configuration/config.rs"
    click Message "https://github.com/otherJL0/oatmeal/blob/main/src/domain/models/message.rs"
    click Author "https://github.com/otherJL0/oatmeal/blob/main/src/domain/models/author.rs"
    click Session "https://github.com/otherJL0/oatmeal/blob/main/src/domain/models/session.rs"
    click Backend "https://github.com/otherJL0/oatmeal/blob/main/src/domain/models/backend.rs"
    click Editor "https://github.com/otherJL0/oatmeal/blob/main/src/domain/models/editor.rs"
    click AppState "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/app_state.rs"
    click Actions "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/actions.rs"
    click Events "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/events.rs"
    click SessionSvc "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/sessions.rs"
    click Syntax "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/syntaxes.rs"
    click Theme "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/themes.rs"
    click Bubble "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/bubble.rs"
    click BubbleList "https://github.com/otherJL0/oatmeal/blob/main/src/domain/services/bubble_list.rs"
    click OpenAI "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/backends/openai.rs"
    click Ollama "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/backends/ollama.rs"
    click Claude "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/backends/claude.rs"
    click Gemini "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/backends/gemini.rs"
    click LangChain "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/backends/langchain.rs"
    click Neovim "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/editors/neovim.rs"
    click Clipboard "https://github.com/otherJL0/oatmeal/blob/main/src/infrastructure/editors/clipboard.rs"

    %% Styling
    classDef application fill:#2374ab
    classDef domain fill:#48a9a6
    classDef infrastructure fill:#e4572e
    classDef models fill:#17bebb
    classDef services fill:#ffc914

    class AL application
    class DL domain
    class IL infrastructure
    class Models models
    class Services services
```
