# Order by form or chat, price it once

Applied AI. Updated Nov 2026 by [Mangesh Kashid](https://eemky.xyz/index.md).

I rebuilt a Gradio pizza ordering prototype so you could choose from a menu or describe what you wanted in chat. Two AI flows help with recommendations or a draft, while the same Python pricing and validation rules handle both ways of ordering.

Figure: Menu recommendations assist the form and chat fills a draft before both reach server validation and pricing.

- Role: Full-stack development and AI integration
- Duration: Public repository: July 2026

## Test coverage

- 74: Documented backend tests
- 8: Graded edge cases covered

## What I kept from the prototype

I used the Stage 2 Gradio app as a reference and rewrote the business logic from the spec for Stage 3. I kept the original rules for validating and pricing orders. What changed was how you could build that order: by picking items in a SvelteKit form or by describing them in chat.

I put validation, pricing, and saving orders in FastAPI. Supabase provided Postgres and authentication. That split kept the browser focused on collecting choices and displaying results instead of carrying its own version of the order rules.

Figure: The Stage 2 Gradio prototype leads to a Stage 3 diagram with SvelteKit, FastAPI, and Supabase.

## A suggestion before the menu

The first AI flow helps when you want an idea but would rather place the order yourself. I pass in the current menu and a summary of past orders when available. The response has three fields: one pizza, one topping, and a short reason. The form displays the recommendation while you still make the selections.

I used pydantic-ai with OpenRouter for the structured response, then checked the returned names against the menu. If the model returns an off-menu item, or if the model call fails, the backend uses a default recommendation instead.

Figure: The current menu and available order history feed a recommendation for a pizza and topping with a reason.

## A conversation that fills a draft

I built the second flow around an order draft rather than treating the chat transcript as the order. The model gets the current menu and returns a reply plus the fields it has collected. I asked it to offer a menu choice when the request is vague and ask for one missing required field at a time. The draft panel shows what has been filled in.

The backend checks that the required fields are present before accepting the model's completion flag. That flag only lets the chat client attempt an order. The draft still goes through the regular order endpoint.

Figure: A chat turn produces a reply and a draft whose required fields are checked before submission.

## One place to calculate the bill

I made FastAPI look up menu prices from the submitted item IDs. The browser sends the selection and quantity for pricing, not a total. Form and chat use the same order endpoint, and the form's quote and the order submission use the same selection validation and price calculation.

The reference bill test pins the discount and GST rules to a known result. Five pizzas qualify for the discount, then GST is calculated on the discounted subtotal. The receipt uses test data, not live menu prices.

Figure: Change the quantity from 1 to 10 to recalculate the receipt. Three items cost ₹677 per pizza, and the reference bill for five pizzas totals ₹3,594.87.

## Checkout without real sales

I kept checkout in test mode. The card path can use Stripe test mode when configured and otherwise returns a simulated result. UPI is simulated, and cash stays pending as a cash-on-delivery choice. The point was to exercise what happens to an order after a payment result, without processing real sales.

A failed payment is returned before the order is saved. A test order that does get saved can carry a payment status, but that status is part of the ordering exercise. It isn't a record of money collected.

Figure: Three payment choices lead to test or simulated outcomes, with cash marked pending.

## What I tested

I tested the sample bill and cases like zero or eleven pizzas and invalid menu prices. I also checked order submission, test payments, admin access, CSV exports, and seeded data.

The API integration tests use in-memory SQLite. For the AI tests, I used pydantic-ai's TestModel rather than calling OpenRouter. Those tests check the API response shapes and behavior when AI is disabled. They don't measure how often a live model gets an order right.

Figure: The documented suite has 74 backend tests and covers eight graded edge cases and the reference bill.

## What I built and what I planned

I built the form, chat, and an admin view with order filters and CSV export. The design notes outline a Vercel layout for the two frameworks. The deployment guide recommends separate projects for SvelteKit and FastAPI so each framework can be detected on its own.

The hosting layout is a plan in the docs, not a live storefront.

Figure: The diagram separates the implemented form, chat and admin view from documented hosting plans.

- [SliceMatic repository](https://github.com/LEO2822/Slicematic)
- [README: features, rules, and tests](https://github.com/LEO2822/Slicematic/blob/eae759a48a2b5e64bffae9230974d1ca14d2a06c/README.md)
- [Stage 3 design notes](https://github.com/LEO2822/Slicematic/blob/eae759a48a2b5e64bffae9230974d1ca14d2a06c/docs/stage-3-design.md)
- [Backend tests](https://github.com/LEO2822/Slicematic/tree/eae759a48a2b5e64bffae9230974d1ca14d2a06c/backend/tests)
- [Reference bill regression](https://github.com/LEO2822/Slicematic/blob/eae759a48a2b5e64bffae9230974d1ca14d2a06c/backend/tests/test_domain.py)
- [Deployment guide](https://github.com/LEO2822/Slicematic/blob/eae759a48a2b5e64bffae9230974d1ca14d2a06c/docs/deployment.md)

Page: https://eemky.xyz/slicematic
