Skip to content
Logic SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Examples

Run the shop and bookings apps from the repository.

The repository contains two apps that use Logic SDK and Postgres.

1. Run the shop

From the repository root, run these commands. Starting the database needs Docker.

bun install
cd examples/shop
bun run db
bun run db:migrate
bun run dev

Open http://localhost:3000/products. The response lists the catalog.

  • Transactions. orders.place runs catalog.reserve for stock and prices. If any item is short, the order rolls back.
  • Record rules. canCancel guards orders.cancel and sets can.cancel in orders.mine for the UI.
  • Config. Each entry builds ctx.config from its environment.
  • Platforms. Node and Workers share the Hono API. Next.js uses Server Actions and gives two functions to an AI assistant.
Command Result
bun run dev:worker The API on Workers at http://localhost:8787.
bun run dev:next The Next.js app at http://localhost:3200. Set ANTHROPIC_API_KEY to use the assistant.
bun run test Tests with PGlite and workerd. Docker is optional for this command.

2. Run the bookings app

Stop the shop server to free port 3000. From the repository root, run these commands.

cd examples/bookings
bun run db
bun run db:migrate
bun run dev

The Hono server serves HTTP and oRPC at http://localhost:3000.

  • Modules. The app has properties, availability, pricing, enquiries, bookings, and tasks.
  • Payments. The checkout action refunds the charge if confirmation fails.
  • Events. A listener emails guests in their locale after commit.
  • Concurrent bookings. An advisory lock and a Postgres exclusion constraint prevent overlapping holds.
  • Tests. bun run test uses PGlite. bun run test:pg uses Docker Postgres and tests concurrent confirmations.

See also

Was this page helpful?