# nicepotato-ms/potatos architecture

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

- Interactive diagram: https://gitdiagram.com/nicepotato-ms/potatos
- Repository: https://github.com/nicepotato-ms/potatos

## Overview

##### Project Type and Purpose
- Project Type: A homemade operating system kernel for “Potato Computers.”
- Purpose: To initialize hardware (via architecture-specific code), manage low-level operations (memory, interrupts, device drivers), and provide basic OS functionality. It’s implemented in C++ and assembly, with platform-specific code directories (for x86_64 and planned i686 support).

##### File Structure to Determine the Main Components
- Bootloader Support:
- Files like limine.conf and the bundled limine tool indicate integration with a bootloader.
- Architecture-Specific Code (“arch” directory):
- Separate directories for i686 and x86_64 demonstrate that core startup and low-level initialization code (GDT, paging, interrupts, etc.) are abstracted by architecture.
- Files such as archinc.mk, linker.ld, and architecture-specific headers and source files (e.g., in arch/x86_64/include and arch/x86_64/kernel) are used to adapt the kernel to the hardware.
- Kernel Core (“kernel” directory):
- Contains kernel source code (e.g., kernel/src/kmain.cpp) which forms the central control logic.
- Subdirectories like “kernel/lib/kernel” (handling panic, printk, error codes) and “kernel/lib/libc” (simplified standard library support) represent kernel-level services.
- Additional utilities like “kernel/include” provide core API interfaces for the rest of the OS.
- Support Libraries and Subsystems:
- Graphics support in both “kernel/lib/graphics” and related font files (in both kernel and misc) suggest dedicated components for rendering and system display.
- The organization into “lib”, “include”, and “src” fosters a modular design in the kernel.
- Miscellaneous and Build Tools:
- Files such as Makefile, modules.mk, tools.mk, and build.mk hint at a custom build process.
- The “misc” directory and additional test directories (e.g., misc/testenv) indicate test code and helper scripts.
- Versioning and Documentation:
- Files like version.json and version.py alongside GitHub folders for development logs and images help with version tracking and communication of design status.

## Diagram (Mermaid)

```mermaid
graph TD
    BuildSystem["Build System & Tools (Makefile, build.mk, modules.mk, tools.mk)"]:::build
    Bootloader["Bootloader (limine)"]:::boot

    subgraph "Architecture Layer"
        Arch_x86["AMD64 (arch/x86_64)"]:::arch
        Arch_i686["i686 (arch/i686)"]:::arch
    end

    subgraph "Kernel Core"
        Kernel_src["kmain.cpp (kernel/src)"]:::core
        Kernel_include["Core API (kernel/include)"]:::core
    end

    subgraph "Kernel Libraries & Support"
        Kernel_lib_kernel["Kernel Functionality (kernel/lib/kernel)"]:::lib
        Kernel_lib_libc["Libc Support (kernel/lib/libc)"]:::lib
        Kernel_graphics["Graphics Support (kernel/lib/graphics)"]:::lib
        Kernel_fonts["Font Definitions (kernel/include/fonts)"]:::lib
    end

    %% Connections
    BuildSystem -->|"compiles"| Bootloader
    Bootloader -->|"loads"| Arch_x86
    Bootloader -->|"loads"| Arch_i686
    Arch_x86 -->|"initializes"| Kernel_src
    Arch_i686 -->|"initializes"| Kernel_src
    Kernel_src -->|"uses"| Kernel_include
    Kernel_src -->|"calls"| Kernel_lib_kernel
    Kernel_src -->|"calls"| Kernel_lib_libc
    Kernel_src -->|"calls"| Kernel_graphics
    Kernel_src -->|"calls"| Kernel_fonts

    %% Click Events
    click BuildSystem "https://github.com/nicepotato-ms/potatos/tree/main/Makefile"
    click Bootloader "https://github.com/nicepotato-ms/potatos/blob/main/limine.conf"
    click Arch_x86 "https://github.com/nicepotato-ms/potatos/tree/main/arch/x86_64"
    click Arch_i686 "https://github.com/nicepotato-ms/potatos/tree/main/arch/i686"
    click Kernel_src "https://github.com/nicepotato-ms/potatos/tree/main/kernel/src"
    click Kernel_include "https://github.com/nicepotato-ms/potatos/tree/main/kernel/include"
    click Kernel_lib_kernel "https://github.com/nicepotato-ms/potatos/tree/main/kernel/lib/kernel"
    click Kernel_lib_libc "https://github.com/nicepotato-ms/potatos/tree/main/kernel/lib/libc"
    click Kernel_graphics "https://github.com/nicepotato-ms/potatos/tree/main/kernel/lib/graphics"
    click Kernel_fonts "https://github.com/nicepotato-ms/potatos/tree/main/kernel/include/fonts"

    %% Styles
    classDef boot fill:#f9a,stroke:#333,stroke-width:2px;
    classDef arch fill:#afa,stroke:#333,stroke-width:2px;
    classDef core fill:#aaf,stroke:#333,stroke-width:2px;
    classDef lib fill:#ffa,stroke:#333,stroke-width:2px;
    classDef build fill:#fa9,stroke:#333,stroke-width:2px;
```
