Skip to Content
Potik Docs
Runbooks

Generate and customize a CRUD feature

Run the generator from the repository root with Python 3.10 or newer on a Unix-like system. Generate a named resource with a singular name and an explicit plural. Use lowercase letters and digits for these identifiers.

python3 tools/generators/starter.py add feature note --plural notes
task generate

The feature uses Projects as its reference. It adds a separate Go application module and PostgreSQL table, registers GraphQL queries and mutations, and wires a React Router list and detail page. The GraphQL API supports listing with cursors, reading one item, creating, renaming, and deleting. The application derives access from the existing identity and organization context. The SQL checks the same authorization scope for reads and writes.

Start the local stack with docker compose up --build. Open http://localhost:3000/notes, create a note, follow its detail link, rename it, and delete it. This stack uses demo data. With the identity profile, sign in before using the generated route. In multi-tenant mode, pass the selected organization in the route query, for example /notes?organization=42.

Review the new migration and SQL and customize the feature in the generated files. For a label change, edit the heading in apps/web/app/routes/notes.tsx. For a model change, update the migration or add a follow-up migration if the current one has already run, then update the SQL, Go service, GraphQL schema, and frontend operations. Regenerate the bindings when the SQL or GraphQL contract changes. Run go test ./... and npm --prefix apps/web run check before committing sources and generated bindings.

An identical rerun leaves existing output unchanged, including after code generation. If a generated source has been customized, the generator reports a conflict before writing any files. Continue editing that feature directly. Separate feature invocations can add more resources without rewriting the generated sources of earlier features.

Generate individual artifacts

python3 tools/generators/starter.py add module calendar
python3 tools/generators/starter.py add graphql-operation list-notes --document ./list-notes.graphql
python3 tools/generators/starter.py add migration index-note-names --up ./up.sql --down ./down.sql

The module command creates a Go package under backend/internal/modules. Supply a named GraphQL operation in the document file. The operation command writes it under apps/web/app/graphql for the existing frontend code generator. Supply raw SQL bodies for the migration command. It chooses the next Goose version and wraps the bodies in Up and Down sections without applying the migration.

The integration check generates a resource in an isolated checkout, compiles it, applies its migration, and checks the CRUD and access paths. Generated feature integration check

On this page