# dallinjdahl/gx architecture

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

- Interactive diagram: https://gitdiagram.com/dallinjdahl/gx
- Repository: https://github.com/dallinjdahl/gx

## Overview

Key Components to Include:

##### Core Components
- Input Handler (stdin/X selection)
- Regex Matcher
- Command Executor
- Port System (Implementation Router)

##### Integration Points
- DWM Window Manager
- ST Terminal
- External Applications (browsers, editors, etc.)

##### Central Flow
- Input Sources -> GX Core -> Port System -> Target Applications

##### Component Details

a. Input Sources (Left side):

b. GX Core (Center):
- Inside this component, create sub-components:
- Config Parser (config.def.h)
- Regex Engine (Plan9 regex library)
- Pattern Matcher
- Command Generator

c. Port System (Right-center):
- It as an intermediary layer
- Example handlers:
- Web Handler
- Edit Handler
- (Extensible nature should be indicated)

d. Target Applications (Right side):
- Web Browsers
- Text Editors
- Custom Applications

##### Notes Section
A small notes section mentioning:
- Input size limitations (1023 bytes)
- Match limitations (8 matches)
- Command size limits (4095 bytes)

Key Architectural Patterns to Emphasize:
##### X Macro-based configuration

Level of Detail:
- Keep the main flow clear and prominent
- Integration points without overwhelming detail
- Extensibility of the port system
- Just enough detail to understand the data flow

- Nested components
- Text annotations

Remember to maintain the suckless philosophy of simplicity while still showing all crucial components and their interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef input fill:#a8d1f0,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef port fill:#FFB347,stroke:#333
    classDef target fill:#DDA0DD,stroke:#333
    classDef config fill:#E6E6FA,stroke:#333

    %% Input Layer
    subgraph InputSources
        X11["X11 Selection"]:::input
        ST["ST Terminal"]:::input
        STDIN["Standard Input"]:::input
    end

    %% Core Processing
    subgraph CoreSystem
        GXCore["GX Core"]:::core
        subgraph CoreComponents
            ConfigParser["Config Parser"]:::core
            RegexEngine["Regex Engine"]:::core
            PatternMatcher["Pattern Matcher"]:::core
            CmdGen["Command Generator"]:::core
        end
    end

    %% Port System
    subgraph PortSystem
        PortRouter["Port System Router"]:::port
        WebHandler["Web Handler"]:::port
        EditHandler["Edit Handler"]:::port
        CustomHandler["Custom Handlers"]:::port
    end

    %% Target Applications
    subgraph TargetApps
        Browser["Web Browsers"]:::target
        Editor["Text Editors"]:::target
        CustomApps["Custom Applications"]:::target
    end

    %% Configuration
    Config["config.def.h"]:::config

    %% Connections
    X11 --> GXCore
    ST --> GXCore
    STDIN --> GXCore
    
    Config -.-> CoreComponents
    
    CoreComponents --> PortRouter
    
    PortRouter --> WebHandler
    PortRouter --> EditHandler
    PortRouter --> CustomHandler
    
    WebHandler --> Browser
    EditHandler --> Editor
    CustomHandler --> CustomApps

    %% Click Events
    click GXCore "https://github.com/dallinjdahl/gx/blob/master/gx.c"
    click PortRouter "https://github.com/dallinjdahl/gx/blob/master/port.def"
    click Config "https://github.com/dallinjdahl/gx/blob/master/config.def.h"
    click X11 "https://github.com/dallinjdahl/gx/tree/master/dwmgx"
    click ST "https://github.com/dallinjdahl/gx/blob/master/simple_plumb.diff"

    %% Legend
    subgraph Legend
        L1["Input Sources"]:::input
        L2["Core Processing"]:::core
        L3["Port System"]:::port
        L4["Target Apps"]:::target
        L5["Configuration"]:::config
    end

    %% Notes
    subgraph Limitations
        N1["Input: 1023 bytes"]
        N2["Matches: 8 max"]
        N3["Command: 4095 bytes"]
    end
```
