Skip to content

Runnable Examples ​

About 3 min read

Runnable examples show how routes, feature code, and a database work together. Choose the application closest to yours, run it locally, and follow a request from the UI to the stored result.

Choose an example ​

ApplicationUse it to studySource and setup
Customer order portalServer-rendered pages and forms using native Next.js queries and Server Actions.Native Next.js
Fulfillment dashboardA polling queue using React Query, Eden Fetch, and a separate backend built with Elysia in a Turborepo workspace.React Query + HTTP
B2B orderingTyped operations shared by a browser and a command-line client.React Query + oRPC

Start with the customer portal for pages and forms. Use the dashboard when your browser needs ongoing updates from an HTTP service, or B2B ordering when you want to share a typed API across clients. The data-fetching guide explains these choices.

The dashboard keeps Next.js in apps/web, Elysia in apps/api, and shared schemas in packages/contracts. Eden Fetch checks requests against the Elysia route types while React Query manages polling and cached results. Turborepo coordinates the workspace tasks. Browser mutations pass through Next.js so it can invalidate its server caches before responding.

Run it locally ​

Open the selected example's README for setup commands and demo accounts. You'll need Bun 1.4.0, Docker Compose, and Node.js 22 or later for test tools. Install dependencies inside that example; the root installation only covers the documentation site.

Each application has its own PostgreSQL database, ports, and tests. Shipping is simulated, so you don't need external credentials or payment setup. The examples omit public registration, email delivery, and production hosting.

Follow one request ​

Each application keeps routes in app, business rules in features, integration setup in platform, and generic code in shared. See the folder structure guide for the dependency rules.

Pick one workflow to trace:

  • Customer portal: follow checkout.actions.ts into create-order.use-case.ts. The server reads product prices and stores the order.
  • Fulfillment dashboard: start with apps/web/src/features/fulfillment/fulfillment.api.ts, then open apps/api/src/features/fulfillment. The backend checks the operator's warehouse before changing a shipment.
  • B2B ordering: follow order.rpc.ts into decide-order.use-case.ts. The use case checks company membership, approver permissions, and order status.

To follow shared authorization, open the customer portal's order queries. List, detail, and delivery reads share one file and use withMembership from the membership query module. The membership wrapper example explains how that check stays with each operation.

Change a rule in its owning feature, then run that example's checks. Each README includes the test commands and a way to observe cache reads after a write. For the reasoning behind those checks, read resource protection and caching.

Code: MIT · Writing, diagrams, and visual assets: CC BY 4.0