Skip to content

Commit c8894c7

Browse files
authored
Merge branch 'main' into warning_dialog
2 parents 2ca1f71 + 4c5f427 commit c8894c7

File tree

232 files changed

+6418
-2930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+6418
-2930
lines changed

Diff for: CONTRIBUTING.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ If you'd like to contribute code to Puter, you need to fork the project and subm
4545

4646
We'll review your pull request and work with you to get your changes merged into the project.
4747

48+
## Repository Structure
49+
50+
![file structure](./doc/File%20Structure.drawio.png)
51+
4852
## Your first code contribution
4953

5054
We maintain a list of issues that are good for first-time contributors. You can find these issues by searching for the [`good first issue`](https://github.com/HeyPuter/puter/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label in our [GitHub repository](https://github.com/HeyPuter/puter). These issues are designed to be relatively easy to fix, and we're happy to help you get started. Pick an issue that interests you, and leave a comment on the issue to let us know you're working on it.
5155

52-
<br>
53-
5456
## Documentation for Contributors
5557

56-
See [doc/contributors/index.md](./doc/contributors/index.md) for more information.
58+
### Backend
59+
See [src/backend/CONTRIBUTING.md](src/backend/CONTRIBUTING.md)
5760

5861
<br>
5962

Diff for: awesome/#DoesItRunPuter.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
- [Steam Deck](https://twitter.com/everythingSung/status/1782162352403828793)
1414
- [Ladybird Browser](https://x.com/HeyPuter/status/1810783504503800035)
1515
- [Garry's Mod](https://x.com/HeyPuter/status/1850587712786722862)
16+
- [Samsung Q88BA](https://x.com/AmirIsAround/status/1862614583263076540)

Diff for: doc/File Structure.drawio

+214
Large diffs are not rendered by default.

Diff for: doc/File Structure.drawio.png

187 KB
Loading

Diff for: doc/contributors/extensions.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
### `vscode`
2-
- `es6-string-html`
1+
## Puter Extensions
2+
3+
See the [Wiki Page](https://github.com/HeyPuter/puter/wiki/ex_extensions)

Diff for: doc/contributors/vscode.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### `vscode`
2+
- `es6-string-html`

Diff for: experiments/x86emu/www/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
*/
1919

20-
#!/usr/bin/env node
2120
/*
2221
* Copyright (C) 2024 Puter Technologies Inc.
2322
*

Diff for: mods/mods_available/kdmod/ShareTestService.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// we have these things registered in "useapi".
2222
const {
2323
get_user,
24-
generate_system_fsentries,
2524
invalidate_cached_user,
2625
deleteUser,
2726
} = require('../../../src/backend/src/helpers.js');
@@ -146,7 +145,8 @@ class ShareTestService extends use.Service {
146145
],
147146
);
148147
const user = await get_user({ username });
149-
await generate_system_fsentries(user);
148+
const svc_user = this.services.get('user');
149+
await svc_user.generate_default_fsentries({ user });
150150
invalidate_cached_user(user);
151151
return user;
152152
}

Diff for: package-lock.json

+49-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"webpack-cli": "^5.1.1"
3131
},
3232
"scripts": {
33-
"test": "npx mocha src/phoenix/test src/contextlink/test && node src/backend/tools/test",
33+
"test": "npx mocha src/phoenix/test && node src/backend/tools/test",
3434
"start=gui": "nodemon --exec \"node dev-server.js\" ",
3535
"start": "node ./tools/run-selfhosted.js",
3636
"build": "cd src/gui; node ./build.js",

Diff for: src/backend/doc/contributors/index.md renamed to src/backend/CONTRIBUTING.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
# Contributing to Puter's Backend
22

3+
## File Structure
4+
5+
6+
37
## Architecture
48

5-
- [boot sequence](./boot-sequence.md)
6-
- [modules and services](./modules.md)
9+
- [boot sequence](./doc/contributors/boot-sequence.md)
10+
- [modules and services](./doc/contributors/modules.md)
711

812
## Features
913

10-
- [protected apps](../features/protected-apps.md)
11-
- [service scripts](../features/service-scripts.md)
14+
- [protected apps](./doc/features/protected-apps.md)
15+
- [service scripts](./doc/features/service-scripts.md)
1216

1317
## Lists of Things
1418

15-
- [list of permissions](../lists-of-things/list-of-permissions.md)
19+
- [list of permissions](./doc/lists-of-things/list-of-permissions.md)
1620

1721
## Code-First Approach
1822

1923
If you prefer to understand a system by looking at the
2024
first files which are invoked and starting from there,
2125
here's a handy list!
2226

23-
- [Kernel](../../src/Kernel.js), despite its intimidating name, is a
27+
- [Kernel](./src/Kernel.js), despite its intimidating name, is a
2428
relatively simple (< 200 LOC) class which loads the modules
2529
(modules register services), and then starts all the services.
26-
- [RuntimeEnvironment](../../src/boot/RuntimeEnvironment.js)
30+
- [RuntimeEnvironment](./src/boot/RuntimeEnvironment.js)
2731
sets the configuration and runtime directories. It's invoked by Kernel.
2832
- The default setup for running a self-hosted Puter loads these modules:
29-
- [CoreModule](../../src/CoreModule.js)
30-
- [DatabaseModule](../../src/DatabaseModule.js)
31-
- [LocalDiskStorageModule](../../src/LocalDiskStorageModule.js)
33+
- [CoreModule](./src/CoreModule.js)
34+
- [DatabaseModule](./src/DatabaseModule.js)
35+
- [LocalDiskStorageModule](./src/LocalDiskStorageModule.js)
3236
- HTTP endpoints are registered with
33-
[WebServerService](../../src/services/WebServerService.js)
37+
[WebServerService](./src/services/WebServerService.js)
3438
by these services:
35-
- [ServeGUIService](../../src/services/ServeGUIService.js)
36-
- [PuterAPIService](../../src/services/PuterAPIService.js)
37-
- [FilesystemAPIService](../../src/services/FilesystemAPIService.js)
39+
- [ServeGUIService](./src/services/ServeGUIService.js)
40+
- [PuterAPIService](./src/services/PuterAPIService.js)
41+
- [FilesystemAPIService](./src/services/FilesystemAPIService.js)
3842

3943
## Development Philosophies
4044

@@ -71,7 +75,7 @@ doing the useless work that reveals what the useful work is.
7175

7276
## Underlying Constructs
7377

74-
- [putility's README.md](../../packages/putility/README.md)
78+
- [putility's README.md](../putility/README.md)
7579
- Whenever you see `AdvancedBase`, that's from here
7680
- Many things in backend extend this. Anything that doesn't only doesn't
7781
because it was written before `AdvancedBase` existed.

Diff for: src/backend/doc/Kernel.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Puter Kernel Documentation
2+
3+
## Overview
4+
5+
The **Puter Kernel** is the core runtime component of the Puter system. It provides the foundational infrastructure for:
6+
7+
- Initializing the runtime environment
8+
- Managing internal and external modules (extensions)
9+
- Setting up and booting core services
10+
- Configuring logging and debugging utilities
11+
- Integrating with third-party modules and performing dependency installs at runtime
12+
13+
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.
14+
15+
---
16+
17+
## Features
18+
19+
1. **Modular Architecture**:
20+
The Kernel supports both internal and external modules:
21+
- **Internal Modules**: Provided to Kernel by an initializing script, such
22+
as `tools/run-selfhosted.js`, via the `add_module()` method.
23+
- **External Modules**: Discovered in configured module directories and installed
24+
dynamically. This includes resolving and executing `package.json` entries and
25+
running `npm install` as needed.
26+
27+
2. **Service Container & Registry**:
28+
The Kernel initializes a service container that manages a wide range of services. Services can:
29+
- Register modules
30+
- Initialize dependencies
31+
- Emit lifecycle events (`boot.consolidation`, `boot.activation`, `boot.ready`) to
32+
orchestrate a stable and consistent environment.
33+
34+
3. **Runtime Environment Setup**:
35+
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.
36+
37+
4. **Logging and Debugging**:
38+
Uses a temporary `BootLogger` for the initialization phase until LogService is
39+
initialized, at which point it will replace the boot logger. Debugging features
40+
(`ll`, `xtra_log`) are enabled in development environments for convenience.
41+
42+
## Initialization & Boot Process
43+
44+
1. **Constructor**:
45+
When a Kernel instance is created, it sets up basic parameters, initializes an empty
46+
module list, and prepares `useapi()` integration.
47+
48+
2. **Booting**:
49+
The `boot()` method:
50+
- Parses CLI arguments using `yargs`.
51+
- Calls `_runtime_init()` to set up the `RuntimeEnvironment` and boot logger.
52+
- Initializes global debugging/logging utilities.
53+
- Sets up the service container (usually called `services`c instance of **Container**).
54+
- Invokes module installation and service bootstrapping processes.
55+
56+
3. **Module Installation**:
57+
Internal modules are registered and installed first.
58+
External modules are discovered, packaged, installed, and their code is executed.
59+
External modules are given a special context with access to `useapi()`, a dynamic
60+
import mechanism for Puter modules and extensions.
61+
62+
4. **Service Bootstrapping**:
63+
After modules and extensions are installed, services are initialized and activated.
64+
For more information about how this works, see [boot-sequence.md](./contributors/boot-sequence.md).
65+

Diff for: src/backend/exports.js

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const { Context } = require("./src/util/context.js");
2828
const { TestDriversModule } = require("./src/modules/test-drivers/TestDriversModule.js");
2929
const { PuterAIModule } = require("./src/modules/puterai/PuterAIModule.js");
3030
const { BroadcastModule } = require("./src/modules/broadcast/BroadcastModule.js");
31+
const { WebModule } = require("./src/modules/web/WebModule.js");
32+
const { Core2Module } = require("./src/modules/core/Core2Module.js");
33+
const { TemplateModule } = require("./src/modules/template/TemplateModule.js");
3134

3235

3336
module.exports = {
@@ -42,9 +45,17 @@ module.exports = {
4245
Context,
4346

4447
Kernel,
48+
49+
EssentialModules: [
50+
Core2Module,
51+
CoreModule,
52+
WebModule,
53+
TemplateModule,
54+
],
4555

4656
// Pre-built modules
4757
CoreModule,
58+
WebModule,
4859
DatabaseModule,
4960
PuterDriversModule,
5061
LocalDiskStorageModule,

0 commit comments

Comments
 (0)