# hatonthecat/solar-kernel architecture

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

- Interactive diagram: https://gitdiagram.com/hatonthecat/solar-kernel
- Repository: https://github.com/hatonthecat/solar-kernel

## Overview

##### Main components
- Hardware Layer:
– Microcontroller or similar low-power processing unit (e.g. an Ambiq Apollo MCU is suggested in the README).
– Solar power/energy harvesting subsystem (solar panel, power management circuitry, battery or capacitor storage).
– Peripherals such as a display (likely a low–power 2D screen), input devices (keyboard/touchpad), and any storage (e.g. microSD).
- Kernel Layer:
– The “SOLAR-Kernel” core (formerly “SOAP Kernel”), which is a minimal kernel designed for running a single application.
– Message passing and inter-process communication (IPC) mechanisms (paralleling ideas from microkernels like Minix 3).
– Device drivers and minimal loadable kernel modules (which can be “frozen” or only loaded when an application is active) that handle I/O and power management.
– A serial application scheduler which ensures only one user application is in execution at any moment to conserve resources.
- Application Layer:
– The loaded user application (or “application repository”) that runs when activated.
– Optional support for context switching (even if it means halting one application completely before launching the next).

##### Relationships and interactions
- Directional data flows: hardware inputs (sensors, user I/O) pass their data through drivers into the kernel.
- The kernel uses message passing to communicate with its device drivers and to coordinate application loading/execution.
- Applications interact with the kernel via system calls or a defined IPC mechanism.
- Power management/control loops (for instance, the kernel’s role in managing RTCs, low-power sleep modes, and load management relative to the available solar energy).

##### Design principles
- Minimalism by design: an “Occam’s razor” approach that strips the kernel (and its drivers) to only essential components.
- Low-memory, low-power footprint: only load what is necessary into RAM (for example, use “frozen”/decode in-place modules similar to ideas from Execute In Place (XiP) research).
- Serial operation: rather than executing many processes concurrently, the system focuses resources on running a single application at a time, with minimal context-switch overhead.
- Message-passing microkernel architecture: similar to the approach used in Minix 3, ensuring separation between kernel core and drivers/applications.

- Separate the architecture into as many components as makes sense, even if it means listing many kernel modules (e.g. separate modules for handling display, input, storage, message passing, and context switching).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Documentation
    subgraph "Documentation"
        D1["Design Rationale"]:::documentation
    end

    %% Hardware Layer
    subgraph "Hardware Layer"
        H1["Microcontroller (Ambiq Apollo MCU)"]:::hardware
        H2["Solar Energy Subsystem"]:::hardware
        H3["Peripherals (Display, Input, Storage)"]:::hardware
    end

    %% Kernel Layer
    subgraph "Kernel Layer"
        K1["SOLAR-Kernel Core"]:::kernel
        K2["Power & Resource Manager"]:::kernel
    end

    %% Application Layer
    subgraph "Application Layer"
        A1["User Application"]:::app
    end

    %% Connections from Documentation to Kernel
    D1 -->|"architectural_guide"| K1

    %% Hardware to Kernel connections
    H1 -->|"commands"| K1
    H3 -->|"I/O_data"| K1
    H2 -->|"power_feed"| K2
    K2 -->|"power_manage"| K1

    %% Kernel to Application connection
    K1 -->|"system_calls"| A1

    %% Click Events
    click K1 "https://github.com/hatonthecat/solar-kernel/blob/main/GitDiagram Open Source Kernel.pdf"
    click D1 "https://github.com/hatonthecat/solar-kernel/blob/main/README.md"

    %% Styles
    classDef documentation fill:#f3e5ab,stroke:#a67c00,stroke-width:2px;
    classDef hardware fill:#ffe6e6,stroke:#cc6666,stroke-width:2px;
    classDef kernel fill:#cceeff,stroke:#3399ff,stroke-width:2px;
    classDef app fill:#ccffcc,stroke:#33cc33,stroke-width:2px;
```
