Scaffold the storefront
In this chapter you create my-shop/ with the netscript CLI, tour what it generated, and bring it
up under Aspire: Postgres, the Redis cache and an example service running
together behind one dashboard.
- 1 · Scaffold
- 2 · Catalog service
- 3 · Cart contracts
- 4 · Checkout saga
- 5 · Shipping webhook
- 6 · Storefront UI
- 7 · Deploy
What you will build
A NetScript workspace named my-shop/ with a shared contracts/ workspace, a products service, a
Fresh app and a Postgres database. At the end it boots under one aspire start, the Aspire dashboard
is live at the URL Aspire prints, and Postgres and Redis report healthy.
Before you begin
You need a working local toolchain:
- Deno 2.x on your
PATH. Check withdeno --version. - The Aspire CLI. Check with
aspire --version. NetScript uses Aspire to provision your database and cache locally, so you never wire up Docker containers by hand. - Docker running, so Aspire can start the Postgres and Redis containers.
docker infoprints engine details, not a connection error.
Install the NetScript CLI from JSR:
deno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@0.0.9
--minimum-dependency-age=0 lets the pinned release install on its publication day, and use --force when replacing an older global executable. Confirm it resolves:
netscript --help
The public command groups are agent, config, contract, db, deploy, generate, init, marketplace, plugin, service, tokens, ui:add, ui:init, ui:list, ui:remove and ui:update. If netscript is not found, add Deno's install directory to your PATH and open a new terminal.
Step 1 — Preview the scaffold with a dry run
--dry-run plans the scaffold and prints the result without writing to disk:
netscript init my-shop --dry-run
netscript init validates your options, then runs an ordered pipeline: the project root, Aspire
orchestration, the shared contracts workspace, a Fresh app, an empty plugin registry, and, when you
ask for them, a database workspace and an example service. The dry run reports file and directory
totals per phase. A clean dry run means you can scaffold for real.
Step 2 — Create the workspace
Scaffold my-shop/ with an example service named products at its allocated endpoint and a Postgres
database, which holds the catalog you build in the next chapter:
netscript init my-shop --service --service-name products --db postgres
cd my-shop
The CLI scaffolds my-shop/, formats the output with deno fmt, initializes a git repository, and
prints a next steps summary for your options. The steps below follow the same path.
This track uses Postgres. You can swap --db postgres for mysql, mssql or sqlite and the
scaffold wires Prisma for that engine instead; SQLite is file-backed, with no Aspire container. Keep
--db postgres to follow along. Run netscript init --help for every option; these are the common
ones:
| Name · Type | Description |
|---|---|
--service --service-name <name> --service-port <port>flag group |
Include an example oRPC service at the endpoint Aspire reports. |
--db <engine>flag |
Scaffold a Prisma-backed database workspace. First-class engines: postgres (default for this track), mysql, mssql, sqlite. Omit or use --db none to skip database tooling. |
--no-aspireflag |
Skip the Aspire orchestration files — you would then wire infrastructure yourself. Do NOT pass this for the track; we rely on aspire start. |
--editor <none|zed|vscode>flag |
Generate editor settings for the chosen editor. |
--dry-runflag |
Plan the scaffold and print totals without writing any files. |
Step 3 — Tour what you got
my-shop/ has this shape:
- my-shop/
- apps/dashboard/ # Fresh frontend (defineFreshApp)
- contracts/ # Shared oRPC contracts, versioned under versions/v1/
- services/products/ # The example oRPC service (src/main.ts, router.ts, routers/)
- plugins/ # Plugin registry + manifests — empty until chapter 4
- database/ # Postgres workspace (Prisma schema + migrations) — initialize before editing
- tests/ # Workspace-level test suite scaffolded alongside the project
- aspire/
- apphost.mts # Entry point for aspire start
- aspire.config.json # AppHost language + SDK pin
- appsettings.json # Infrastructure config (Services / Databases / Persistent)
- deno.json # Workspace root (members, tasks, dependency catalog)
- netscript.config.ts # Framework config (defineConfig)
What each piece is for:
contracts/— the typed seam between your services and any client: oRPC + Zod contracts, versioned underversions/v1/. Everything else takes its types from here. You add the cart contract in chapter 3. See Contracts & type flow.services/products/— a working oRPC service.src/main.tscallsdefineService(...)and handlers live undersrc/routers/. You read it as a typed catalog in chapter 2.apps/dashboard/— a Fresh app wired to consume contracts, powered by the@netscript/freshmeta-framework. You add the storefront page in chapter 6.plugins/— where background capabilities (workers, sagas, triggers, streams) register. Empty until chapter 4.database/— the Postgres database workspace: the Prisma schema and migrations behindcontext.dbin your handlers. You initialize it in Step 4.tests/— the workspace-level test suite. Extend it as you add handlers and contracts.aspire/— the orchestrator.aspire startreadsapphost.mtsand starts every resource your app declares: Postgres, the Redis cache and your services.appsettings.json— the infrastructure manifest Aspire reads: which services, databases and persistent resources to provision.netscript.config.ts— declares paths, plugins, logging and database wiring withdefineConfig. See the config reference.
Step 4 — Bring up orchestration
Aspire provisions your database and cache; you don't start containers by hand, and you start Aspire
before any netscript db command. Run it from the aspire/ folder so the CLI finds apphost.mts:
cd aspire
aspire restore # once per machine: restores the Aspire SDK modules into .aspire/
deno task aspire:start # starts the AppHost and every declared resource
deno task aspire:start is the wrapper the CLI's printed next steps recommend: it sets a 300-second
cold-start budget while container images download on the first run. It brings up Postgres, the Redis
cache and your products service, then prints the allocated URL for the Aspire
dashboard.
In an interactive terminal, leave it running: it is your storefront's control plane for the rest of
the track. Aspire assigns free ports at runtime, so take the dashboard and app URLs from the
dashboard (or MCP list_api_services) instead of memorizing them.
Initialize the database before customising
The Postgres container exists only while aspire start is running. Open a second terminal at the
my-shop/ project root and run:
netscript db init --name init
netscript db generate
netscript db seed
db init creates and applies the initial migration, db generate produces the Prisma client and
the @database/zod schemas, and db seed runs the generated seed script. The CLI runs each command
as a database-operation resource inside the running graph, so it uses the existing Postgres
connection and never provisions a second container over the same data directory. A successful run
proves the resource graph, connection string, Prisma schema and migration path agree before chapter 2
adds catalog behavior.
Verify your progress
In the second terminal, with aspire start still running in the first, check that the example
products service answers at its allocated endpoint:
curl "$SERVICE_URL/health"
You get a healthy JSON response. Services answer over plaintext HTTP/1.1; HTTP/2 is opt-in and needs TLS. Then type-check the workspace from the project root:
deno task check
A clean check and a healthy curl mean the scaffold is sound. Don't start customizing until every
box below is ticked: on an unverified base, every later failure looks like a bug in your code.
- [ ]
netscript --helplists the public command groups (agent,config,contract,db,deploy,generate,init,marketplace,plugin,service,ui:*). - [ ]
my-shop/exists withcontracts/,services/products/,database/,plugins/,aspire/, andtests/. - [ ]
aspire startis up; its printed dashboard URL (or MCPlist_api_services) showsproducts,postgres, andredishealthy. - [ ]
netscript db init --name initsucceeded and the initial migration exists. - [ ]
curl "$SERVICE_URL/health"returns healthy JSON. - [ ] Opening the Fresh app URL from the dashboard (or MCP status) with
/designappended renders the generated design reference (it returns an HTTP 302 redirect to/design/composition, so scripted checks requirecurl -L). - [ ]
deno task checkpasses with no errors.
What you built
A NetScript workspace, my-shop/: a shared contracts/ workspace, a products service, a Fresh
app, and a Postgres database plus Redis cache, all orchestrated by Aspire and visible in one
dashboard. Next, you read the products service as a typed catalog and give it a typed 404.