src/backend/doc/Kernel.md
The Puter Kernel is the core runtime component of the Puter system. It provides the foundational infrastructure for:
This kernel is responsible for orchestrating the startup sequence and ensuring that all necessary services, modules, and environmental configurations are properly loaded before the application enters its operational state.
Modular Architecture:
The Kernel supports both internal and external modules:
tools/run-selfhosted.js, via the add_module() method.package.json entries and
running npm install as needed.Service Container & Registry:
The Kernel initializes a service container that manages a wide range of services. Services can:
boot.consolidation, boot.activation, boot.ready) to
orchestrate a stable and consistent environment.Runtime Environment Setup:
The Kernel sets up a RuntimeEnvironment to determine configuration paths and environment parameters. It also provides global helpers like kv for key-value storage and cl for simplified console logging.
Logging and Debugging:
Uses a temporary BootLogger for the initialization phase until LogService is
initialized, at which point it will replace the boot logger. Debugging features
(ll, xtra_log) are enabled in development environments for convenience.
Constructor:
When a Kernel instance is created, it sets up basic parameters, initializes an empty
module list, and prepares useapi() integration.
Booting:
The boot() method:
yargs._runtime_init() to set up the RuntimeEnvironment and boot logger.servicesc instance of Container).Module Installation:
Internal modules are registered and installed first.
External modules are discovered, packaged, installed, and their code is executed.
External modules are given a special context with access to useapi(), a dynamic
import mechanism for Puter modules and extensions.
Service Bootstrapping:
After modules and extensions are installed, services are initialized and activated.
For more information about how this works, see boot-sequence.md.