# konosubakonoakua/zig-river architecture

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

- Interactive diagram: https://gitdiagram.com/konosubakonoakua/zig-river
- Repository: https://github.com/konosubakonoakua/zig-river

## Overview

##### Main Components

a) Core Compositor (River)
- Key components visible in the /river directory:
- Server.zig (central component)
- Input Management (InputManager.zig, InputDevice.zig)
- View Management (View.zig, XdgToplevel.zig)
- Layout System (Layout.zig, LayoutManager.zig)
- Output Management (Output.zig)

b) Protocol Layer
- This as a foundation layer below the core
- Custom protocols from the /protocol directory:
- river-control-unstable-v1
- river-layout-v3
- river-status-unstable-v1
- wlr-layer-shell-unstable-v1

c) External Components
- Layout Generators (rivertile)
- Control Interface (riverctl)
- Client Applications

##### Component Relationships

- Wayland protocol communication between components
- Layout generator protocol interaction
- Control command flow from riverctl to the compositor
- Window management flow

##### Specific Implementation Details

a) Layout System Architecture
**riverctl <-> River Core <-> Layout Generator (rivertile)**

b) Input Management Chain
**Input Devices -> InputManager -> InputRelay -> Views/Windows**

c) Window Management Flow
**Client Windows -> XdgToplevel/XwaylandView -> View Management -> Layout System**

##### Important Notes

- A note about the future architectural changes mentioned in the README
- Modular nature of the layout generator system
- Configuration flow from init script through riverctl
- Xwayland support (when enabled)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#a8d1f0,stroke:#333
    classDef input fill:#e6b3ff,stroke:#333
    classDef view fill:#ffb366,stroke:#333
    classDef layout fill:#99ff99,stroke:#333
    classDef output fill:#ff99cc,stroke:#333
    classDef protocol fill:#b3e6ff,stroke:#333
    classDef external fill:#ffff99,stroke:#333
    classDef config fill:#d9b3ff,stroke:#333
    classDef seat fill:#ff9999,stroke:#333

    %% Core Components
    subgraph CoreCompositor["River Core Compositor"]
        Server["Server"]:::core
        
        subgraph InputSystem["Input Management"]
            InputManager["Input Manager"]:::input
            InputDevice["Input Device"]:::input
            InputRelay["Input Relay"]:::input
            Keyboard["Keyboard"]:::input
            InputConfig["Input Config"]:::input
        end

        subgraph ViewSystem["View Management"]
            View["View Handler"]:::view
            XdgToplevel["XDG Toplevel"]:::view
            XwaylandView["Xwayland View"]:::view
        end

        subgraph LayoutSystem["Layout System"]
            LayoutManager["Layout Manager"]:::layout
            Layout["Layout Core"]:::layout
            LayoutDemand["Layout Demand"]:::layout
        end

        subgraph OutputSystem["Output Management"]
            Output["Output Handler"]:::output
            OutputStatus["Output Status"]:::output
        end

        subgraph SeatSystem["Seat Management"]
            Seat["Seat Handler"]:::seat
            SeatStatus["Seat Status"]:::seat
        end

        Config["Config Handler"]:::config
        Command["Command Handler"]:::config
    end

    %% Protocol Layer
    subgraph Protocols["Protocol Layer"]
        ControlProtocol["River Control Protocol"]:::protocol
        LayoutProtocol["River Layout Protocol"]:::protocol
        StatusProtocol["River Status Protocol"]:::protocol
        LayerShell["Layer Shell Protocol"]:::protocol
    end

    %% External Tools
    Riverctl["riverctl"]:::external
    Rivertile["rivertile"]:::external
    ClientApps["Client Applications"]:::external

    %% Relationships
    Server --> InputManager
    Server --> View
    Server --> LayoutManager
    Server --> Output
    Server --> Seat
    Server --> Config
    Server --> Command

    InputManager --> InputDevice
    InputManager --> InputRelay
    InputManager --> Keyboard
    InputManager --> InputConfig

    View --> XdgToplevel
    View --> XwaylandView

    LayoutManager --> Layout
    LayoutManager --> LayoutDemand

    Output --> OutputStatus
    Seat --> SeatStatus

    Protocols --> Server
    Riverctl --> ControlProtocol
    Rivertile --> LayoutProtocol
    ClientApps --> LayerShell

    %% Click Events
    click Server "https://github.com/konosubakonoakua/zig-river/blob/master/river/Server.zig"
    click InputManager "https://github.com/konosubakonoakua/zig-river/blob/master/river/InputManager.zig"
    click InputDevice "https://github.com/konosubakonoakua/zig-river/blob/master/river/InputDevice.zig"
    click InputRelay "https://github.com/konosubakonoakua/zig-river/blob/master/river/InputRelay.zig"
    click Keyboard "https://github.com/konosubakonoakua/zig-river/blob/master/river/Keyboard.zig"
    click InputConfig "https://github.com/konosubakonoakua/zig-river/blob/master/river/InputConfig.zig"
    click View "https://github.com/konosubakonoakua/zig-river/blob/master/river/View.zig"
    click XdgToplevel "https://github.com/konosubakonoakua/zig-river/blob/master/river/XdgToplevel.zig"
    click XwaylandView "https://github.com/konosubakonoakua/zig-river/blob/master/river/XwaylandView.zig"
    click LayoutManager "https://github.com/konosubakonoakua/zig-river/blob/master/river/LayoutManager.zig"
    click Layout "https://github.com/konosubakonoakua/zig-river/blob/master/river/Layout.zig"
    click LayoutDemand "https://github.com/konosubakonoakua/zig-river/blob/master/river/LayoutDemand.zig"
    click Output "https://github.com/konosubakonoakua/zig-river/blob/master/river/Output.zig"
    click OutputStatus "https://github.com/konosubakonoakua/zig-river/blob/master/river/OutputStatus.zig"
    click Seat "https://github.com/konosubakonoakua/zig-river/blob/master/river/Seat.zig"
    click SeatStatus "https://github.com/konosubakonoakua/zig-river/blob/master/river/SeatStatus.zig"
    click Config "https://github.com/konosubakonoakua/zig-river/blob/master/river/Config.zig"
    click Command "https://github.com/konosubakonoakua/zig-river/blob/master/river/command.zig"
    click ControlProtocol "https://github.com/konosubakonoakua/zig-river/blob/master/protocol/river-control-unstable-v1.xml"
    click LayoutProtocol "https://github.com/konosubakonoakua/zig-river/blob/master/protocol/river-layout-v3.xml"
    click StatusProtocol "https://github.com/konosubakonoakua/zig-river/blob/master/protocol/river-status-unstable-v1.xml"
    click LayerShell "https://github.com/konosubakonoakua/zig-river/blob/master/protocol/wlr-layer-shell-unstable-v1.xml"
    click Riverctl "https://github.com/konosubakonoakua/zig-river/blob/master/riverctl/main.zig"
    click Rivertile "https://github.com/konosubakonoakua/zig-river/blob/master/rivertile/main.zig"
```
