Skip to content
Public template

About

Build your own online store with your agent: a Next.js ecommerce template with a cart, Stripe Checkout, shipping, customer accounts and an agent API, deployed on floo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Build your own online store with your agent

A Next.js ecommerce store you own and your agent can change: a product catalog, a cart, Stripe Checkout with shipping and tax, customer accounts with order history, and an API your agents use to run fulfillment. Paste one prompt into Claude Code, Codex or Cursor and it deploys on floo with Postgres, photo storage and sign-in. Your only setup is a Stripe key.

The walkthrough, with every step tested end to end: How to build your own online store with your agent.

The shop page of the storefront template

What you get

  • Catalog and cart. Products with prices and stock in managed Postgres. The cart lives on the server, keyed by a cookie, and never holds more than is in stock.
  • Stripe Checkout. Stripe hosts the payment page, so card numbers never reach your app or floo. Prices come from your database, so you create nothing in Stripe but an account. Stripe collects the shipping address and emails the receipt.
  • Shipping and tax. Shoppers pick Standard or Express at checkout, and Standard is free over $50; change the rates in lib/store.ts. Turn on COLLECT_TAX there and Stripe Tax adds sales tax, VAT or GST for the shopper's address. The order records the method, shipping cost, tax and amount charged.
  • Orders that add up. An order is paid only when Stripe's signed webhook says the money arrived. Stock goes down and the cart empties in the same transaction, and a retried webhook changes nothing. Delayed payment methods, such as bank debits, are recorded when they clear.
  • Customer accounts. Shoppers sign up with email and password, confirm a code floo emails, and see their orders at /orders. floo runs the sign-in and keeps users in your database. Guests can check out too.
  • Product photos. Your agent uploads a product's photo through the API; floo stores it in a private bucket per environment and the store serves it with a year-long cache. No image files in Git, no redeploy.
  • Found by search. Each product page has its own title, description and link-preview tags, and /sitemap.xml lists every product as it is added.
  • Owner page. /admin, behind floo sign-in for you and the people you invite: ship orders, add products, upload photos, change prices and stock. No agent or terminal needed.
  • Agent API. List paid orders, mark them fulfilled, add products, upload their photos, and change prices and stock, with an app API key and a generated OpenAPI document.

Deploy with your agent

Paste this into Claude Code, Codex or Cursor:

Deploy the template at https://github.com/getfloo/storefront-template on floo for me.
Follow https://getfloo.com/agents.md to create a floo-hosted project, replace its
starter code with this template's files (keep the project's [app] name in
floo.app.toml), push, and give me the live URL. The deploy stops on
STRIPE_SECRET_KEY: have me set it with `floo env set STRIPE_SECRET_KEY --stdin`
as the README says, never paste it to you.

Or click Use this template on GitHub, then:

curl -fsSL https://getfloo.com/install.sh | bash
floo auth login
git clone https://github.com/<you>/<your-repo>.git
cd <your-repo>
floo deploy

Connect Stripe

Dev uses Stripe test mode; prod uses live mode. Each environment holds its own key.

  1. In the Stripe Dashboard, in test mode, copy the secret key, set it on dev, and redeploy:
    floo env set STRIPE_SECRET_KEY --stdin
    floo deploy --rebuild
  2. Nothing to do for webhooks. Each deploy creates or updates one Stripe webhook endpoint for the environment's URL, with the events and API version the store reads, and keeps its signing secret in the database (scripts/stripe-webhook.ts). A custom domain is picked up on the next deploy. A restricted key needs write access to Webhook Endpoints. If you added a webhook endpoint by hand before, delete it: it signs with a secret the store no longer uses.
  3. Dev already has six sample products: outside prod, each deploy adds them while the catalog is empty (scripts/samples.ts). Prod starts empty.
  4. Buy something with Stripe's test card 4242 4242 4242 4242, any future date and any CVC.

To collect tax, set up Stripe Tax in the Dashboard (your business address and where you are registered), in test mode and again in live mode, then set COLLECT_TAX = true in lib/store.ts and push. Until Stripe Tax is set up, Checkout refuses to open with it on.

To go live, repeat step 1 in Stripe's live mode with --env prod, then release: gh release create v1 for your GitHub repository, or floo promote for a floo-hosted project.

Run the store

Open /admin on the store. floo signs you in, and you get the orders to ship, with each shipping address, and every product, where you change the name, price, stock and photo, take a product out of the shop, or add one. It is open to the app's members: you, and anyone you invite with floo apps invite. Shoppers never see it.

With an agent

Mint an app API key with the api scope and hand it to your fulfillment agent:

floo apps consumers create fulfillment-agent
floo apps keys create fulfillment-key --consumer fulfillment-agent --scope api
Method Path What
GET /api/orders?status=paid Orders ready to ship, with items, shipping address and method
GET /api/orders/{id} One order
POST /api/orders/{id}/fulfill Mark a paid order shipped
GET /api/products Every product, including ones taken out of the shop
POST /api/products Add a product
PATCH /api/products/{id} Change price, stock, details, or active
PUT /api/products/{id}/image Upload the product's photo: {"contentType": "image/jpeg", "data": "<base64>"}, JPEG, PNG, WebP or AVIF up to 5 MB
GET /api/openapi.json The OpenAPI document

Customize

Ask your agent for changes like these:

  • "Take a tracking number when an order is fulfilled and show it on the customer's orders page."
  • "Add product categories and a filter on the shop page."
  • "Add a low-stock cron job that lists products with fewer than five left."
  • "Add a second photo to each product and show them as a gallery on the product page."

AGENTS.md tells the agent how the store is put together and which rules to keep.

Private dev

[[routes]] in floo.app.toml applies to every environment, so dev is public like prod, with Stripe in test mode. Stripe sends webhooks without a floo sign-in, so an environment behind floo's team sign-in never receives them. Your machine and preview environments get no Stripe webhooks either: only dev and prod have an endpoint. tests/webhook.test.ts signs events with a test secret, so webhook handling is tested without Stripe.

Building on it

The template is a starting point. Discount codes, order emails, more currencies, carrier rates, reserved stock: ask your agent and it builds them on top. A few facts it needs when it does:

  • Stock is checked at checkout but not held while the shopper pays, so two shoppers can buy the last unit. Both orders are recorded, stock stops at zero, and both appear in /api/orders?status=paid.
  • Currency, shipping rates and the tax switch live in lib/store.ts.
  • Stripe's receipt is the buyer's confirmation; the store sends no email of its own.

Local development

npm install
npm test        # route types, typecheck, lint and tests; no database or Stripe account needed
floo dev        # migrations and the app against your dev database

floo dev withholds the storage bucket's secret key, so uploaded photos load only on the deployed store; the sample photos in public/products/ load everywhere.


Built on floo.

About

Build your own online store with your agent: a Next.js ecommerce template with a cart, Stripe Checkout, shipping, customer accounts and an agent API, deployed on floo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages