# try-supernova/supernova architecture

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

- Interactive diagram: https://gitdiagram.com/try-supernova/supernova
- Repository: https://github.com/try-supernova/supernova

## Overview

##### Project Type and Purpose
- The README and file tree show that Supernova is a Web OS (similar in spirit to Windows93/96) that boots as an offline, static web application.
- It has multiple subcomponents including the OS kernel (in /src), runtime components (the “41worker” under /src/41worker, which handles program execution in isolated workers), installer systems (various executables under /executables/installer and /executables/root), and the Tauri setup (in /src-tauri) that packages the app as a desktop application.
- Build scripts (in /scripts) and public static assets (in /public) support the build and delivery pipeline.

##### Analyzing the File Structure
- /src: Contains the core OS kernel. It includes directories for modules like:
- 41worker: Directly responsible for runtime process management, creating a sandboxed environment for Supernova applications.
- Assembly, FS, Startup (background processes, boot tasks, installer tasks), and utility modules.
- /executables: Contains different installer and runtime executable bundles that get built into zip files (installer.zip and rootfs.zip). These represent the packaged and deployable modules of the system.
- /public: Hosts static files (e.g., index.html, manifest.json, legal info) used by the static web version.
- /scripts: Build and pre-/post-build scripts that automate tasks such as cleaning, serving, and other custom build tasks.
- /src-tauri: Contains Rust code with Tauri configuration (Cargo.toml, build.rs, main.rs) that is used to generate the native desktop application.
- Configuration and environment files (.env.example, .gitignore, etc.) that manage linting, hot commit hooks, and overall project constraints.

##### Main Components
a. OS Kernel (Core of Supernova)
- Module: /src (including its subdivisions for runtime components, OS bootstrapping, FS management, and utilities).
- Submodules: “41worker” (responsible for program runtime), “Assembly” (handling low-level tasks), “Startup” (boot, background, installer setup).
b. Installers and Bundling System
- Components under /executables/installer and /executables/root.
- Packaging process that bundles these into zip files (installer.zip, rootfs.zip).
c. Build and Deployment Pipeline
- Build scripts under /scripts (prebuild and postbuild) and the build process in /src/build.
- How these scripts compile, bundle, and move assets to the /dist folder.
d. Public Static Assets
- /public directory representing the UI entry point (e.g., index.html, manifest, vendor.js) used to serve the Web OS.
e. Desktop Application Layer via Tauri
- /src-tauri serving as the connection between the web OS and native desktop features using Tauri (via Rust code).

##### Relationships and Interactions Between Components
- The OS kernel (from /src) is the heart of Supernova. It interacts closely with the 41worker runtime module for executing individual applications.
- The startup scripts (under /src/startup) ensure proper initialization by booting components like the GUI and background services.
- The installer and runtime executables (in /executables) are built separately from the core kernel; they are later zipped and used for installation or runtime provisioning.
- The build pipeline (using scripts and modules under /src/build) collects various aspects of the codebase and outputs a ready–to–run build into the /dist folder.
- The Tauri module ties the web OS with desktop capabilities by wrapping the static build in a native application shell.
- Static assets in /public serve the UI over HTTP (locally or on cloud deployments such as Cloudflare Pages as mentioned in the README).

##### Highlighting Architectural Patterns and Design Principles
- Modularization: The system is divided into distinct modules (OS kernel, runtime, installer, build scripts) to encourage separation of concerns.
- Build-Time Environment Differentiation: The use of NODE_ENV to toggle features (like devtools detection and obfuscation) illustrates environment-based compilation strategies.
- Isolation and Security: The use of Web Workers ("41worker") for running applications reflects an emphasis on process isolation to enhance security and performance.
- Multi-Platform Packaging: The Tauri (Rust) integration under /src-tauri adds an abstraction layer, supporting both web and desktop delivery models.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core System: OS Kernel and its modules
    subgraph "Core System"
        OSK["OS Kernel"]:::core
        Worker["41worker (Runtime)"]:::module
        Assembly["Assembly (Low-Level)"]:::module
        FS["FS (File System)"]:::module
        Startup["Startup"]:::module
        Utils["Utilities"]:::module
        OSK --> Worker
        OSK --> Assembly
        OSK --> FS
        OSK --> Startup
        OSK --> Utils
    end

    %% Build Pipeline: Build scripts and tasks
    subgraph "Build Pipeline"
        Scripts["Build Scripts"]:::build
        BuildModule["Build Tasks (/src/build)"]:::build
        Scripts --> BuildModule
    end

    %% Deployment: Installer, Public Assets, Build Output and Tauri Desktop
    subgraph "Deployment"
        Installers["Installers & Bundling"]:::installer
        PublicAssets["Public Static Assets"]:::public
        BuildOutput["Build Output (/dist)"]:::buildout
        Tauri["Tauri Desktop Wrapper"]:::tauri
        BuildModule --> BuildOutput
        PublicAssets --> BuildOutput
        Installers --> BuildOutput
        BuildOutput --> Tauri
    end

    %% Interconnections between major components
    OSK --> BuildModule
    Startup --> Installers

    %% Click Events
    click OSK "https://github.com/try-supernova/supernova/tree/develop/src"
    click Worker "https://github.com/try-supernova/supernova/tree/develop/src/41worker"
    click Assembly "https://github.com/try-supernova/supernova/tree/develop/src/Assembly"
    click Startup "https://github.com/try-supernova/supernova/tree/develop/src/startup"
    click Installers "https://github.com/try-supernova/supernova/tree/develop/executables"
    click Scripts "https://github.com/try-supernova/supernova/tree/develop/scripts"
    click BuildModule "https://github.com/try-supernova/supernova/tree/develop/src/build"
    click PublicAssets "https://github.com/try-supernova/supernova/tree/develop/public"
    click Tauri "https://github.com/try-supernova/supernova/tree/develop/src-tauri"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef module fill:#B0E0E6,stroke:#333,stroke-width:1px;
    classDef build fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef installer fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef public fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef tauri fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef buildout fill:#F0E68C,stroke:#000,stroke-width:2px;
    
    class OSK core;
    class Worker,Assembly,FS,Startup,Utils module;
    class Scripts,BuildModule build;
    class Installers installer;
    class PublicAssets public;
    class Tauri tauri;
    class BuildOutput buildout;
```
