# awesomewm/awesome architecture

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

- Interactive diagram: https://gitdiagram.com/awesomewm/awesome
- Repository: https://github.com/awesomewm/awesome

## Overview

##### Main Components
- Lua Integration and Libraries: Under the ‘lib/’ directory you have several Lua modules grouped by functionality:
– lib/awful: This module covers client management, layouts, key bindings, and other window management abstractions.
– lib/beautiful: This manages theming, GTK integration, and appearance.
– lib/naughty: Handles notifications, message displaying, and DBus integration.
– lib/wibox: Concerns the creation of panels, widgets, and layout containers.
– Other supportive modules such as lib/menubar.
- Configuration and Theming: Notice files like awesomerc.lua and directories for themes (themes/default, themes/gtk, themes/zenburn, etc.) – these are points for user customization, theme assets, and declarative configuration.
- Build and Testing Infrastructure: Files such as CMakeLists.txt, Makefile, AutoOption.cmake, and numerous “tests” and “spec” directories show configuration of the build system and extensive tests/examples for each module.

##### Relationships and Flow
- Core engine (written in C) initializes and drives the event loop, handling lower-level system calls, interfacing with the X11 subsystem (via xwindow.c, xkb.c, xrdb.c, etc.) and dispatching events.
- The core exposes APIs that the Lua libraries wrap for higher-level functionalities. For example, the awesome core interacts with the lib/awful modules (client management, key, and mouse events) and lib/beautiful (loading themes), while lib/gears provides utility functions that both the core and Lua scripts depend on.
- Notification and on-screen widget display are handled by lib/naughty and lib/wibox respectively. Data flows from the core events to these libraries which then update the user interface.
- Configuration files (e.g., awesomerc.lua) and themes (under themes/) plug into the Lua libraries at startup allowing user-defined behavior and styling.
- Build and test components are separate but reinforce correct behavior and integration; these are typically invoked separately from the main runtime flow.

##### Architectural Patterns & Design Principles
- Layered Architecture: You have a clear separation between the low-level C core and the high-level Lua modules. This promotes modularity and simplifies user customization.
- Event-Driven Design: The window manager takes advantage of an event loop where user actions, client changes, and system events are handed off to appropriate modules.
- Extensibility & Customization: The extensive use of Lua modules (with libraries such as awful, beautiful, gears, naughty, and wibox) shows the design’s emphasis on flexibility and configurable components.
- Clear Separation of Concerns: Core functionalities (handling X11 events, window management) are in one layer, while the presentation (themes, widget rendering) and configuration are isolated into separate modules/directories.

##### Additional Detailed Elements to Capture
- Dependencies (like DBus communications from lib/awful/dbus.lua or how configuration files are loaded at startup).
- If appropriate, capture interaction with external resources (like X11 inputs, file system operations for themes, and potentially client applications that are managed by the window manager).
- Don’t forget to include the testing and build layers to provide context on how the system is validated and built.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External System Layer
    X11["X11 System (Input/Events)"]:::external

    %% C Core Layer
    C_Core["C Core (Window Manager)"]:::core

    %% Lua Integration & Libraries Layer
    subgraph "Lua Integration & Libraries"
        direction TB
        Lua_Awful["lib/awful (Client & Layout)"]:::lua
        Lua_Beautiful["lib/beautiful (Theming)"]:::lua
        Lua_Gears["lib/gears (Utilities)"]:::lua
        Lua_Naughty["lib/naughty (Notifications)"]:::lua
        Lua_Wibox["lib/wibox (Panels/Widgets)"]:::lua
        Lua_Menubar["lib/menubar (Menus)"]:::lua
    end

    %% User Configuration & Themes Layer
    User_Config["User Configuration & Themes (awesomerc.lua, themes/)"]:::config

    %% Build and Testing Infrastructure Layer
    Build_Infra["Build Infrastructure (Makefile, CMakeLists.txt, AutoOption.cmake)"]:::build
    Test_Infra["Testing Infrastructure (tests/)"]:::test

    %% Relationships and Data Flow
    X11 -->|"input"| C_Core
    C_Core -->|"invokes"| Lua_Awful
    C_Core -->|"invokes"| Lua_Beautiful
    C_Core -->|"invokes"| Lua_Gears
    C_Core -->|"invokes"| Lua_Naughty
    C_Core -->|"invokes"| Lua_Wibox
    C_Core -->|"invokes"| Lua_Menubar
    Lua_Awful -->|"configures"| User_Config
    Lua_Beautiful -->|"applies"| User_Config
    Lua_Gears -->|"supports"| C_Core
    Lua_Naughty -->|"updates"| User_Config
    Lua_Wibox -->|"renders"| User_Config
    Build_Infra -->|"builds"| C_Core
    Test_Infra -->|"tests"| C_Core

    %% Click Events
    click C_Core "https://github.com/awesomewm/awesome/blob/master/awesome.c"
    click Lua_Awful "https://github.com/awesomewm/awesome/tree/master/lib/awful"
    click Lua_Beautiful "https://github.com/awesomewm/awesome/tree/master/lib/beautiful"
    click Lua_Gears "https://github.com/awesomewm/awesome/tree/master/lib/gears"
    click Lua_Naughty "https://github.com/awesomewm/awesome/tree/master/lib/naughty"
    click Lua_Wibox "https://github.com/awesomewm/awesome/tree/master/lib/wibox"
    click Lua_Menubar "https://github.com/awesomewm/awesome/tree/master/lib/menubar"
    click User_Config "https://github.com/awesomewm/awesome/blob/master/awesomerc.lua"
    click Build_Infra "https://github.com/awesomewm/awesome/blob/master/CMakeLists.txt"
    click Test_Infra "https://github.com/awesomewm/awesome/tree/master/tests/"

    %% Styles
    classDef external fill:#D3D3D3,stroke:#000000,stroke-width:2px;
    classDef core fill:#FFA07A,stroke:#8B0000,stroke-width:2px;
    classDef lua fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef build fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef test fill:#FFB6C1,stroke:#CD5C5C,stroke-width:2px;
```
