$ show HeyPuter/puter
Puter is a full-stack, self-hosted 'internet computer' โ a browser-based desktop environment (file manager, app launcher, AI services, static-site hosting, serverless workers) backed by a Node.js kernel. The repo is a monorepo of five interlocking sub-packages: a TypeScript backend kernel (`src/backend`), a browser GUI (`src/gui`), a published JavaScript SDK (`src/puter-js`), a CLI (`src/cli`), and a Cloudflare-Worker port (`src/worker`) plus an MCP connector (`src/mcp-connector`). The kernel is the centerpiece: it layers clients (MySQL/Postgres/SQLite, DynamoDB, S3, Redis, email, alarms), stores (user, app, FS entry, session, share, permission, group, KV, OIDC, notification, subdomain), services (auth, FS, metering, permission, ACL, broadcast, notification, OIDC, app-icon, health), controllers (REST + WebDAV + WISP + Peer endpoints), and drivers (AI chat/TTS/STT/image/video/OCR, KV, apps, subdomains, notifications, workers) behind a custom `PuterServer` that wires them together with ordered peer-dependency construction. Configuration is a three-tier deep-merge (config.default.json โ config.json โ PUTER_CONFIG_PATH) computed at startup. The backend is well-tested with vitest unit, integration, and benchmark suites; the SDK ships with Playwright e2e tests. The GUI is a large, jQuery-based desktop UI with its own webpack build and a component system. Notable engineering: a type-safe permission/ACL system with rewriters and implicators, a metering/subscription model in microcents, a multi-engine database abstraction with ordered migrations, a driver pattern with per-operation cost tables, a token v1โv2 silent-migration path, a reauth coordinator with shared in-flight promises, and a worker-types package that provides template-literal route-param inference for the worker runtime. The codebase is actively maintained (June 2026), uses current Node 24 / TypeScript 5.9 / Express 5 tooling, and has CI for backend tests, docs builds, release-please, and Docker image publishing.
The LLM identified 9 files worth highlighting for reuse:
The kernel entry point implements a three-tier config resolution (bundled defaults โ user config.json โ env-specified PUTER_CONFIG_PATH) with a recursive deepMerge, then computes derived fields (origin, api_base_url, pub_port) and resolves path-valued config entries against either the runtime root (dist/) or the package root depending on whether the asset ships in the build output. A reusable pattern for any Node service that needs layered, file-based configuration with computed overrides.
Solves the lexical-vs-numeric sorting problem for migration files named engine_mig_N.sql (where *_mig_10 would sort before *_mig_2 lexically). Extracts the trailing integer for numeric comparison and falls back to lexical for non-matching names. A small, self-contained, reusable comparator for any migration runner that uses numbered filenames.
The SDK bootstrap demonstrates several non-obvious patterns: an environment detector (gui/app/web/web-worker/service-worker/nodejs) based on URL params and globals; a v1โv2 token silent-migration path that fires at boot and falls back to interactive reauth on failure; and a reauth coordinator (triggerReauth) that shares a single in-flight promise across parallel 401 callers, drives environment-specific flows (popup for web, postMessage to parent for app, no-op for gui, rejection for workers), and emits events. The reauth-coordinator idiom is reusable anywhere a client must serialize token refresh.
Defines the puter.drivers facade: list() enumerates available drivers, get(iface_name, service_name) returns a Driver proxy, and call(...) invokes methods directly. The DriverDescriptor / Driver split is a clean interface-segregation pattern for a client-side service-locator over a backend driver registry.
ExtractParams<S> is a recursive conditional template-literal type that parses route path literals like '/posts/:id/comments/:cid' or '/files/*path' into { id: string; cid: string } / { path: string }. Powers the worker router's get/post/put/delete methods so handler params are inferred with full type safety and no annotations. A textbook example of advanced TypeScript type-level programming that any typed HTTP router could adopt.
Abstract base class for AI chat providers (OpenAI, Claude, Gemini, etc.) implementing a uniform IChatProvider contract (models, list, complete) with per-model cost tables in microcents. The same pattern is replicated for TTS, image, video, OCR, and speech-to-speech drivers. A clean, extensible provider/plugin architecture with built-in metering โ reusable for any multi-vendor service integration.
toMicroCents converts dollar amounts to microcents (1 dollar = 1_000_000 * 100 ยตยข), the integer currency unit used throughout the metering service to avoid floating-point rounding. Combined with the per-operation cost tables (FS_COSTS, KV_COSTS, OCR_COSTS, etc.), this is a reusable pattern for precise billing/metering in any usage-based system.
A catch-all 404 handler that throws an HttpError(404) rather than writing the response directly, so the same error-handler pipeline serializes the body consistently with every other failure. A small but correct pattern for any Express/Fastify/Hono app that wants uniform error shapes.
Wraps dynamic import() with a @vite-ignore comment so vite skips static analysis while Node performs the import โ working around vitest's ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING that occurs with new Function('return import(s)'). A reusable helper for any codebase that needs runtime dynamic imports under both vitest and production.