# robbedgreef/yanix architecture

> Architecture diagram of the GitHub repository robbedgreef/yanix, 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/robbedgreef/yanix
- Repository: https://github.com/robbedgreef/yanix

## Overview

##### Project Type and Purpose
- yanix is a hobbyist, monolithic, preemptible UNIX-like kernel aiming for high POSIX compliance. It is not only an educational platform to learn OS development but also an evolving OS that supports basic multitasking, virtual filesystems, and a set of drivers.
- The project includes components for bootstrapping (bootloader stages), a robust kernel (complete with device drivers, memory management, and process handling), libraries (graphics and event handling), system tools (command-line utilities and a shell), and even some user applications (found in apps).

##### Relationships and Interactions
- Within the kernel, show interactions:
– Initialization flows from architecture-specific boot code → CPU setup → memory management.
– Drivers interact with hardware and feed into higher-level kernel services (e.g., interrupts from keyboard or timer feeding into task scheduling).
– Filesystem modules interface with the storage devices (via drivers) and supply file operations to processes.
- How the Libraries integrate: for instance, the igl library providing a windowing system that interacts with both user applications and low-level graphical drivers.
- How user applications (apps, system tools) run on top of the kernel services and utilize the sysroot environment.

##### Architectural Patterns & Design Principles
- Monolithic Kernel: Emphasize that almost all OS services (driver management, file systems, process scheduling, etc.) are part of one large kernel image.
- Modular Breakdown: Although monolithic, the structure is decomposed into clearly separated modules (drivers, filesystem, memory, scheduling) to help clarity.
- Boot Sequence: Demonstrate the two-stage bootloader process ensuring that the kernel is properly loaded and initialized.
- POSIX Compliance: While not depicted in detail, note that kernel services are designed with the POSIX model in mind (system calls, user processes, etc.).
- Separation of Userland and Kernel: Even though libraries and utilities are bundled, there is a clear conceptual separation of kernel space (bootloader, kernel) and user space (apps, tools, sysroot).

## Diagram (Mermaid)

```mermaid
flowchart TD
    HW["Hardware Power On"]:::hardware

    subgraph "Bootloader"
        B1["Stage1: Bootloader Stage1 – Minimal Boot Code"]:::bootloader
        B2["Stage2: Bootloader Stage2 – Kernel Loader & FS Support"]:::bootloader
    end

    subgraph "Kernel"
        K1["Kernel Boot: Arch-specific Startup (i386)"]:::kernel
        K2["CPU & Interrupt Handling: GDT, IDT, ISR"]:::kernel
        K3["Memory Management: Paging, Heap, Fault Handling"]:::kernel
        K4["Process Management: Tasking & Scheduling"]:::kernel
        K5["Filesystem & VFS: File Systems & ext2 Support"]:::kernel
        K6["Drivers: ATA, PCI, PS/2, Video, etc."]:::kernel
        K7["Kernel Services & Syscalls: System Calls, IPC"]:::kernel
    end

    subgraph "Libraries"
        L1["IGL: Graphics/Windowing"]:::libs
        L2["LibEvent: Event Handling"]:::libs
        L3["LibGFX: Basic Graphics Routines"]:::libs
    end

    subgraph "Userland"
        U1["User Applications"]:::userland
        U2["System Utilities: Shell & CLI Tools"]:::userland
    end

    subgraph "Development Environment"
        S1["Sysroot: Userland Runtime (usr/include, usr/lib)"]:::development
        S2["Development Tools: Build Scripts & Utilities"]:::development
    end

    HW --> B1
    B1 --> B2
    B2 --> K1
    K1 --> K2
    K2 --> K3
    K3 --> K4
    K4 --> K7
    K5 --> K7
    K6 --> K7
    K2 --> K6

    L1 --> K7
    L1 --> U1
    L2 --> U1
    L3 --> U1

    S1 --> U1
    S1 --> U2
    S2 --> S1
    U2 --> K7

    %% Click Events
    click B1 "https://github.com/robbedgreef/yanix/tree/master/bootloader/stage1"
    click B2 "https://github.com/robbedgreef/yanix/tree/master/bootloader/stage2"
    click K1 "https://github.com/robbedgreef/yanix/tree/master/kernel/arch/i386/boot"
    click K2 "https://github.com/robbedgreef/yanix/tree/master/kernel/arch/i386/cpu"
    click K3 "https://github.com/robbedgreef/yanix/tree/master/kernel/mm"
    click K4 "https://github.com/robbedgreef/yanix/tree/master/kernel/arch/i386/proc"
    click K5 "https://github.com/robbedgreef/yanix/tree/master/kernel/fs"
    click K6 "https://github.com/robbedgreef/yanix/tree/master/kernel/drivers"
    click K7 "https://github.com/robbedgreef/yanix/tree/master/kernel/proc/syscalls"
    click L1 "https://github.com/robbedgreef/yanix/tree/master/libs/igl"
    click L2 "https://github.com/robbedgreef/yanix/tree/master/libs/libevent"
    click L3 "https://github.com/robbedgreef/yanix/tree/master/libs/libgfx"
    click U1 "https://github.com/robbedgreef/yanix/tree/master/apps"
    click U2 "https://github.com/robbedgreef/yanix/tree/master/system"
    click S1 "https://github.com/robbedgreef/yanix/tree/master/sysroot"
    click S2 "https://github.com/robbedgreef/yanix/tree/master/tools"

    %% Styles
    classDef hardware fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef bootloader fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef kernel fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef libs fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef userland fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef development fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
