# mockapapella/diffdev architecture

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

- Interactive diagram: https://gitdiagram.com/mockapapella/diffdev
- Repository: https://github.com/mockapapella/diffdev

## Overview

##### Main Components Identification

a) User Interface Layer:
- CLI Interface (cli.py)
- File Selector TUI (file_selector.py)
- Clipboard Handler (clipboard.py)

b) Core Processing Layer:
- Context Management (context.py)
- Patch Generation (patch.py)
- LLM Integration (llm.py)

c) Utility Layer:
- Configuration Management (config.py)
- Git Integration (gitignore.py)
- Tree Utilities (tree_utils.py)

##### External Dependencies
- Anthropic Claude API
- DeepSeek API (optional for FrankenClaude mode)
- Git System

##### Specific Component Relationships

**User Input -> CLI -> File Selector**
- > Context Manager -> LLM Integration -> AI APIs
- > Patch Generator -> Git System

##### Important Details

a) Process Flow:
- File selection flow
- Context building process
- AI interaction cycle
- Patch generation and application
- Undo/redo functionality

b) Configuration Elements:
- API key management
- Model selection
- Git integration points

##### Technical Details

- File formats (patches, context)
- API endpoints
- Configuration points
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph User_Interaction
        CLI["CLI Interface"]
        FileSelector["File Selector TUI"]
        Clipboard["Clipboard Handler"]
    end

    subgraph Core_Processing
        Context["Context Manager"]
        Patch["Patch Generator"]
        LLM["LLM Integration"]
        Config["Configuration Manager"]
    end

    subgraph Utilities
        Git["Git Integration"]
        TreeUtils["Tree Utilities"]
    end

    subgraph External_Services
        Claude["Anthropic Claude API"]
        DeepSeek["DeepSeek API"]
        GitSystem["Git System"]
    end

    %% Main Flow
    CLI --> FileSelector
    FileSelector --> Context
    Context --> LLM
    LLM --> Patch
    Patch --> Git
    
    %% Secondary Flows
    CLI --> Clipboard
    Config --> CLI
    Config --> LLM
    TreeUtils --> FileSelector
    Git --> GitSystem
    
    %% AI Integration
    LLM --> Claude
    LLM -.-> DeepSeek
    
    %% Click Events
    click CLI "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/cli.py"
    click FileSelector "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/file_selector.py"
    click Clipboard "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/clipboard.py"
    click Context "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/context.py"
    click Patch "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/patch.py"
    click LLM "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/llm.py"
    click Config "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/config.py"
    click Git "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/gitignore.py"
    click TreeUtils "https://github.com/Mockapapella/diffdev/blob/master/src/diffdev/tree_utils.py"

    %% Styling
    classDef ui fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef util fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px

    class CLI,FileSelector,Clipboard ui
    class Context,Patch,LLM,Config core
    class Git,TreeUtils util
    class Claude,DeepSeek,GitSystem external

    %% Legend
    subgraph Legend
        UI[User Interface]:::ui
        Core[Core Processing]:::core
        Util[Utilities]:::util
        Ext[External Services]:::external
    end
```
