Getting Started
Install, scaffold, generate & mount the plugin
Nucleus is one config object turned into a running backend. The loop is: declare config.nucleus.json, run the generator to produce the Drizzle schema, and mount NucleusElysiaPlugin in an Elysia app. The CLI can also scaffold an entire project — API, frontend, Kubernetes manifests and CI pipelines — so you start from a working system, not a blank file.
This page is the orientation: the two CLI commands, the two top-level primitives every config carries (appId, mode), and how the plugin is wired. Every block referenced here has its own deep page in the sidebar.
The CLI#
nucleus-core-ts ships a single CLI with two commands. scaffold gets you a whole project; generate keeps your schema in sync with the config.
1# scaffold a new project (API + frontend + k8s + pipelines)2npx nucleus-core-ts scaffold3 4# regenerate the Drizzle schema after editing config.json5npx nucleus-core-ts generate src/config.json src/drizzlescaffoldinteractiveOptionalInteractive project scaffolding. It lays down a complete starting point — the Elysia API, a frontend, Kubernetes manifests and CI/CD pipelines — so a new service is deployable from day one. (Aliases: init, new.)
generateconfig → DrizzleOptionalReads your config.json and emits the Drizzle schema + relations files the plugin loads, merging your entities with the built-in system tables (users, sessions, roles, claims, audit_logs, …). Run it whenever you change entities. (Alias: gen; a path argument is auto-detected as generate.)
The two primitives — appId & mode#
Every config has two scalar fields at its root, before any feature block. They get no page of their own because a sentence covers each.
appIdstringRequiredA unique, stable identifier for this service. Nucleus uses it to namespace Redis keys, brand transactional emails and tag monitoring/audit data — so two services sharing one Redis never collide. Choose it once; don't change it in production.
mode'development' | 'production'OptionalFlips framework-wide safety rails. development gives verbose errors, relaxed cookie flags and pretty logs; production hardens cookies (Secure / SameSite), trims error detail, switches logs to compact JSON and assumes HTTPS.
"development"Mounting the plugin#
The generated schema and relations are handed to NucleusElysiaPlugin alongside the path to your config. That single plugin mounts every enabled feature's routes.
1import { Elysia } from "elysia";2import { NucleusElysiaPlugin } from "nucleus-core-ts";3import * as schema from "./drizzle/schema";4import * as relations from "./drizzle/relations";5 6const app = new Elysia()7 .use(8 NucleusElysiaPlugin({9 options: "./src/config.json", // path to config.nucleus.json10 schema, // generated Drizzle schema11 relations, // generated relations12 swagger: true, // mount the OpenAPI / Swagger UI13 }),14 )15 .listen(9000);optionsstring (path)OptionalPath to your config.nucleus.json. Secrets inside it are env-var NAMES, resolved from process.env at boot — so the same file ships across environments.
schema / relationsgenerated modulesOptionalThe Drizzle schema and relations produced by generate. The plugin pushes the schema to Postgres on boot and uses relations for the Query API's with expansion.
swaggerbooleanOptionalMounts an OpenAPI page built from the TypeBox schemas every entity and route generates — so your live API is self-documenting in addition to this site.
Related sections