# cdown/dwm architecture

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

- Interactive diagram: https://gitdiagram.com/cdown/dwm
- Repository: https://github.com/cdown/dwm

## Overview

##### Project type and purpose
- This is a customized build of dwm (a dynamic window manager for X11) written in C. It sits between X server and all other X clients to manage window layout, input events, and rendering.
- The README calls out patches, build scripts, and the sync mechanism to stay up-to-date with the upstream dwm repository.

##### File structure
- Top-level build files:
- Makefile, config.mk, config.def.h, config.h
- sync (script to pull upstream changes)
- Source modules:
- dwm.c          – core event loop, window management
- drw.c / drw.h  – drawing abstraction (Xft/Xlib wrapper)
- util.c / util.h– helper routines (string parsing, error handling)
- transient.c    – patch for transient windows
- patches are applied in-source, so code in dwm.c/util.c reflects extensions
- Man page: dwm.1
- License file and README

##### README for additional insights
- Describes which patches are added or merged upstream.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build Subsystem
    subgraph "Build Subsystem"
        direction TB
        MK["Makefile"]:::source
        CFGDEF["config.def.h"]:::source
        CFG["config.h"]:::source
        CMK["config.mk"]:::source
        SY["sync"]:::source
        GC["gcc compiler"]:::process
        OBJ["object files"]:::artifact
        DWMBIN["dwm binary"]:::artifact
        MK & CFGDEF & CFG & CMK & SY --> GC
        GC --> OBJ
        OBJ --> DWMBIN

        subgraph "Documentation & Metadata"
            direction TB
            MAN["dwm.1"]:::source
            RD1["README"]:::source
            RD2["README.md"]:::source
            LIC["LICENSE"]:::source
        end
    end

    %% Runtime Architecture
    subgraph "Runtime Architecture"
        direction TB
        XSRV["X Server"]:::external
        XCL["X Clients"]:::external
        DWMBIN -->|"interacts"| XSRV
        XCL -->|"communicates"| XSRV

        subgraph "dwm Internal Modules"
            direction TB
            CORE["dwm.c"]:::module
            DRWC["drw.c"]:::module
            DRWH["drw.h"]:::module
            UTILC["util.c"]:::module
            UTILH["util.h"]:::module
            PATCH["transient.c"]:::module
        end
        DWMBIN -->|"core loop uses"| CORE
        CORE -->|"uses drawing"| DRWC
        CORE -->|"uses drawing header"| DRWH
        CORE -->|"uses util"| UTILC
        CORE -->|"uses util header"| UTILH
        CORE -->|"uses patch"| PATCH
        CORE -->|"renders via"| XSRV
    end

    %% Click Events
    click MK "https://github.com/cdown/dwm/tree/master/Makefile"
    click CFGDEF "https://github.com/cdown/dwm/blob/master/config.def.h"
    click CFG "https://github.com/cdown/dwm/blob/master/config.h"
    click CMK "https://github.com/cdown/dwm/blob/master/config.mk"
    click SY "https://github.com/cdown/dwm/tree/master/sync"
    click CORE "https://github.com/cdown/dwm/blob/master/dwm.c"
    click DRWC "https://github.com/cdown/dwm/blob/master/drw.c"
    click DRWH "https://github.com/cdown/dwm/blob/master/drw.h"
    click UTILC "https://github.com/cdown/dwm/blob/master/util.c"
    click UTILH "https://github.com/cdown/dwm/blob/master/util.h"
    click PATCH "https://github.com/cdown/dwm/blob/master/transient.c"
    click MAN "https://github.com/cdown/dwm/blob/master/dwm.1"
    click RD1 "https://github.com/cdown/dwm/tree/master/README"
    click RD2 "https://github.com/cdown/dwm/blob/master/README.md"
    click LIC "https://github.com/cdown/dwm/tree/master/LICENSE"

    %% Styles
    classDef source fill:#D6EAF8,stroke:#1B4F72;
    classDef process fill:#FCF3CF,stroke:#B7950B;
    classDef artifact fill:#FADBD8,stroke:#C0392B;
    classDef external fill:#D5F5E3,stroke:#1D8348;
    classDef module fill:#EBDEF0,stroke:#8E44AD;
```
