Skip to main content
A GatoJS project starts with the core: sign-in, organizations, users, account and dashboard. Everything else is optional and comes as a kit module that you add when the project needs it and remove when it doesn’t. A module is copied into your repository as plain Next.js, Prisma and TypeScript code. There is no runtime plugin system and no package in node_modules to work around. This page explains how modules relate to the core, what each module does, and how the core learns about a module without importing it.

Core, kit modules and project modules

The word “module” means two things in GatoJS:
  • a kit module is the unit the CLI copies into a project and removes from it. A manifest in the kit (kit/modules/<name>.json) describes its files, npm dependencies, environment variables, schema relations, Docker services and CI steps.
  • a module definition is a src/features/<name>/module.ts file that calls defineModule({...}). It describes one feature: its key, menu entries, roles and declarations. The generator puts it in the module registry.
The core is the kit module core with five features (account, auth, dashboard, organizations, users). Each optional kit module has a single feature with the same name. Features you write yourself are project modules. See .wa/kit.json for the full file format.

Available modules

See the roadmap for planned work.

What each module adds

Dependencies between modules

No kit module lists another in requires, so you can add and remove each one independently. They still cooperate through core entry points: a module uses another module’s contribution when it is installed, and works without it. A project module can list a kit module in requires. gato remove then refuses to remove that kit module, and every CLI command refuses to run if a required module is missing.

How a module reaches your app

A module only adds files. It never edits core code. The core learns about the module through a generated registry and a few marked regions, which together form the seam layer.
1

Manifest

The kit describes the module in kit/modules/<name>.json. When you install it, the manifest is copied into .wa/kit.json, so from then on gato generate and gato remove work without the kit.
2

Copy

gato create --modules <list> or gato add <name> copies the module files, adds its npm dependencies to package.json and runs gato generate. If any module file already exists, gato add stops without changing anything.
3

Generate

gato generate rewrites src/modules.generated.ts, src/modules.client.generated.ts and src/i18n/locales.generated.ts, and fills the wa:* regions in core files.
4

Run

The core reads the registry (environment schemas, better-auth plugins, translations, menu, guards, audit sinks). Modules read each other’s declarations (auditActions, apiScopes, uploadPurposes) from the same registry.

Generated seams

A feature lands in a registry array only if it has the matching file. Don’t edit generated files or regions by hand: your CI checks that gato generate produces no diff. Adding or removing a module.ts, env.ts, auth.ts, audit-sink.ts or translation file requires npx gato generate. Changing the contents of an existing one does not, because the registry imports the files. See Module registry for details.
A module’s env.ts becomes part of the whole app’s environment schema. A missing or invalid variable stops the entire server at startup, not just the module. After adding api-keys, set API_KEY_PEPPER in .env before starting the app.

Core entry points that work without a module

Generated seams tell the core which modules exist. Entry points work the other way: they are core code that a module, or your own code, calls. Because they live in core files, they exist in every project, including projects without the module that handles them. The declaration types from src/shared/lib/modules/define-module.ts:
src/shared/lib/modules/define-module.ts
Labels in auditActions and apiScopes are looked up in the translation namespace of the module that declares them. That namespace is the feature folder name, so a module’s key must equal its folder name. Three rules follow for your code:
  • Use entry points and declarations freely. Calls to trackAudit and the auditActions, apiScopes and uploadPurposes fields build and run in a core-only project. They start working once the handling module is added, with no code change.
  • Import module files only when the module is installed. Importing <AuditTrail>, authenticateApiKey or <FileUpload> without audit-logs, api-keys or uploads fails typecheck and build with TS2307: Cannot find module '@/features/…'. A project module that has such imports should list the module in requires.
  • requireModuleAccess("<module>") for a missing module always returns 404 to a user with an active organization, because the registry has no definition for that key.

Shared rules

Kit modules follow the same rules as the core:
  • Organization isolation. Queries and commands get context from getOrgContext() or requireModuleAccess() and filter by organizationId explicitly. Routes authenticated with an API key have no session, so they filter by the organization from the key. See Organizations.
  • Service mode. Commands that change organization data have the signature (input, confirmation?) and call assertServiceModeConfirmed before touching Prisma. The UI calls them through useServiceModeAction().run. See Superadmin and service mode.
  • Tests and mutation gate. Module files are covered by the server entry point architecture test, and each module’s services/ folder is on the critical list in mutation-gate.json. See Testing.
  • Modules don’t edit core files. gato add and gato remove only touch wa:* regions and generated files in the core.

Install and remove a module

Choose modules when you create the project:
create-gato-app downloads the kit and passes --modules to gato create. The first migration (npx prisma migrate dev --name init) creates the module tables. See create-gato-app and gato create.
The alias npm run wa -- add uploads runs the same command.
gato remove leaves your data alone: database tables stay until you apply the migration, and stored files (local directory or bucket), .env values and your own code that imports the module are untouched. The migration permanently deletes the module’s data. Back up the tables first if you need the history.
A module added later with gato add works the same as one chosen at gato create. After either command the schema changes, so the migration belongs in your repository. See Database and migrations.

Choosing modules for a project

Pick each module on its own merits. The kit CI builds and tests the core alone, each module alone, and all three modules together.

Next steps

Audit logs

Record and browse organization events.

API keys

Let external systems call your API.

Uploads

Accept and serve organization files.

Write a kit module

Add a new module to the kit itself.