# xenith-re/xenith architecture

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

- Interactive diagram: https://gitdiagram.com/xenith-re/xenith
- Repository: https://github.com/xenith-re/xenith

## Overview

##### Project Type & Purpose
- Xenith is a lightweight, Xen-based hypervisor designed for research, development, and advanced debugging of virtualized workloads. It offers features such as stealth operations, low-level debugging, real-time virtual machine introspection (VMI), a comprehensive scripting API, and a user-friendly GUI.
- The project is composed of multiple Rust crates (e.g., xenith-cli, xenith-vm, xenith-vmi, xenith-redpill) and additional components (e.g., xenith-website for documentation and user tutorials) with supporting infrastructure like Ansible playbooks and Vagrant configurations for deployment/testing.

##### File Structure
- Top-Level Components:
- Multiple Rust crates:
▪ xenith-cli: Likely the command-line interface for managing or controlling Xenith functions.
▪ xenith-redpill: Contains techniques for anti-VM or stealth/debugging functionalities.
▪ xenith-vm: Focuses on domain management, VM actions, and encapsulates core VM operations.
▪ xenith-vmi: Provides virtual machine introspection functionalities.
- Ansible Directory:
▪ Contains configuration, roles, and tasks that set up the environment and manage various aspects of the Xen-based hypervisor (e.g., roles for KDE, Xen, and tools).
- Documentation:
▪ The docs folder holds comprehensive developer guides, architecture explanations, reference documentation, and tutorials.
- xenith-website:
▪ A standalone component built with Hugo (in Go), serving as the public-facing portal and documentation site.
- Supporting Files:
▪ CI/CD workflows in the .github/workflows directory (e.g., for Rust builds and code coverage).
▪ Vagrant configurations for local or test environment setup.

##### Key System Components & Their Relationships
a. Hypervisor Core:
- Represents Xenith’s main functionality with several modules:
▪ xenith-vm: Manages virtual machine (domain) operations, booting, device and event handling.
▪ xenith-vmi: Handles introspection into guest VMs, enabling debugging and monitoring.
- These core components interact directly with the underlying Xen hypervisor (illustrated in the “xen” directory, configuration scripts, or Ansible roles).

b. Management & Interface Layers:
- xenith-cli: Acts as the command-line interface to trigger operations and interact with the hypervisor modules.
- GUI (as mentioned in the README): While not directly visible in the file structure, the documentation details a user-friendly GUI; indicate it as a separate component interfacing with the core.
- Scripting API: An extensibility point that automates tasks and integrates with both CLI and backend modules.

c. Support Infrastructure:
- Ansible Playbooks & Vagrant: Define environment setup, automated deployment, and testing orchestration, ensuring that the hypervisor and its modules are consistently configured.
- CI/CD & GitHub Workflows: Automate testing, code coverage, and deployment steps, ensuring continuous integration and quality.
- xenith-website: Provides tutorials, documentation, and guides that interact indirectly with the underlying system (promoting usability and community contributions).

##### Architectural Patterns & Technologies
- Modular Architecture: Separation into distinct Rust crates enables independent development, testing, and reuse.
- Microservice-like Approach within a Monorepo: Each crate has a clear responsibility (CLI, VM management, introspection, stealth/debugging) and interacts with the others through well-defined interfaces.
- Use of Infrastructure as Code: Ansible and Vagrant are leveraged to ensure environment consistency and manage hypervisor deployments.
- CI/CD Integration: GitHub workflows (Rust, code coverage, deployment restrictions) are recognized as critical parts of the development lifecycle.
- Documentation & Community Engagement: A dedicated website built with Hugo and comprehensive docs promote transparency and facilitate open-source collaboration.

##### Final Recommendations
- Detail Every Component: Start by listing all modules and supporting systems before connecting them. Don’t shy away from dedicating separate nodes for Ansible roles, GitHub workflows, and documentation components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        CLI["CLI Interface (xenith-cli)"]:::interface
        GUI["GUI & Documentation (xenith-website)"]:::interface
    end

    %% Hypervisor Core
    subgraph "Hypervisor Core"
        VM["VM Management (xenith-vm)"]:::core
        VMI["VMI/Introspection (xenith-vmi)"]:::core
        REDPILL["Stealth/Debug Module (xenith-redpill)"]:::core
    end

    %% Infrastructure
    subgraph "Infrastructure"
        ANS["Ansible Playbooks (ansible)"]:::infrastructure
        VAGR["Vagrant Config (Vagrantfile)"]:::infrastructure
        CICD["CI/CD Pipelines (.github/workflows)"]:::infrastructure
    end

    %% Relationships from User Interfaces to Hypervisor Core
    CLI -->|"triggers"| VM
    CLI -->|"triggers"| VMI
    CLI -->|"triggers"| REDPILL

    GUI -->|"monitors"| VM
    GUI -->|"monitors"| VMI

    %% Relationships within Hypervisor Core
    VM -->|"provides data"| VMI
    REDPILL -->|"debugs"| VM

    %% Infrastructure connections to Hypervisor Core
    ANS -->|"deploys"| VM
    ANS -->|"deploys"| VMI

    VAGR -->|"configures"| VM
    VAGR -->|"configures"| VMI

    CICD -->|"builds&tests"| VM
    CICD -->|"builds&tests"| VMI
    CICD -->|"deploys"| GUI

    %% Click Events
    click CLI "https://github.com/xenith-re/xenith/tree/main/xenith-cli/"
    click VM "https://github.com/xenith-re/xenith/tree/main/xenith-vm/"
    click VMI "https://github.com/xenith-re/xenith/tree/main/xenith-vmi/"
    click REDPILL "https://github.com/xenith-re/xenith/tree/main/xenith-redpill/"
    click GUI "https://github.com/xenith-re/xenith/tree/main/xenith-website/"
    click ANS "https://github.com/xenith-re/xenith/tree/main/ansible/"
    click VAGR "https://github.com/xenith-re/xenith/tree/main/Vagrantfile"
    click CICD "https://github.com/xenith-re/xenith/tree/main/.github/workflows/"

    %% Styles
    classDef interface fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef infrastructure fill:#98FB98,stroke:#000,stroke-width:2px;
```
