# kaansenol5/vibeos architecture

> Architecture diagram of the GitHub repository kaansenol5/vibeos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaansenol5/vibeos
- Repository: https://github.com/kaansenol5/vibeos

## Overview

1. **Overall shape**
VibeOS is a monolithic hobby OS for ARM64, split into a small boot chain, a kernel, a platform-specific hardware layer, and a substantial user space. It runs in QEMU and on Raspberry Pi Zero 2W, with most runtime behavior determined by the kernel plus bundled apps in the root filesystem.

2. **Boot and image layout**
Startup begins in assembly boot code under `boot/`, then transfers into the kernel via the linker scripts (`linker.ld`, `linker-pi.ld`). The build produces a disk image rooted at `vibeos_root/`, which contains boot config, help docs, binaries, assets, and temporary/runtime directories.

3. **Kernel core**
The `kernel/` tree is the OS heart: process management, cooperative multitasking with preemptive fallback, interrupt handling, memory allocation, logging, and system APIs. Files like `process.c`, `context.S`, `irq.c`, `memory.c`, `tls.c`, and `kapi.c` define the kernel’s execution model and the interface exposed to user programs.

4. **Platform abstraction boundary**
Hardware-specific code is isolated under `kernel/hal/`, with separate backends for `qemu/` and `pizero2w/`. This is the main portability boundary: the kernel logic stays mostly shared, while framebuffer, keyboard, serial, DMA, IRQ, and storage drivers differ by target.

5. **Device and I/O subsystems**
The kernel owns drivers for framebuffer, console, keyboard, mouse, RTC, USB, networking, and virtual block devices. On the Pi, USB is handled through the DWC2 stack; on QEMU, simplified platform drivers provide the same abstractions. These drivers feed the higher-level console, GUI, shell, and networking code.

6. **Filesystem and storage path**
Persistent storage flows through FAT32 and VFS code in `kernel/fat32.c`, `kernel/vfs.c`, and related modules. The OS also has `initramfs` support, plus a root filesystem image in `vibeos_root/` that holds `/bin`, `/etc`, `/lib`, `/tmp`, and documentation/assets. User programs are loaded from this filesystem rather than being baked into the kernel.

7. **User/kernel interface**
User programs are built separately under `user/` and link against `user/lib/`, which provides startup code and the VibeOS API headers. The boundary is the kernel API exposed via `vibe.h` and the kernel-side `kapi` implementation; this is how apps access files, graphics, input, network, audio, and process services.

8. **Desktop and interactive shell**
The primary interactive environment is split between a GUI desktop and a terminal shell. The kernel provides low-level console and framebuffer services, while user-space apps like `desktop`, `term`, `files`, `textedit`, and `vim` build the actual UI. The boot config in `/etc/boot.cfg` can choose whether the system starts in desktop or shell mode.

9. **Networking stack**
Networking is implemented inside the kernel with its own TCP/IP stack: Ethernet, ARP, IP, ICMP, UDP, and TCP. Higher-level user applications like the browser and `ping` consume this stack through kernel APIs. TLS/HTTPS support depends on the vendored TLSe library mentioned in the README.

10. **Graphics and media pipeline**
Graphics flow from kernel framebuffer support into the UI and apps. The browser, image viewers, desktop, and games render through VibeOS graphics APIs; font and text rendering are supported by `font.c` and `ttf.c`. Audio is similarly kernel-backed through sound drivers and exposed to apps like `music`, `play`, and DOOM.

11. **Bundled user-space applications**
`user/bin/` is the application layer: coreutils-style commands, GUI apps, games, editors, network tools, and demos. Several apps are notable integration points: `doom` wraps `doomgeneric`, `vibecode` and `vim` provide editing environments, `browser` exercises networking plus rendering, and `micropython`/`tcc` expose programming environments inside the OS.

12. **Embedded third-party subsystems**
The repo vendors large external codebases as architectural subsystems, not just libraries: MicroPython, TinyCC, DoomGeneric, and support libraries like minimp3 and stb. These are integrated as separate trees because they provide whole runtimes or feature domains—scripting, compilation, game porting, and media/graphics decoding.

13. **Build and deployment**
The top-level build produces both kernel and user-space artifacts, then stages them into `vibeos_root/` and a bootable image. Separate targets exist for QEMU and Pi. The build layout makes the OS easy to diagram as: bootloader → kernel → device abstractions → user-space programs → root filesystem assets.

