# ddn44/monix architecture

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

- Interactive diagram: https://gitdiagram.com/ddn44/monix
- Repository: https://github.com/ddn44/monix

## Overview

##### Main Components
- Bootloader: The “boot” directory contains assembly files (boot.asm, bootloader.asm, multiboot.asm) that are responsible for early boot processes and complying with the multiboot spec.
- Kernel: The “kernel” directory is central and includes C and assembly files. There are subdirectories and files for interrupt handling (kernel/asm/idt.asm, kernel/irq.c), memory management (kernel/mem/mem.c), process management (kernel/procman.c) and terminal output (kernel/term/term.c). The linker script (kernel/kernel.ld) also hints at how the kernel binary is linked.
- Drivers: The “drivers” directory (with files like ata.c, keyboard.c, serial.c) implements hardware device interactions.
- Filesystem: The “fs” directory contains code for handling disks and FAT file systems (files like disk.c, fat.c, file.c), supported also by include files in the “Include” directory (fs.h, fat.h).
- /Headers: The “Include” directory aggregates header files for various subsystems (e.g., ata.h, irq.h, mem.h, syscalls.h) shared across boot, kernel, and drivers.
- Build and Deployment: Files such as CMakeLists.txt, build scripts (buildboot.sh, buildkernel.sh, makedisk.sh, makeiso.sh, etc.) and configuration files (like bx_enh_dbg.ini and bochsrc.txt) illustrate how the project is built and tested/emulated (via qemu scripts).
- ISO/Boot Image: The “iso” directory with grub configuration and kernel image (kernel.elf) indicates the final packaged output, likely for deployment via bootloaders like GRUB.

##### Relationships and Interactions
- Boot Process: Start with the Bootloader component that initializes hardware and loads the kernel into memory.
- Kernel Core: The kernel then takes over, setting up low-level functions such as global descriptor table (kernel/gdt.c), interrupt service routines (kernel/irq.c), memory management, and process management.
- Device Drivers: Within the kernel, device drivers (from the “drivers” directory) handle interactions with hardware (ATA interfaces, keyboard, and serial ports). These modules are likely invoked by interrupt routines.
- Filesystem Operations: The filesystem code (in both “fs” directory and corresponding header files) provides access to disk storage, working closely with drivers and kernel space to read/write data.
- Build Process: The build scripts, linker files and configuration (CMakeLists.txt, linker scripts, .bat/.sh files) tie together the compilation and linking phases necessary to generate the operating system image (os.img, kernel.elf).

##### Architectural Patterns and Design Principles
- Modularity: The project is broken into clear modules (bootloader, kernel, drivers, filesystem) to isolate concerns.
- Layered Architecture: There’s a natural layering from hardware initialization (bootloader) up to the high-level kernel operations and drivers.
- Interaction through Defined Interfaces: The inclusion of header files (“Include”) for each subsystem suggests that explicit interfaces are used for communication across different layers.

##### Relevant Technologies and Frameworks
- Assembly and C Integration: Use of assembly (boot and some kernel parts) alongside C for kernel logic.
- Multiboot Standard: The bootloader components hint at compliance with the multiboot specification.
- Emulation Tools: Configuration and scripts for QEMU indicate testing under emulation.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Monix Operating System"]:::os

    subgraph "Core Components"
        B["Bootloader Module"]:::bootloader
        subgraph "Kernel Core"
            C0["Kernel Core"]:::kernel
            C1["Interrupt/Exception Handling"]:::kernelSub
            C2["Memory Management"]:::kernelSub
            C3["Process Management"]:::kernelSub
            C4["Terminal/Console"]:::kernelSub
            C5["Global Descriptor Table"]:::kernelSub
        end
        D["Device Drivers"]:::drivers
        E["Filesystem Operations"]:::filesystem
        F["Include/Headers"]:::include
    end

    subgraph "Supporting Tools"
        subgraph "Build & Deployment Tools"
            T["CMakeLists.txt"]:::build
            J["buildboot.sh"]:::build
            K["buildkernel.sh"]:::build
            L["makedisk.sh"]:::build
            M["makeiso.sh"]:::build
            N["makeimg.sh"]:::build
            O["mntdisk.sh"]:::build
            P["bx_enh_dbg.ini"]:::build
            Q["bochsrc.txt"]:::build
            R["qemu.bat"]:::build
            S["qemu.sh"]:::build
            G["Build & Deployment Tools Summary"]:::build
        end
        H["ISO & Boot Image Packaging"]:::iso
        I["External Emulators (QEMU)"]:::emulator
    end

    %% Connections
    A --> B
    B -->|"loads"| C0
    C0 -->|"manages"| C1
    C0 -->|"manages"| C2
    C0 -->|"manages"| C3
    C0 -->|"manages"| C4
    C0 -->|"manages"| C5
    C0 -->|"invokes"| D
    C0 -->|"accesses"| E
    D -->|"depends"| F
    E -->|"depends"| F
    G -->|"builds"| A
    G -->|"creates"| H
    H -->|"supports"| B
    I -->|"tests"| A

    %% Build Tools details
    T --> G
    J --> G
    K --> G
    L --> G
    M --> G
    N --> G
    O --> G
    P --> G
    Q --> G
    R --> G
    S --> G

    %% Click Events
    click B "https://github.com/ddn44/monix/tree/main/boot"
    click C0 "https://github.com/ddn44/monix/tree/main/kernel"
    click C1 "https://github.com/ddn44/monix/blob/main/kernel/irq.c"
    click C2 "https://github.com/ddn44/monix/blob/main/kernel/mem/mem.c"
    click C3 "https://github.com/ddn44/monix/blob/main/kernel/procman.c"
    click C4 "https://github.com/ddn44/monix/blob/main/kernel/term/term.c"
    click C5 "https://github.com/ddn44/monix/blob/main/kernel/gdt.c"
    click D "https://github.com/ddn44/monix/tree/main/drivers"
    click E "https://github.com/ddn44/monix/tree/main/fs"
    click F "https://github.com/ddn44/monix/tree/main/Include"
    click T "https://github.com/ddn44/monix/blob/main/CMakeLists.txt"
    click J "https://github.com/ddn44/monix/blob/main/buildboot.sh"
    click K "https://github.com/ddn44/monix/blob/main/buildkernel.sh"
    click L "https://github.com/ddn44/monix/blob/main/makedisk.sh"
    click M "https://github.com/ddn44/monix/blob/main/makeiso.sh"
    click N "https://github.com/ddn44/monix/blob/main/makeimg.sh"
    click O "https://github.com/ddn44/monix/blob/main/mntdisk.sh"
    click P "https://github.com/ddn44/monix/blob/main/bx_enh_dbg.ini"
    click Q "https://github.com/ddn44/monix/blob/main/bochsrc.txt"
    click R "https://github.com/ddn44/monix/blob/main/qemu.bat"
    click S "https://github.com/ddn44/monix/blob/main/qemu.sh"
    click G "https://github.com/ddn44/monix/blob/main/CMakeLists.txt"
    click H "https://github.com/ddn44/monix/tree/main/iso"

    %% Styles
    classDef os fill:#f2f2f2,stroke:#333,stroke-width:2px;
    classDef bootloader fill:#ffefc2,stroke:#333,stroke-width:2px;
    classDef kernel fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef kernelSub fill:#b3d7ff,stroke:#333,stroke-width:2px;
    classDef drivers fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef filesystem fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef include fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef build fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef iso fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef emulator fill:#e6ccff,stroke:#333,stroke-width:2px;
```
