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.tsfile that callsdefineModule({...}). It describes one feature: its key, menu entries, roles and declarations. The generator puts it in the module registry.
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 inrequires, 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.
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
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
trackAuditand theauditActions,apiScopesanduploadPurposesfields 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>,authenticateApiKeyor<FileUpload>withoutaudit-logs,api-keysoruploadsfails typecheck and build withTS2307: Cannot find module '@/features/…'. A project module that has such imports should list the module inrequires. 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()orrequireModuleAccess()and filter byorganizationIdexplicitly. 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 callassertServiceModeConfirmedbefore touching Prisma. The UI calls them throughuseServiceModeAction().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 thecriticallist inmutation-gate.json. See Testing. - Modules don’t edit core files.
gato addandgato removeonly touchwa:*regions and generated files in the core.
Install and remove a module
- New project
- Existing project
- Remove
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.npm run wa -- add uploads runs the same command.
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.