14. **Diagram takeaway**
If you’re drawing the architecture, the key boundaries are: boot vs kernel, kernel vs HAL, kernel vs user space, and local filesystem vs bundled runtime/assets. The main data flows are input/device events into kernel services, kernel services into GUI/shell/apps, and user apps back into kernel-managed storage, networking, graphics, and audio.

Main entry points: [`kernel/kernel.c`](https://github.com/kaansenol5/vibeos/blob/main/kernel/kernel.c) (Kernel core), [`user/bin/desktop.c`](https://github.com/kaansenol5/vibeos/blob/main/user/bin/desktop.c) (Apps), [`user/lib/vibe.h`](https://github.com/kaansenol5/vibeos/blob/main/user/lib/vibe.h) (User lib), [`vibeos_root/etc/boot.cfg`](https://github.com/kaansenol5/vibeos/blob/main/vibeos_root/etc/boot.cfg) (Root image)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_boot["Boot"]
  node_n_boot["Boot code<br/>assembly boot"]
  node_n_linker["Link scripts<br/>linker layout<br/>[linker.ld]"]
end

subgraph group_grp_kernel["Kernel"]
  node_n_kernel_core["Kernel core<br/>os kernel<br/>[kernel.c]"]
  node_n_exec["Proc model<br/>scheduler<br/>[process.c]"]
  node_n_mem["Memory<br/>allocator mm<br/>[memory.c]"]
  node_n_irq["Interrupts<br/>irq layer<br/>[irq.c]"]
  node_n_io_core["Console I/O<br/>display/input<br/>[console.c]"]
  node_n_filesystem["Storage<br/>vfs + fat32<br/>[vfs.c]"]
  node_n_net["Networking<br/>tcp/ip stack<br/>[net.c]"]
  node_n_audio["Audio<br/>sound drivers<br/>[virtio_sound.c]"]
  node_n_hal_qemu["QEMU HAL<br/>platform backend<br/>[platform.c]"]
  node_n_hal_pi["Pi HAL<br/>platform backend<br/>[platform.c]"]
end

subgraph group_grp_user["User space"]
  node_n_userlib["User lib<br/>crt + api<br/>[vibe.h]"]
  node_n_shell["Shell<br/>interactive ui<br/>[term.c]"]
  node_n_apps["Apps<br/>user programs<br/>[desktop.c]"]
end

subgraph group_grp_vendor["Vendors"]
  node_n_mpy["MicroPython<br/>embedded runtime<br/>[main.c]"]
  node_n_tcc["TinyCC<br/>embedded compiler<br/>[tcc_main.c]"]
  node_n_doom["DoomGeneric<br/>game port"]
end

subgraph group_grp_root["Root FS"]
  node_n_rootfs["Root image<br/>filesystem image<br/>[boot.cfg]"]
  node_n_help["Help docs<br/>docs bundle<br/>[index.html]"]
end

node_n_boot -->|"linked by"| node_n_linker
node_n_boot -->|"enters"| node_n_kernel_core
node_n_kernel_core -->|"runs"| node_n_exec
node_n_kernel_core -->|"allocates"| node_n_mem
node_n_kernel_core -->|"handles"| node_n_irq
node_n_kernel_core -->|"exposes"| node_n_io_core
node_n_kernel_core -->|"mounts"| node_n_filesystem
node_n_kernel_core -->|"routes"| node_n_net
node_n_kernel_core -->|"drives"| node_n_audio
node_n_hal_qemu -->|"backs"| node_n_kernel_core
node_n_hal_pi -->|"backs"| node_n_kernel_core
node_n_hal_pi -->|"storage"| node_n_filesystem
node_n_userlib -->|"calls"| node_n_kernel_core
node_n_shell -->|"links"| node_n_userlib
node_n_apps -->|"links"| node_n_userlib
node_n_apps -->|"loaded from"| node_n_filesystem
node_n_apps -->|"uses"| node_n_net
node_n_apps -->|"renders via"| node_n_io_core
node_n_apps -->|"plays via"| node_n_audio
node_n_mpy -->|"bridges"| node_n_userlib
node_n_tcc -->|"bridges"| node_n_userlib
node_n_doom -->|"renders via"| node_n_io_core
node_n_rootfs -->|"contains"| node_n_apps
node_n_rootfs -->|"contains"| node_n_help
node_n_rootfs -->|"configures"| node_n_shell
node_n_filesystem -->|"serves"| node_n_rootfs
node_n_help -->|"documents"| node_n_apps

click node_n_boot "https://github.com/kaansenol5/vibeos/tree/main/boot"
click node_n_linker "https://github.com/kaansenol5/vibeos/blob/main/linker.ld"
click node_n_kernel_core "https://github.com/kaansenol5/vibeos/blob/main/kernel/kernel.c"
click node_n_exec "https://github.com/kaansenol5/vibeos/blob/main/kernel/process.c"
click node_n_mem "https://github.com/kaansenol5/vibeos/blob/main/kernel/memory.c"
click node_n_irq "https://github.com/kaansenol5/vibeos/blob/main/kernel/irq.c"
click node_n_io_core "https://github.com/kaansenol5/vibeos/blob/main/kernel/console.c"
click node_n_filesystem "https://github.com/kaansenol5/vibeos/blob/main/kernel/vfs.c"
click node_n_net "https://github.com/kaansenol5/vibeos/blob/main/kernel/net.c"
click node_n_audio "https://github.com/kaansenol5/vibeos/blob/main/kernel/virtio_sound.c"
click node_n_hal_qemu "https://github.com/kaansenol5/vibeos/blob/main/kernel/hal/qemu/platform.c"
click node_n_hal_pi "https://github.com/kaansenol5/vibeos/blob/main/kernel/hal/pizero2w/platform.c"
click node_n_userlib "https://github.com/kaansenol5/vibeos/blob/main/user/lib/vibe.h"
click node_n_shell "https://github.com/kaansenol5/vibeos/blob/main/user/bin/term.c"
click node_n_apps "https://github.com/kaansenol5/vibeos/blob/main/user/bin/desktop.c"
click node_n_mpy "https://github.com/kaansenol5/vibeos/blob/main/micropython/ports/vibeos/main.c"
click node_n_tcc "https://github.com/kaansenol5/vibeos/blob/main/tinycc/vibeos/tcc_main.c"
click node_n_doom "https://github.com/kaansenol5/vibeos/blob/main/user/bin/doom/doomgeneric_vibeos.c"
click node_n_rootfs "https://github.com/kaansenol5/vibeos/blob/main/vibeos_root/etc/boot.cfg"
click node_n_help "https://github.com/kaansenol5/vibeos/blob/main/vibeos_root/etc/help/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_boot,node_n_linker toneBlue
class node_n_kernel_core,node_n_exec,node_n_mem,node_n_irq,node_n_io_core,node_n_filesystem,node_n_net,node_n_audio,node_n_hal_qemu,node_n_hal_pi toneAmber
class node_n_userlib,node_n_shell,node_n_apps toneMint
class node_n_mpy,node_n_tcc,node_n_doom toneRose
class node_n_rootfs,node_n_help toneIndigo
```

## Components

### Boot

Startup code and image entrypoint

- [Boot code](https://github.com/kaansenol5/vibeos/tree/main/boot): assembly boot · Early ARM64 boot entry for QEMU and Pi targets · `boot`
- [Link scripts](https://github.com/kaansenol5/vibeos/blob/main/linker.ld): linker layout · Kernel and user-space memory layout definitions · `linker.ld`

### Kernel

Core OS services and drivers

- [Kernel core](https://github.com/kaansenol5/vibeos/blob/main/kernel/kernel.c): os kernel · Main execution model, process management, scheduling, and syscalls · `kernel/kernel.c`
- [Proc model](https://github.com/kaansenol5/vibeos/blob/main/kernel/process.c): scheduler · Processes, context switching, TLS, and shell-facing execution control · `kernel/process.c`
- [Memory](https://github.com/kaansenol5/vibeos/blob/main/kernel/memory.c): allocator mm · Kernel memory management and low-level allocation · `kernel/memory.c`
- [Interrupts](https://github.com/kaansenol5/vibeos/blob/main/kernel/irq.c): irq layer · Vectoring, IRQ handling, and preemption-related control flow · `kernel/irq.c`
- [Console I/O](https://github.com/kaansenol5/vibeos/blob/main/kernel/console.c): display/input · Framebuffer console, cursor, fonts, keyboard, mouse, and terminal-facing I/O · `kernel/console.c`
- [Storage](https://github.com/kaansenol5/vibeos/blob/main/kernel/vfs.c): vfs + fat32 · Filesystem, initramfs, ELF loading, and persistent storage path · `kernel/vfs.c`
- [Networking](https://github.com/kaansenol5/vibeos/blob/main/kernel/net.c): tcp/ip stack · Kernel networking stack and virtual device integration · `kernel/net.c`
- [Audio](https://github.com/kaansenol5/vibeos/blob/main/kernel/virtio_sound.c): sound drivers · Kernel-backed sound output for user-space media apps · `kernel/virtio_sound.c`
- [QEMU HAL](https://github.com/kaansenol5/vibeos/blob/main/kernel/hal/qemu/platform.c): platform backend · QEMU-specific device implementations · `kernel/hal/qemu/platform.c`
- [Pi HAL](https://github.com/kaansenol5/vibeos/blob/main/kernel/hal/pizero2w/platform.c): platform backend · Raspberry Pi Zero 2W hardware implementations including USB and storage · `kernel/hal/pizero2w/platform.c`

### User space

Applications and user libraries

- [User lib](https://github.com/kaansenol5/vibeos/blob/main/user/lib/vibe.h): crt + api · User-space startup code, graphics helpers, and VibeOS API headers · `user/lib/vibe.h`
- [Shell](https://github.com/kaansenol5/vibeos/blob/main/user/bin/term.c): interactive ui · Terminal and desktop entry points managed in user space · `user/bin/term.c`
- [Apps](https://github.com/kaansenol5/vibeos/blob/main/user/bin/desktop.c): user programs · Core utilities, editors, browser, games, and demos · `user/bin/desktop.c`

### Vendors

Embedded third-party runtimes and ports

- [MicroPython](https://github.com/kaansenol5/vibeos/blob/main/micropython/ports/vibeos/main.c): embedded runtime · Vendored Python runtime ported to VibeOS · `micropython/ports/vibeos/main.c`
- [TinyCC](https://github.com/kaansenol5/vibeos/blob/main/tinycc/vibeos/tcc_main.c): embedded compiler · Vendored C compiler and VibeOS port · `tinycc/vibeos/tcc_main.c`
- [DoomGeneric](https://github.com/kaansenol5/vibeos/blob/main/user/bin/doom/doomgeneric_vibeos.c): game port · Vendored Doom engine adapted to the OS · `user/bin/doom/doomgeneric_vibeos.c`

### Root FS

Staged filesystem image and bundled assets

- [Root image](https://github.com/kaansenol5/vibeos/blob/main/vibeos_root/etc/boot.cfg): filesystem image · Staged boot config, help docs, binaries, temp areas, and sample content · `vibeos_root/etc/boot.cfg`
- [Help docs](https://github.com/kaansenol5/vibeos/blob/main/vibeos_root/etc/help/index.html): docs bundle · Bundled system and program documentation served from the root filesystem · `vibeos_root/etc/help/index.html`

## Connections

- Boot code → Link scripts: linked by · Boot code hands off according to the memory layout
- Boot code → Kernel core: enters · Early startup transfers into the kernel
- Kernel core → Proc model: runs · Kernel execution model and process control
- Kernel core → Memory: allocates · Memory management supports kernel subsystems
- Kernel core → Interrupts: handles · Interrupts drive scheduling and device events
- Kernel core → Console I/O: exposes · Console, framebuffer, input, and text rendering services
- Kernel core → Storage: mounts · Filesystem services load programs and assets
- Kernel core → Networking: routes · Network stack is implemented in the kernel
- Kernel core → Audio: drives · Kernel sound services feed media apps
- QEMU HAL → Kernel core: backs · QEMU-specific platform support underpins the shared kernel
- Pi HAL → Kernel core: backs · Pi-specific platform support underpins the shared kernel
- Pi HAL → Storage: storage · Pi backend includes eMMC and USB storage path
- User lib → Kernel core: calls · User apps reach kernel services through VibeOS API
- Shell → User lib: links · Shell and desktop apps use the shared user library
- Apps → User lib: links · Bundled applications depend on the user-space runtime layer
- Apps → Storage: loaded from · Applications are staged into the root filesystem
- Apps → Networking: uses · Browser and network tools consume kernel networking
- Apps → Console I/O: renders via · GUI apps and terminal tools use console/graphics/input services
- Apps → Audio: plays via · Media apps rely on kernel-backed audio
- MicroPython → User lib: bridges · Python runtime is integrated through the VibeOS user interface
- TinyCC → User lib: bridges · Compiler tooling is exposed as a user-space program
- DoomGeneric → Console I/O: renders via · Doom port consumes graphics and input services
- Root image → Apps: contains · Root image stages the executable set
- Root image → Help docs: contains · Documentation and program help live in the filesystem image
- Root image → Shell: configures · Boot configuration can start desktop or shell mode
- Storage → Root image: serves · Kernel loads from the staged root image
- Help docs → Apps: documents · Help pages describe bundled programs and services
