Stage 3 of the AiNa pipeline · 2026-11-30 · inputs: 01 Braindoc, 02 SOW
Name
PhoneBazaar Android Store
Elevator pitch
PhoneBazaar is a small online shop that sells only Android phones, built around fast spec filters and side-by-side compare. It is for UK shoppers choosing their next phone and for a single seller who wants a clean store without a platform subscription.
Chosen variant
tier_lean
Tech stack (one-line)
FastAPI 0.115 (Python 3.12) · Jinja2 + HTMX, AiNa design system · SQLite (seeded at startup, /tmp on Vercel) · Vercel serverless at phonebazaar.tehchand.com
Domain architecture
Three bounded areas inside one FastAPI app:
| Area | Responsibility | Pages |
|---|---|---|
| Storefront | Catalog, search, filters, detail, compare | /, /phones, /phones/{slug}, /compare |
| Ordering | Session cart, demo checkout, order records | /cart, /checkout, /orders/{number} |
| Back office | Admin login, phone CRUD, stock, orders | /admin/* |
Cross-cutting: /docs (pipeline documents), /roadmap, /healthz.
Layout decision. The storefront gets a shopper-facing top-bar layout (store_base.html); the admin keeps the starter's sidebar shell (base.html). Both use the same app.css tokens and component classes, so there is still one design system. The accent colour is overridden to Android green (--accent: #0f9d58).
Features
- Home page [P0]
- what: Hero, featured phones, shop-by-brand chips, price-band shortcuts.
- acceptance:
/returns 200 and shows at least 4 featured phones and every brand in the catalog as a link to/phones?brand=<brand>. -
depends on: Phone ·
GET /· home -
Catalog with filters [P0]
- what: Grid of phone cards filterable by brand (multi), max price, min RAM, min storage, 5G only, free-text search, and sortable.
- acceptance:
/phones?brand=Samsungreturns only Samsung phones;max_price=300excludes phones above £300; an HTMX request (HX-Request: true) returns only the results partial; an empty result shows a friendly empty state with a "clear filters" link. -
depends on: Phone ·
GET /phones· catalog -
Phone detail [P0]
- what: Spec sheet (display, refresh rate, chipset, RAM, storage, main camera, battery, Android version, 5G, release year), price, stock status, add-to-cart and compare buttons.
- acceptance:
/phones/{slug}shows all spec fields; unknown slug returns 404; out-of-stock phones disable add-to-cart. -
depends on: Phone ·
GET /phones/{slug}· detail -
Compare (up to 3) [P0]
- what: Toggle phones into a compare tray;
/compareshows a spec table with the best value per numeric row highlighted. - acceptance: adding a 4th phone replaces none and shows "compare holds 3 phones"; the table highlights highest RAM/storage/battery/camera and lowest price.
-
depends on: Phone, session ·
POST /compare/{id},GET /compare· compare -
Cart [P0]
- what: Session cart with add, quantity update (1-5), remove, subtotal; header badge shows item count.
- acceptance: adding the same phone twice increments quantity; quantity is capped by stock and by 5; subtotal equals Σ(price × qty).
-
depends on: Phone, session ·
POST /cart/add,POST /cart/update,POST /cart/remove,GET /cart· cart -
Demo checkout [P0]
- what: Name, email, address, postcode form; creates an Order with items, decrements stock, clears cart, redirects to confirmation.
- acceptance: invalid email or empty fields re-render the form with errors; a valid submit creates order
PB-XXXXXX; the confirmation page and checkout page both show "Demo store: no payment is taken". -
depends on: Order, OrderItem, Phone ·
GET/POST /checkout,GET /orders/{number}· checkout, confirmation -
Admin login [P0]
- what: Single password (env
ADMIN_PASSWORD), constant-time compare, signed session flag. - acceptance: any
/admin/*page redirects to/admin/loginwhen not logged in; a wrong password shows an error; logout clears the flag. -
depends on: session ·
GET/POST /admin/login,POST /admin/logout -
Admin phones [P0]
- what: Table of all phones with price, stock and active flag; create and edit form; hide/show toggle.
- acceptance: a new phone appears in
/phonesimmediately; a hidden phone disappears from the storefront but stays in admin. -
depends on: Phone ·
/admin/phones*· admin -
Admin orders [P0]
- what: Orders list with status, totals and items; "mark shipped".
- acceptance: a demo order placed by a shopper appears at the top of
/admin/orders; marking shipped changes its badge. -
depends on: Order, OrderItem ·
/admin/orders*· admin -
Admin dashboard [P1]
- what: Stat tiles (orders today, revenue (demo), low-stock phones, catalog size).
- acceptance: tiles reflect current DB counts.
-
depends on: Phone, Order ·
GET /admin -
Docs & roadmap [P0]
- what:
/docslists every pipeline document with a formatted HTML version;/roadmapshows done/in-progress/planned. -
acceptance: each
docs/*.mdhas a matching/docs/<slug>.htmlreturning 200. -
Stripe payments [P2] · Customer accounts [P2] · Reviews [P2]
Data model summary
| Entity | Purpose | Key fields |
|---|---|---|
| Phone | A sellable Android model | id, slug, brand, model, price_pence, ram_gb, storage_gb, screen_in, refresh_hz, chipset, camera_mp, battery_mah, android_ver, is_5g, release_year, colour, stock, active, blurb |
| Order | A demo order | id, number (PB-XXXXXX), name, email, address, postcode, total_pence, status (new/shipped), created_at |
| OrderItem | Line on an order | id, order_id, phone_id, model_snapshot, unit_pence, qty |
| Session (cookie) | Cart and compare tray, admin flag | cart: {phone_id: qty}, compare: [id,…], admin: bool |
Money is stored as integer pence; formatting to £1,299.00 happens in a Jinja filter.
API contract summary
Server-rendered HTML routes; HTMX endpoints return partials.
- Storefront:
GET /,GET /phones,GET /phones/{slug},GET /compare,POST /compare/{id},POST /compare/clear - Ordering:
GET /cart,POST /cart/add,POST /cart/update,POST /cart/remove,GET /checkout,POST /checkout,GET /orders/{number} - Admin:
GET/POST /admin/login,POST /admin/logout,GET /admin,GET /admin/phones,GET /admin/phones/new,POST /admin/phones,GET /admin/phones/{id},POST /admin/phones/{id},POST /admin/phones/{id}/toggle,GET /admin/orders,POST /admin/orders/{id}/ship - System:
GET /healthz,GET /docs,GET /docs/{slug},GET /docs/{slug}.html,GET /roadmap,GET /api/phones(JSON catalog, read-only)
UX composition
- Header (store): logo, search box, "Phones", "Compare (n)", "Cart (n)" links. Sticky on mobile.
- Phone card: generated device illustration in the phone's colour (inline SVG, no photos), brand, model, 3 spec chips (RAM / storage / battery), price, "Add" and "Compare" buttons.
- Catalog: filter panel on the left (collapses above results under 860px), results grid 2 → 4 columns; filters submit through HTMX with
hx-push-urlso URLs are shareable. - Demo banner: amber strip on cart, checkout and confirmation pages.
- Admin: starter sidebar shell, tables and forms using existing
.table,.input,.field,.btnclasses.
NFR highlights
- Performance: catalog page < 100 KB HTML+CSS, no JS framework, Time-to-first-byte < 400 ms warm on Vercel.
- Security: admin behind
ADMIN_PASSWORD+SESSION_SECRETenv vars,hmac.compare_digest,HttpOnly/SameSite=Lax/Securesession cookie; all user input escaped by Jinja autoescape; SQL via parameterised queries only. - Accessibility: semantic forms with labels, focus styles, contrast AA, works without JS (HTMX enhances progressively).
- Privacy: checkout data used only to display the order; demo storage is ephemeral; privacy note in footer.
- Resilience: if
/tmpDB is missing, the app re-creates and re-seeds it on the next request.
Open questions
- Launch currency: GBP assumed (default accepted).
- Real product photos: generated illustrations assumed (default accepted).
- Admin password delivery: generated, stored in the operator's private
keys.mdasPHONEBAZAAR_ADMIN_PASSWORD, set on Vercel asADMIN_PASSWORD.
What's NOT in V1 (deliberate)
- Payments of any kind (demo checkout only).
- Persistent order storage (orders may reset on serverless cold start).
- Customer accounts and email notifications.
- Accessories, refurbished phones, trade-ins.
- Product images from manufacturers.