Getting started
Getting started
Two ways to start with crouton: create a new project from scratch, or add crouton to an existing one.
@ghentcdh/create-crouton
Scaffold a complete crouton project β a NestJS backend with Prisma, pre-configured datasource, Docker Compose, and optionally an Nx monorepo layout with a Vue frontend.
npm create @ghentcdh/crouton my-app
# or
npx @ghentcdh/create-crouton my-appLocal development
To test a locally built version of the CLI:
# Build and link globally
pnpm nx build create-crouton
pnpm link ./packages/create-crouton --global
# Now use it anywhere
create-crouton my-test-app --prefix splitOr run directly without linking:
pnpm nx build create-crouton
node packages/create-crouton/dist/index.js my-test-appFlags
| Flag | Default | Description |
|---|---|---|
--nx | prompt | Use Nx monorepo layout (backend + frontend + shared libs). |
--no-nx | β | Skip Nx layout (scaffold a regular single-app project). |
--no-frontend | β | Skip Vue frontend generation (Nx layout only). |
--no-postgres | β | Skip the PostgreSQL Docker service (use an external DB). |
--sample | β | Include a sample resource. |
--pm <manager> | prompt | Package manager: pnpm, npm, yarn, or bun. |
--no-install | β | Skip dependency installation. |
--no-git | β | Skip git init. |
--no-docker | β | Skip Docker files (Dockerfile, compose.yml). |
--prefix <name> | prompt | Subfolder prefix for apps/config (e.g. split). Implies Nx layout. |
--db-url <url> | prompt | Database connection URL. |
-y, --yes | β | Accept all defaults (non-interactive). |
--force | β | Overwrite existing files. |
Layouts
Regular (single app)
A standalone NestJS backend β best for APIs, small projects, or when you already have a separate frontend.
my-app/
βββ src/
β βββ main.ts
β βββ app.module.ts
β βββ data-sources/default/
β β βββ data-source.json
β β βββ index.ts
β βββ resources/ # generated by `crouton update resources`
βββ prisma/default/
β βββ schema.prisma
β βββ prisma.config.ts
βββ crouton.json
βββ crouton.enums.json
βββ package.json
βββ compose.yml
βββ .envNx monorepo
A full-stack workspace with separate backend and frontend apps, shared generated types, and workspace-level tooling.
my-app/
βββ apps/
β βββ backend/
β β βββ src/
β β β βββ main.ts
β β β βββ app/
β β β βββ app.module.ts
β β β βββ data-sources/default/
β β β βββ resources/
β β βββ package.json
β βββ frontend/ # Vue + Vite (skipped with --no-frontend)
β βββ src/
β β βββ main.ts
β β βββ App.vue
β βββ package.json
βββ generated/default/
β βββ types/ # crouton-prisma zod output
β βββ client/ # Prisma client output
βββ prisma/default/
βββ crouton.json
βββ nx.json
βββ pnpm-workspace.yaml
βββ package.jsonNx monorepo with prefix
When using --prefix split, apps and generated code live under a subfolder. This is useful when the Nx workspace also contains non-crouton projects.
my-app/
βββ split/
β βββ apps/
β β βββ backend/
β β βββ frontend/
β βββ generated/default/
β β βββ types/
β β βββ client/
β βββ prisma/default/
β βββ crouton.json
βββ nx.json
βββ tsconfig.base.json
βββ pnpm-workspace.yaml
βββ package.jsonWhat happens after scaffolding
The CLI runs these steps automatically (unless skipped via flags):
git initβ initialises a repository with an initial commit.<pm> installβ installs all dependencies.crouton update resourcesβ introspects the database and generates resource CRUD (best-effort; warns on failure if DB is not running).
Then follow the printed next-steps:
docker compose up -d # start postgres
pnpm prisma:migrate # create initial migration
crouton update resources # generate resource CRUD from your schema
pnpm dev # start dev serverWhen using a prefix, point the CLI at that project with --project:
crouton update resources --project split@ghentcdh/add-crouton
Not published yet
@ghentcdh/add-crouton is not on npm yet (see the roadmap). Until it is released, use the manual setup guide to add crouton to an existing project.
Add crouton to an existing NestJS project β regular or Nx. This command is additive: it never overwrites existing files. Once released, run it from the project root:
npx @ghentcdh/add-crouton
# or from outside the project:
npx @ghentcdh/add-crouton --cwd /path/to/projectFlags
| Flag | Default | Description |
|---|---|---|
--cwd <dir> | . | Project directory. |
--backend <app> | auto-detect | Backend app name (Nx only). |
--frontend <app> | auto-detect | Frontend app name (Nx only). |
--no-frontend | β | Skip frontend detection. |
--pm <manager> | auto-detect | Package manager. |
--no-install | β | Skip dependency installation. |
--no-docker | β | Skip Docker file generation. |
-y, --yes | β | Accept all defaults (non-interactive). |
What it does
- Detects project type β checks for
nx.jsonat or above the current directory to distinguish Nx workspaces from regular projects. - Discovers apps (Nx only) β scans
apps/subdirs, classifies them as backend (@nestjs/corein deps) or frontend (vue/vitein deps), and prompts which to use. - Detects package manager β from lockfile presence (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb).
- Scans dependencies β reports missing backend deps (
@ghentcdh/crouton-api,@ghentcdh/crouton-core,prisma, etc.). - Writes config files (if absent):
crouton.jsonβ with detectedresourcesDiranddataSourcesDircrouton.enums.jsonβ empty enum registrydata-sources/default/β default datasource with Prisma schema and config.env.exampleβ withDATABASE_URLplaceholder
- Installs dependencies β runs
<pm> installif missing deps were detected.
After running @ghentcdh/add-crouton, wire CroutonApiModule into your NestJS app module β see Backend setup.