# oakmura/4cc architecture

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

- Interactive diagram: https://gitdiagram.com/oakmura/4cc
- Repository: https://github.com/oakmura/4cc

## Overview

##### Main Components

a) Core Editor Components:
- Editor Core (4ed.*)
- Buffer Management System
- Text Layout Engine
- Rendering System
- Input/Event System
- File System Interface

b) Platform-Specific Layers:
- Windows Implementation
- Linux Implementation
- MacOS Implementation

c) Custom Layer:
- Custom API
- Command System
- Extension Framework
- Theme System

d) Supporting Systems:
- Font Management
- Audio System
- Configuration System
- Build System

**┌─────────────────────────────────────────────────────┐**
- User Interface                      │
- ┤
- Custom Layer                        │
- ┌─────────────┐ ┌──────────┐ ┌──────────────────┐ │
- Extensions  │ │ Themes   │ │ Custom Commands   │ │
- ┘ └──────────┘ └──────────────────┘ │
- ┤
- Core Editor                         │
- ┌─────────────┐ ┌──────────┐ ┌──────────────────┐ │
- Buffer    │ │  Layout  │ │     Rendering    │ │
- Management │ │  Engine  │ │      System      │ │
- ┘ └──────────┘ └──────────────────┘ │
- ┌─────────────┐ ┌──────────┐ ┌──────────────────┐ │
- File     │ │  Input   │ │      Audio       │ │
- System    │ │  System  │ │     System       │ │
- ┘ └──────────┘ └──────────────────┘ │
- ┤
- Platform Abstraction                   │
- ┬────────────┬────────────────────────────┤
- Windows  │   Linux    │         MacOS              │
- ┴────────────┴────────────────────────────┘

##### Connection Types

- Double lines for API boundaries

##### Important Details to Highlight

a) Cross-Platform Architecture:
- How the platform-specific implementations (win32_4ed.cpp, linux_4ed.cpp, mac_4ed.mm) connect to the core
- Abstraction layer that enables cross-platform support

b) Extension System:
- How custom commands and extensions integrate with the core
- Relationship between custom APIs and the core editor

c) Resource Management:
- Font management system
- Configuration file handling
- Demonstrate theme system integration

##### Implementation Notes

- Use standardized UML notation where appropriate
- Annotations for critical components
- Version information and build system integration
- Configuration flow

##### Key Relationships to Emphasize

- Custom layer interaction with core components
- Platform-specific implementation details
- Resource loading and management paths
- User input flow through the system
- File system interactions
- Rendering pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface"]
        UI_MAIN["4Coder Editor Interface"]:::ui
    end

    subgraph CL["Custom Layer"]
        EXT["Extensions"]:::custom
        THM["Theme System"]:::custom
        CMD["Custom Commands"]:::custom
        CAPI["Custom API"]:::custom
        CFG["Configuration System"]:::custom
    end

    subgraph CORE["Core Editor"]
        EC["Editor Core"]:::core
        BUF["Buffer Management"]:::core
        LAY["Layout Engine"]:::core
        REN["Rendering System"]:::core
        INP["Input/Event System"]:::core
        FS["File System"]:::core
        FNT["Font Management"]:::core
        AUD["Audio System"]:::core
    end

    subgraph PA["Platform Abstraction"]
        WIN["Windows Implementation"]:::platform
        LIN["Linux Implementation"]:::platform
        MAC["MacOS Implementation"]:::platform
    end

    %% Connections
    UI_MAIN --> CL
    CL --> CORE
    CORE --> PA

    %% Custom Layer Internal
    EXT --> CAPI
    THM --> CAPI
    CMD --> CAPI
    CAPI --> CFG

    %% Core Internal
    EC --> BUF
    EC --> LAY
    EC --> REN
    EC --> INP
    EC --> FS
    EC --> FNT
    EC --> AUD

    %% Platform Connections
    PA --> WIN
    PA --> LIN
    PA --> MAC

    %% Click Events
    click EC "https://github.com/Oakmura/4cc/blob/master/code/4ed.cpp"
    click BUF "https://github.com/Oakmura/4cc/blob/master/code/4ed_buffer.cpp"
    click LAY "https://github.com/Oakmura/4cc/blob/master/code/4ed_text_layout.cpp"
    click REN "https://github.com/Oakmura/4cc/blob/master/code/4ed_render_target.cpp"
    click INP "https://github.com/Oakmura/4cc/blob/master/4coder/custom/4coder_events.cpp"
    click FS "https://github.com/Oakmura/4cc/blob/master/code/4ed_file.cpp"
    click WIN "https://github.com/Oakmura/4cc/blob/master/code/platform_win32/win32_4ed.cpp"
    click LIN "https://github.com/Oakmura/4cc/blob/master/code/platform_linux/linux_4ed.cpp"
    click MAC "https://github.com/Oakmura/4cc/blob/master/code/platform_mac/mac_4ed.mm"
    click CAPI "https://github.com/Oakmura/4cc/blob/master/4coder/custom/generated/custom_api.cpp"
    click CMD "https://github.com/Oakmura/4cc/blob/master/4coder/custom/4coder_command_map.cpp"
    click THM "https://github.com/Oakmura/4cc/tree/master/4coder/themes/"
    click FNT "https://github.com/Oakmura/4cc/blob/master/code/4ed_font_set.cpp"
    click AUD "https://github.com/Oakmura/4cc/blob/master/4coder/custom/4coder_audio.cpp"
    click CFG "https://github.com/Oakmura/4cc/blob/master/4coder/custom/4coder_config.cpp"

    %% Styles
    classDef ui fill:#f9f,stroke:#333,stroke-width:2px
    classDef custom fill:#fb8,stroke:#333,stroke-width:2px
    classDef core fill:#9cf,stroke:#333,stroke-width:2px
    classDef platform fill:#9f9,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Custom Layer"]:::custom
        L3["Core Components"]:::core
        L4["Platform Layer"]:::platform
    end
```
