# leonmmcoset/cmleonos architecture

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

- Interactive diagram: https://gitdiagram.com/leonmmcoset/cmleonos
- Repository: https://github.com/leonmmcoset/cmleonos

## Overview

##### Project type and purpose
- CMLeanOS is a small, Cosmos-based operating system / shell environment written in C# targeting .NET 6.0+, with a custom kernel (Kernel.cs), file system, user system, shell, scripting engine (Branswe + UniLua), editor, utilities, and UI assets.

##### File structure
- Top-level artifacts:
- CMLeonOS.sln & .csproj (solution and project)
- Kernel.cs – the OS kernel entry point (Cosmos)
- System/ – core OS services (FileSystem.cs, UserSystem.cs)
- Logger/ – centralized logging (Logger.cs, LogEntry, LogLevel)
- UI/ – user interface layer (CUI.cs is present but note: custom UI overrides it per instructions)
- shell/ – shell framework (Shell.cs, CommandList.cs) and a rich Command pattern under shell/Commands/*
- interpreter/ – two engines: Branswe.cs (custom script) and UniLua (full Lua interpreter library)
- editor/ – built-in text editors (Editor.cs, Nano.cs)
- utils/ – helper utilities (Base64, SHA256, env manager, network config, Version)
- Wallpapers/ – static UI asset
- docs/ – documentation site (VuePress)

##### Main components & interactions
a. Components
1) Hardware & Cosmos microkernel layer
2) Kernel (Kernel.cs)
3) Core services:
– FileSystem service (System/FileSystem.cs)
– UserSystem service (System/UserSystem.cs)
– Logger service (Logger/Logger.cs)
4) Shell framework (shell/Shell.cs + CommandList) and individual Commands
5) Scripting engines:
– Branswe script engine (interpreter/Branswe.cs)
– UniLua engine (interpreter/UniLua/*) – note: UniLua is standalone, not embedded in Branswe
6) Built-in editors (editor/Editor.cs, Nano.cs)
7) Utilities (utils/*)
8) UI layer (UI/* + Wallpapers) – custom console UI, not the CUI.cs stub
9) Documentation site (docs/cmleonos) – separate from runtime
b. Relationships & data flow
- Hardware → Cosmos → Kernel
- Kernel → Core Services (filesystem, user, logger) via system calls
- Kernel & Services expose APIs to Shell
- Shell invokes Commands, which call into Core Services, Utilities, Editors, or Scripting Engines
- Branswe engine and UniLua engine invoked by Shell Commands (Script commands)
- UI layer registers as a consumer of Shell’s I/O streams, renders Wallpapers in background
- Logger subscribes to Kernel, Services, Shell, Interpreter events
c. Architectural patterns & principles
- Layered architecture: hardware → kernel → services → shell/apps → UI
- Command pattern in shell/Commands
- Separation of concerns: interpreter engines separate from shell logic; UI separate from core
- Plugin-like extensibility: new Commands or utilities can be dropped in shell/Commands or utils
d. Key technologies
- .NET 6.0, C#
- Cosmos OS DevKit
- UniLua (MIT‐licensed Lua interpreter library)
- Custom Branswe script engine
- VuePress for docs

##### Essential details to capture
- Separation of kernel vs. userland (shell, editors, scripts)
- Command pattern extensibility
- Dual-engine scripting (Branswe vs. UniLua)
- Custom UI overlay, not the default CUI stub
- Logger’s integration across all layers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    Hardware["Hardware & Cosmos Microkernel Layer"]:::kernel
    Kernel["Kernel Core"]:::kernel
    subgraph "Core Services"
        FileSystem["FileSystem Service"]:::kernel
        UserSystem["UserSystem Service"]:::kernel
        Logger["Logger Service"]:::kernel
    end
    subgraph "Shell Layer"
        Shell["Shell Framework"]:::shell
        ShellCL["CommandList"]:::shell
        subgraph "Shell Commands"
            EditorCmd("EditCommand"):::shell
            NanoCmd("NanoCommand"):::shell
            EnvCmd("EnvCommand"):::shell
            FSCommands("FileSystem Commands"):::shell
            HelpCmd("HelpCommand"):::shell
            AboutCmd("AboutCommand"):::shell
            VersionCmd("VersionCommand"):::shell
            RestartCmd("RestartCommand"):::shell
            ShutdownCmd("ShutdownCommand"):::shell
            BransweCmd("BransweCommand"):::shell
            ComCmd("ComCommand"):::shell
            LuaCmd("LuaCommand"):::shell
            SystemCommands("System Commands"):::shell
            UserCommands("User Commands"):::shell
            UtilityCommands("Utility Commands"):::shell
            TestGuiCmd("TestGuiCommand"):::shell
        end
    end
    subgraph "Editors"
        EditorCore["Editor.cs"]:::shell
        NanoCore["Nano.cs"]:::shell
    end
    subgraph "Scripting Engines"
        BransweEngine["Branswe Script Engine"]:::interpreter
        UniLua["UniLua Engine"]:::interpreter
    end
    subgraph "Utilities Toolkit"
        Base64["Base64 Utility"]:::utils
        SHA256["SHA256 Utility"]:::utils
        EnvMgr["EnvironmentVariableManager"]:::utils
        NetCfg["NetworkConfigManager"]:::utils
        VersionUtil["Version Utility"]:::utils
    end
    subgraph "UI Layer"
        CustomUI["Custom Console UI"]:::ui
        Wallpaper["Wallpapers"]:::ui
    end
    Docs["Documentation Site"]:::component

    %% Relationships
    Hardware -->|"Boot"| Kernel
    Kernel -->|"system calls"| FileSystem
    Kernel -->|"system calls"| UserSystem
    Kernel -->|"events"| Logger
    Kernel -->|"provides API"| Shell
    Shell -->|"uses"| ShellCL
    ShellCL -->|"manages"| EditorCmd
    ShellCL -->|"manages"| NanoCmd
    ShellCL -->|"manages"| EnvCmd
    ShellCL -->|"manages"| FSCommands
    ShellCL -->|"manages"| HelpCmd
    ShellCL -->|"manages"| AboutCmd
    ShellCL -->|"manages"| VersionCmd
    ShellCL -->|"manages"| RestartCmd
    ShellCL -->|"manages"| ShutdownCmd
    ShellCL -->|"manages"| BransweCmd
    ShellCL -->|"manages"| ComCmd
    ShellCL -->|"manages"| LuaCmd
    ShellCL -->|"manages"| SystemCommands
    ShellCL -->|"manages"| UserCommands
    ShellCL -->|"manages"| UtilityCommands
    ShellCL -->|"manages"| TestGuiCmd

    Shell -->|"ExecuteCommand()"| FileSystem
    Shell -->|"ExecuteCommand()"| UserSystem
    Shell -->|"ExecuteCommand()"| Logger
    Shell -->|"Invoke()"| EditorCore
    Shell -->|"Invoke()"| NanoCore
    Shell -->|"RunScript()"| BransweEngine
    Shell -->|"RunScript()"| UniLua
    Shell -->|"Call()"| Base64
    Shell -->|"Call()"| SHA256
    Shell -->|"Call()"| EnvMgr
    Shell -->|"Call()"| NetCfg
    Shell -->|"Call()"| VersionUtil
    Shell -->|"IO streams"| CustomUI
    CustomUI -->|"renders"| Wallpaper

    %% Logger subscriptions
    Kernel -->|"log events"| Logger
    FileSystem -->|"log events"| Logger
    UserSystem -->|"log events"| Logger
    Shell -->|"log events"| Logger
    BransweEngine -->|"log events"| Logger
    UniLua -->|"log events"| Logger

    %% Documentation
    Docs

    %% Click Events
    click Kernel "https://github.com/leonmmcoset/cmleonos/blob/main/Kernel.cs"
    click FileSystem "https://github.com/leonmmcoset/cmleonos/blob/main/System/FileSystem.cs"
    click UserSystem "https://github.com/leonmmcoset/cmleonos/blob/main/System/UserSystem.cs"
    click Logger "https://github.com/leonmmcoset/cmleonos/blob/main/Logger/Logger.cs"
    click Shell "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Shell.cs"
    click ShellCL "https://github.com/leonmmcoset/cmleonos/blob/main/shell/CommandList.cs"
    click EditorCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Editor/EditCommand.cs"
    click NanoCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Editor/NanoCommand.cs"
    click EnvCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Environment/EnvCommand.cs"
    click FSCommands "https://github.com/leonmmcoset/cmleonos/tree/main/shell/Commands/FileSystem/"
    click HelpCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Help/Help.cs"
    click AboutCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Info/About.cs"
    click VersionCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Info/Version.cs"
    click RestartCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Power/RestartCommand.cs"
    click ShutdownCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Power/ShutdownCommand.cs"
    click BransweCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Script/BransweCommand.cs"
    click ComCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Script/ComCommand.cs"
    click LuaCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/Script/LuaCommand.cs"
    click SystemCommands "https://github.com/leonmmcoset/cmleonos/tree/main/shell/Commands/System/"
    click UserCommands "https://github.com/leonmmcoset/cmleonos/tree/main/shell/Commands/User/"
    click UtilityCommands "https://github.com/leonmmcoset/cmleonos/tree/main/shell/Commands/Utility/"
    click TestGuiCmd "https://github.com/leonmmcoset/cmleonos/blob/main/shell/Commands/TestGuiCommand.cs"
    click BransweEngine "https://github.com/leonmmcoset/cmleonos/blob/main/interpreter/Branswe.cs"
    click UniLua "https://github.com/leonmmcoset/cmleonos/tree/main/interpreter/UniLua/"
    click EditorCore "https://github.com/leonmmcoset/cmleonos/blob/main/editor/Editor.cs"
    click NanoCore "https://github.com/leonmmcoset/cmleonos/blob/main/editor/Nano.cs"
    click Base64 "https://github.com/leonmmcoset/cmleonos/blob/main/utils/Base64.cs"
    click SHA256 "https://github.com/leonmmcoset/cmleonos/blob/main/utils/SHA256.cs"
    click EnvMgr "https://github.com/leonmmcoset/cmleonos/blob/main/utils/EnvironmentVariableManager.cs"
    click NetCfg "https://github.com/leonmmcoset/cmleonos/blob/main/utils/NetworkConfigManager.cs"
    click VersionUtil "https://github.com/leonmmcoset/cmleonos/blob/main/utils/Version.cs"
    click CustomUI "https://github.com/leonmmcoset/cmleonos/blob/main/UI/CUI.cs"
    click Wallpaper "https://github.com/leonmmcoset/cmleonos/blob/main/Wallpapers/wallpaper.bmp"
    click Docs "https://github.com/leonmmcoset/cmleonos/tree/main/docs/cmleonos/"

    %% Styles
    classDef kernel fill:#BBDEFB,color:#000;
    classDef shell fill:#C8E6C9,color:#000;
    classDef interpreter fill:#FFE0B2,color:#000;
    classDef ui fill:#E1BEE7,color:#000;
    classDef utils fill:#FFF9C4,color:#000;
    classDef component fill:#CFD8DC,color:#000;
```
