flisk-recipe-shop

Recipe for "build me a small online shop" with Flisk - a storefront website and an orders API with a database in one stack, started with `flisk up` and checked URL by URL. Use with the flisk-build ski

SKILL.md

GitHub

Recipe: a small online shop

Parts: a storefront the user opens in the browser, and an orders API that stores products and orders.

Steps

flisk doctor
flisk project --yes
flisk resource storefront --type frontend --stack shop --yes
flisk resource orders-api --type backend --stack shop --feature drizzle --yes
flisk up shop --dry-run
flisk up shop --json &        # wait for {"ok":true}
flisk networks --stack shop --raw

App code

  • services/shop/orders-api/src/schema.ts: a products table and an orders table. Use src/db.ts for queries.
  • services/shop/orders-api/src/index.ts: GET /products, POST /orders, GET /orders. Keep /health and /health/db. Create the tables as the flisk-build skill says under "Tables"; seed three products if the table is empty.
  • services/shop/storefront/src/: a page that lists the products from the API and a button that places an order. Call the API through the generated client in .autogenerated/ (the api-client feature), not a hard-coded host.

Done when

Each of these answers 200 (ports come from flisk networks):

  • the storefront health URL, for example http://app.<project>.localhost:<port>/storefront/health
  • http://api.<project>.localhost:<port>/api/orders/health
  • http://api.<project>.localhost:<port>/api/orders/health/db

Then tell the user: "Your shop is running. Open the storefront at … . The orders API is at … ; try curl …/api/orders/products. Stop it with flisk down."