# edit4i/editor architecture

> Architecture diagram of the GitHub repository edit4i/editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edit4i/editor
- Repository: https://github.com/edit4i/editor

## Overview

##### Main Components

a) Frontend Layer (Svelte-based UI):
- Editor Core (Monaco Editor)
- File Explorer
- Git Integration UI
- Terminal Interface
- Command Palette
- AI Features Interface

b) Backend Layer (Go-based):
- File System Service
- Git Service
- Terminal Service
- AI Pipeline
- Database Layer
- Project Management

c) Integration Layer:
- Wails Bridge (connecting frontend and backend)
- External Services Integration

**[Frontend Layer (Top)]**
- ↕️
**[Wails Bridge (Middle)]**
- ↕️
**[Backend Services (Bottom)]**

##### Component Details

- Sidebar components (FileTree, Git, Terminal) on the sides
- Command palette and AI features floating above
- Stores management system

- Core services (file, git, terminal) in a service layer
- AI pipeline components (context, LLM, vector store)
- Database layer for persistent storage
- Project management system

- Wails runtime bridge
- External system connections

##### Data Flow Indicators

- Frontend-Backend communication through Wails
- File system operations
- Git operations
- Terminal I/O
- AI processing pipeline
- Database interactions

##### Component Relationships

- How the terminal service connects to the OS
- How Git operations flow through the system
- How AI features interact with the editor
- How file operations are handled

##### Technical Details

- Svelte components structure
- Go service architecture
- Database schema indication
- File system interaction paths
- AI pipeline processing flow
- Terminal communication channels

##### The extensibility points for future features

Remember to indicate future integration points from the roadmap, such as:
- Multi-file context understanding
- Dependency graph analysis
- Autonomous AI agents
- Tool marketplace integration

This will create a comprehensive yet clear system design that accurately represents Edit4I's architecture while highlighting its unique AI-powered features and desktop-native capabilities.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#d0e1f9,stroke:#333
    classDef backend fill:#d4edda,stroke:#333
    classDef integration fill:#e6d0f9,stroke:#333
    classDef ai fill:#fff3cd,stroke:#333
    classDef store fill:#f8d7da,stroke:#333
    classDef database fill:#f5c6cb,stroke:#333

    subgraph Frontend
        Editor["Editor Core (Monaco)"]:::frontend
        FileExplorer["File Explorer"]:::frontend
        GitUI["Git Integration UI"]:::frontend
        TerminalUI["Terminal Interface"]:::frontend
        CmdPalette["Command Palette"]:::frontend
        AIInterface["AI Features Interface"]:::frontend

        subgraph Stores
            EditorStore["Editor State Store"]:::store
            GitStore["Git Store"]:::store
            TerminalStore["Terminal Store"]:::store
            FileStore["File Store"]:::store
        end
    end

    subgraph Integration
        WailsBridge["Wails Bridge"]:::integration
    end

    subgraph Backend
        FSService["File System Service"]:::backend
        GitService["Git Service"]:::backend
        TermService["Terminal Service"]:::backend
        ProjectMgmt["Project Management"]:::backend

        subgraph AIPipeline
            Context["Context Generation"]:::ai
            LLM["Language Models"]:::ai
            VectorStore["Vector Store"]:::ai
        end

        subgraph Storage
            DB["Database Layer"]:::database
            DBMigrations["Database Migrations"]:::database
        end
    end

    %% Relationships
    Editor --> WailsBridge
    FileExplorer --> WailsBridge
    GitUI --> WailsBridge
    TerminalUI --> WailsBridge
    CmdPalette --> WailsBridge
    AIInterface --> WailsBridge

    WailsBridge --> FSService
    WailsBridge --> GitService
    WailsBridge --> TermService
    WailsBridge --> ProjectMgmt
    WailsBridge --> AIPipeline

    FSService --> DB
    GitService --> DB
    ProjectMgmt --> DB
    DB --> DBMigrations

    Context --> LLM
    LLM --> VectorStore

    Editor --> EditorStore
    GitUI --> GitStore
    TerminalUI --> TerminalStore
    FileExplorer --> FileStore

    %% Click Events
    click Editor "https://github.com/edit4i/editor/blob/main/frontend/src/lib/editor/core/MonacoEditor.svelte"
    click FileExplorer "https://github.com/edit4i/editor/blob/main/frontend/src/lib/editor/explorer/FileTree.svelte"
    click GitUI "https://github.com/edit4i/editor/tree/main/frontend/src/lib/editor/git/"
    click TerminalUI "https://github.com/edit4i/editor/blob/main/frontend/src/lib/terminal/XtermComponent.svelte"
    click CmdPalette "https://github.com/edit4i/editor/blob/main/frontend/src/lib/components/palletes/CommandPalette.svelte"
    click FSService "https://github.com/edit4i/editor/blob/main/internal/service/files.go"
    click GitService "https://github.com/edit4i/editor/blob/main/internal/service/git.go"
    click TermService "https://github.com/edit4i/editor/blob/main/internal/service/terminal.go"
    click AIPipeline "https://github.com/edit4i/editor/tree/main/internal/ai/"
    click DB "https://github.com/edit4i/editor/tree/main/internal/db/"
    click ProjectMgmt "https://github.com/edit4i/editor/blob/main/internal/service/projects.go"
    click WailsBridge "https://github.com/edit4i/editor/tree/main/frontend/src/lib/wailsjs/"
    click Stores "https://github.com/edit4i/editor/tree/main/frontend/src/stores/"
    click DBMigrations "https://github.com/edit4i/editor/tree/main/db/migrations/"
    click EditorStore "https://github.com/edit4i/editor/blob/main/frontend/src/stores/editorStateStore.ts"
    click GitStore "https://github.com/edit4i/editor/blob/main/frontend/src/stores/gitStore.ts"
    click TerminalStore "https://github.com/edit4i/editor/blob/main/frontend/src/stores/terminalStore.ts"
    click FileStore "https://github.com/edit4i/editor/blob/main/frontend/src/stores/fileStore.ts"
```
