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.placerunscatalog.reservefor stock and prices. If any item is short, the order rolls back. - Record rules.
canCancelguardsorders.canceland setscan.cancelinorders.minefor the UI. - Config. Each entry builds
ctx.configfrom 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, andtasks. - 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 testuses PGlite.bun run test:pguses Docker Postgres and tests concurrent confirmations.