# unikraft/kraftkit architecture

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

- Interactive diagram: https://gitdiagram.com/unikraft/kraftkit
- Repository: https://github.com/unikraft/kraftkit

## Overview

##### Main Components

a. Core Components:
- Package Manager (packmanager/)
- Machine Management (machine/)
- Network Management (machine/network/)
- Volume Management (machine/volume/)
- OCI Integration (oci/)
- Unikraft Core (unikraft/)

b. CLI Interface:
- Command Factory (cmdfactory/)
- CLI Commands (internal/cli/)
- TUI Components (tui/)

c. Platform Support:
- QEMU (machine/qemu/)
- Firecracker (machine/firecracker/)

d. Build System:
- Make Integration (make/)
- Build Pipeline (internal/cli/kraft/build/)
- Package Management (internal/cli/kraft/pkg/)

##### Component Relationships

a. Control Flow:
**CLI Interface -> Package Manager -> Build System -> Platform Drivers**
- > Network Management
- > Volume Management

b. Data Flow:
**OCI Registry <-> Package Manager <-> Local Storage**
**Machine Management <-> Platform Drivers <-> Host System**

##### Component Details

Core Services:

- Package Manager    |

- Package pulling      |
- Version management   |
- Dependency resolution|

- Machine Management   |

- VM lifecycle        |
- Resource allocation |
- Platform abstraction|

Platform Integration:
- /------------\
- QEMU     |

- VM Control |
- /

- /------------\
- Firecracker|

- MicroVM    |
- /

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI
        CLI_CMD[CLI Commands]:::cli
        CMD_FAC[Command Factory]:::cli
        TUI[TUI Components]:::cli
    end

    subgraph Core
        PKG_MGR[Package Manager]:::core
        MACH_MGR[Machine Management]:::core
        UNIKRAFT[Unikraft Core]:::core
    end

    subgraph Platform
        QEMU[QEMU Driver]:::platform
        FIRE[Firecracker Driver]:::platform
    end

    subgraph Resources
        NET_MGR[Network Management]:::resource
        VOL_MGR[Volume Management]:::resource
    end

    subgraph Build
        MAKE[Make Integration]:::build
        BUILD[Build Pipeline]:::build
        PKG_BUILD[Package Management]:::build
    end

    subgraph Container
        OCI[OCI Integration]:::container
        OCI_HAND[OCI Handler]:::container
        CONT_RT[Container Runtime]:::container
    end

    CLI_CMD --> CMD_FAC
    CMD_FAC --> PKG_MGR
    CMD_FAC --> MACH_MGR
    TUI --> MACH_MGR

    PKG_MGR --> BUILD
    PKG_MGR --> OCI

    MACH_MGR --> QEMU
    MACH_MGR --> FIRE
    MACH_MGR --> NET_MGR
    MACH_MGR --> VOL_MGR

    BUILD --> MAKE
    BUILD --> PKG_BUILD
    BUILD --> UNIKRAFT

    OCI --> OCI_HAND
    OCI_HAND --> CONT_RT

    %% Click events for component mapping
    click PKG_MGR "https://github.com/unikraft/kraftkit/tree/staging/packmanager/"
    click MACH_MGR "https://github.com/unikraft/kraftkit/blob/staging/machine/platform/platform.go"
    click NET_MGR "https://github.com/unikraft/kraftkit/tree/staging/machine/network/"
    click VOL_MGR "https://github.com/unikraft/kraftkit/tree/staging/machine/volume/"
    click OCI "https://github.com/unikraft/kraftkit/tree/staging/oci/"
    click UNIKRAFT "https://github.com/unikraft/kraftkit/tree/staging/unikraft/"
    click CLI_CMD "https://github.com/unikraft/kraftkit/tree/staging/internal/cli/kraft/"
    click CMD_FAC "https://github.com/unikraft/kraftkit/tree/staging/cmdfactory/"
    click TUI "https://github.com/unikraft/kraftkit/tree/staging/tui/"
    click QEMU "https://github.com/unikraft/kraftkit/tree/staging/machine/qemu/"
    click FIRE "https://github.com/unikraft/kraftkit/tree/staging/machine/firecrafter/"
    click MAKE "https://github.com/unikraft/kraftkit/tree/staging/make/"
    click BUILD "https://github.com/unikraft/kraftkit/tree/staging/internal/cli/kraft/build/"
    click PKG_BUILD "https://github.com/unikraft/kraftkit/tree/staging/internal/cli/kraft/pkg/"
    click OCI_HAND "https://github.com/unikraft/kraftkit/tree/staging/oci/handler/"
    click CONT_RT "https://github.com/unikraft/kraftkit/tree/staging/libmocktainer/"

    classDef cli fill:#9370DB
    classDef core fill:#4169E1
    classDef platform fill:#3CB371
    classDef resource fill:#CD853F
    classDef build fill:#FFA500
    classDef container fill:#778899

    %% Legend
    subgraph Legend
        L_CLI[CLI Components]:::cli
        L_CORE[Core Components]:::core
        L_PLAT[Platform Components]:::platform
        L_RES[Resource Components]:::resource
        L_BUILD[Build Components]:::build
        L_CONT[Container Components]:::container
    end
```
