Product Slices
A Product Slice is the ownership and deployment boundary for one product. It is a single package of 32 files that holds the web app, the API handlers, the data layer and the infrastructure for that product.
Anatomy
| Directory | Contents |
|---|---|
web/ | A Next.js App Router app: layout, home page, sign-in page, a page test and thin API routes. |
api/ | Lambda handlers: health.ts and protected.ts. |
data/ | DynamoDB-first persistence: key-value.ts, records.ts and persistence.json. |
contracts/ | The one entry point other projects may import. |
infra/ | The Slice’s infrastructure, written against shared builders. |
| Root files | package.json, project.json, sst.config.ts, TypeScript and Vitest configuration, the ownership record and a README.md. |
Slice files lists every file and says which ones are yours to edit.
Targets
Every Slice has the same 12 targets: build, lint, typecheck, test, verify, dev, dev-cleanup, deploy, refresh, remove, unlock, foundation-preflight. The first five check your code. dev runs the Slice locally, and dev-cleanup removes the development task stack it used. The rest operate its deployment. See Targets.
Choosing the boundary
Create a Slice when a capability has its own data, its own interface and its own release rhythm. Keep closely related features in one Slice when splitting them would only add remote calls. The framework gives you the mechanism for a boundary; where the boundary goes is a product decision.
A Slice can grow without becoming a second Slice. Add a Function, a Service or a Job inside it when a feature needs a different way of running. See Add a Function, Service or Job.
Continue building