Skip to content

Generate your first module

StackRivet’s code generator doesn’t just write CRUD. From a single database table it generates a governed module: backend layers, frontend pages, the menu, permissions, OpenAPI annotations, a test scaffold, a module manifest and AI-readable module context — all of it respecting the architecture and security rules.

The generator lives inside the product (admin UI plus the /api/v1/generator API); you don’t run a separate tool.

  • Have the backend and admin UI running (see Installation).
  • Have a database table to generate from. The generator reads tables from MySQL 8.4 or PostgreSQL 18.4.
select a table → import metadata → configure fields → configure menu & permissions
→ preview → confirm → write code + manifest → run tests / start the app

Pick a table and import its metadata. The generator reads columns, types, primary key, indexes and comments.

GET /api/v1/generator/database-tables # browse available tables
POST /api/v1/generator/tables/import # import the selected table(s)

This creates the sr_gen_table and sr_gen_column config rows. Re-importing the same table prompts to merge or overwrite.

For each column, set how it appears in the list, the form, queries, validation, dictionary and control type. StackRivet applies sensible defaults from the column type:

DB typeJavaControl
varchar / textStringinput / textarea
integer / bigintInteger / Longnumber input
decimalBigDecimal (never double, for money)decimal input
boolean / tinyint(1)Booleanswitch
date / datetimeLocalDate / LocalDateTimedate / datetime picker
*_asset_idStringasset uploader (auto-detected)
*_dictStringselect

id, tenant_id, created_at, updated_at and deleted stay out of the normal form by default. Any field you mark as a query condition is run through an index-risk check — if no index covers it, the preview flags it.

The generator produces the menu entry plus menu, button and API permissions for the module, so it is locked down by default. (See Add a permission for the manifest details.)

The generator always previews before it writes. Each file is marked new, overwrite or skip — and it will not overwrite a file you have modified unless you explicitly confirm.

POST /api/v1/generator/tables/{id}/preview # see the file diff
POST /api/v1/generator/tables/{id}/apply # write after you confirm
AreaFiles
Backend{Name}Entity, {Name}Mapper, {Name}Service + Impl, {Name}Controller, Create/Update/Query DTOs, a Response VO
Frontend{resource}.api.ts, a list page and a form dialog/drawer
Governancemenu + button + API permission seed, OpenAPI annotations, a base test, module manifest, AI-readable module context

The generated backend compiles, the Controller never calls a Mapper directly, DTO/VO are not reused entities, list APIs paginate (max pageSize 200), and generated files carry template metadata and file hashes for the upgrade path.

  1. Run the generated tests and start the app.
  2. Open the module in the admin UI and exercise create / read / update / delete.
  3. Continue customizing — an AI tool can read the module context to extend it safely (see AI coding workflow).

Community generates single-table modules. Master-detail, tree and many-to-many generation, template editing and generated diff previews are Pro / Enterprise — see the pricing page.