# rpm-software-management/dnf5 architecture

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

- Interactive diagram: https://gitdiagram.com/rpm-software-management/dnf5
- Repository: https://github.com/rpm-software-management/dnf5

## Overview

##### Project type and purpose
- DNF5 is a command‐line package manager written in C++.
- It consists of a core C++ library (libdnf5), a CLI binary (dnf5), a client–server daemon (dnf5daemon‐client + dnf5daemon‐server), plugin subsystems, language bindings (Python, Perl, Ruby), and documentation/tests.

##### Top-level structure and architectural patterns
- Top-level directories:
- bindings/… (Go, Python, Perl, Ruby language bindings)
- libdnf5/… (core package‐management library)
- libdnf5-cli/… (helper library for building CLI tools)
- libdnf5-plugins/… (shared plugin API and shipped plugins)
- dnf5/… (the CLI frontend binary)
- dnf5daemon-client/… (wrapper and D-Bus client for the daemon)
- dnf5daemon-server/… (D-Bus service implementing package operations)
- test/… (unit/integration tests)
- doc/… (Sphinx/RST documentation)
- Architectural patterns:
- Layered architecture (Presentation → Application → Domain → Data)
- Plugin architecture (DNF5 CLI and libdnf5 load plugins)
- Client–Server over D-Bus (CLI → dnf5daemon‐client → dnf5daemon‐server)
- CMake‐driven modular build.

##### Key components
a. Presentation layer
- dnf5 CLI binary: parses arguments, loads plugins, displays output.
- dnf5daemon‐client library: translates CLI calls into D-Bus method calls.
- Language bindings: SWIG/GObject-introspection wrappers for Python, Perl, Ruby.
b. Application layer
- dnf5daemon-server: D-Bus service, receives requests, manages sessions.
- Plugin host: both CLI and daemon can load C++ or Python‐based plugins.
c. Domain logic
- libdnf5: core modules (conf, repo, rpm, transaction, comps, advisory, module).
- libsolv: dependency solver integrated by libdnf5.
- SQLite or on‐disk transaction history DB.
d. Infrastructure / data access
- Network: HTTP(S) to RPM repositories (repomd).
- File system: package downloads, caches, config files (/etc/dnf/…).
- D-Bus IPC for client–server.
- systemd units for scheduling (e.g., offline cleanup).

##### Interactions & data flow
1. User runs `dnf5 <command>` → CLI parses & optionally calls libdnf5-cli output adapters.
2. For daemon mode: CLI invokes dnf5daemon-client → D-Bus method call to dnf5daemon-server.
3. Server receives RPC, invokes libdnf5 API → uses libsolv for dependency solving.
4. libdnf5 interacts with repos (download metadata, packages) and with the transaction DB (SQLite).
5. Results (package lists, transaction progress) flow back via D-Bus → client → CLI → terminal.
6. Plugins can hook into various stages: CLI commands, libdnf5 events, transaction callbacks.
7. Language bindings wrap libdnf5 C++ classes for use in Python/Perl/Ruby scripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        CLI["dnf5 CLI"]:::firstParty
        LCli["libdnf5-cli"]:::firstParty
        CLI -->|"loads helper library"| LCli
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Client["dnf5daemon-client"]:::firstParty
        Server["dnf5daemon-server"]:::firstParty
        Client ---|"D-Bus RPC"| Server
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Core["libdnf5"]:::firstParty
        Solv["libsolv"]:::external
        DB["SQLite3 DB"]:::external
        HTTP["HTTP(S) RPM Repos"]:::external
        Core -->|"uses"| Solv
        Core -->|"reads/writes"| DB
        Core -->|"HTTP GET/repodata"| HTTP
    end

    %% Plugins & Bindings
    subgraph "Plugins & Bindings"
        direction TB
        SharedPl["Shared Plugin API\n(libdnf5-plugins)"]:::binding
        CLIPl["CLI Plugins\n(dnf5-plugins)"]:::binding
        Bindings["Language Bindings\n(Python/Perl/Ruby/Go)"]:::binding
        SharedPl -->|"plugin host"| Core
        CLIPl -->|"extends"| CLI
        Bindings -->|"wraps"| Core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        DBus["D-Bus IPC"]:::external
        FS["File System\n(/etc/dnf/, cache)"]:::external
        Systemd["systemd units"]:::external
        DBus --> Client
        DBus --> Server
        Core --> FS
        Systemd --> Core
    end

    %% CMake Build Orchestrator
    CMake["CMake Build"]:::external
    CMake --> CLI
    CMake --> LCli
    CMake --> Client
    CMake --> Server
    CMake --> Core
    CMake --> SharedPl
    CMake --> CLIPl
    CMake --> Bindings

    %% User Interaction
    User["User / Terminal"]:::external
    User -->|"dnf5 <command>"| CLI

    %% Click Events
    click CLI "https://github.com/rpm-software-management/dnf5/blob/main/dnf5/main.cpp"
    click LCli "https://github.com/rpm-software-management/dnf5/blob/main/libdnf5-cli/CMakeLists.txt"
    click Client "https://github.com/rpm-software-management/dnf5/blob/main/dnf5daemon-client/CMakeLists.txt"
    click Server "https://github.com/rpm-software-management/dnf5/blob/main/dnf5daemon-server/CMakeLists.txt"
    click Core "https://github.com/rpm-software-management/dnf5/blob/main/libdnf5/CMakeLists.txt"
    click SharedPl "https://github.com/rpm-software-management/dnf5/blob/main/libdnf5-plugins/CMakeLists.txt"
    click CLIPl "https://github.com/rpm-software-management/dnf5/blob/main/dnf5-plugins/CMakeLists.txt"
    click Bindings "https://github.com/rpm-software-management/dnf5/blob/main/bindings/python3/CMakeLists.txt"
    click CMake "https://github.com/rpm-software-management/dnf5/blob/main/CMakeLists.txt"

    classDef firstParty fill:#cce5ff,stroke:#004085;
    classDef external fill:#d4edda,stroke:#155724;
    classDef binding fill:#fff3cd,stroke:#856404;
```
