Education › Forward Deployed › Stage 3: Building & integrating

Rapid prototyping and demos

From idea to clickable prototype in days with FastAPI and Streamlit, demo hygiene, and knowing when a prototype must become a product.

Intermediate ~40 min read Module 12 of 20

Customers believe what they can click. A working prototype on their own data, shown in the first two weeks, does more to align stakeholders than any number of slides, and it surfaces the real requirements faster than interviews alone. This lesson covers building such prototypes quickly with a FastAPI backend and a Streamlit front end, the demo hygiene that keeps them credible, how to iterate with users weekly, and the checklist for the moment a prototype has to become a product someone else can run.

After this module you can
  • Build a thin backend and UI prototype in days with FastAPI and Streamlit
  • Structure prototype code so it can evolve instead of being thrown away
  • Prepare demos with seeded data, safe configuration and a reset path
  • Run weekly user iterations and turn feedback into prioritised changes
  • Apply a prototype-to-production checklist before real users depend on it

A thin, evolvable architecture

Keep the prototype in two pieces even when it is tiny: a backend API that holds all logic, data access and model calls, and a thin UI that only calls the API. The UI can be thrown away or replaced by the customer's own front end later; the API, tested and documented, often survives into production. Avoid putting business logic in the UI script, which is the most common reason prototypes cannot evolve.

backend/app.py: the logic lives behind an API
python
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI(title="Clause assistant")


class Ask(BaseModel):
    question: str
    user_id: str


class Answer(BaseModel):
    answer: str
    sources: list[str]


@app.get("/health")
def health() -> dict:
    return {"ok": True}


@app.post("/ask", response_model=Answer)
def ask(req: Ask) -> Answer:
    result = rag.answer(req.question, groups_for(req.user_id))   # your logic module
    return Answer(**result)
ui/app.py: a thin Streamlit chat front end
python
import httpx
import streamlit as st

API = st.secrets.get("api_url", "http://localhost:8000")
st.title("Clause assistant (pilot)")

if "history" not in st.session_state:
    st.session_state.history = []
for role, text in st.session_state.history:
    st.chat_message(role).write(text)

if question := st.chat_input("Ask about a motor policy clause"):
    st.chat_message("user").write(question)
    r = httpx.post(f"{API}/ask", json={"question": question, "user_id": "demo"}, timeout=60)
    body = r.json()
    reply = body["answer"] + "\n\nSources: " + ", ".join(body["sources"])
    st.chat_message("assistant").write(reply)
    st.session_state.history += [("user", question), ("assistant", reply)]
Run both locally
bash
uv run uvicorn backend.app:app --reload --port 8000
uv run streamlit run ui/app.py

Speed without chaos

  • Timebox every prototype goal ("answer clause questions on 200 real policies by Friday") and cut features to hit it.
  • Real data early: a prototype on the customer's actual documents, even a sample, reveals problems no synthetic data will.
  • Fake what is not the point: stub the integrations you have not got access to yet behind the same interface the real one will use.
  • Keep the evaluation set running from the LLM apps lesson, so speed does not mean regressions.
  • Commit daily with short notes; a prototype that only exists on your laptop is a risk to the engagement.

Demo hygiene

A prototype is judged in demos, so make demos reliable and safe. Prepare a seeded demo dataset of approved, realistic cases that show the value, plus a few that show honest limitations. Add a reset command that restores the demo state in seconds. Run the demo environment separately from anything users depend on.

  • No secrets, tokens or internal URLs visible on screen; use configuration and screen-share a clean window.
  • No personal data in demo cases unless the customer has approved it for that audience.
  • Pre-warm caches and models so the first answer is not a 40-second cold start.
  • Keep a recorded backup of the exact flow and a static screenshot deck for total network failure.
  • Know your fallback line when something odd happens: "That is a good example of a case we route to a human; let me show you how."
Watch out

Never fake results in a demo with hard-coded answers presented as live. If something is mocked, say so. Discovered fakery ends engagements and reputations.

Iterating with users

Put the prototype in front of a few real users as early as it is useful, and run a weekly loop: watch them use it on real work, collect failures and requests, add failures to the evaluation set, prioritise, ship, repeat. Watching beats asking: users rarely report the moment they gave up and went back to the old way, but you will see it.

Prioritise feedback by frequency and impact on the success metric, not by who shouted loudest. Keep a visible list of what you will do this week, next, and not at all in this pilot; it doubles as expectation management.

From prototype to product

The moment real users depend on the prototype for real work, it is production, whatever it is called. Before that moment, close the gaps.

AreaPrototypeBefore real users rely on it
AuthDemo userCustomer SSO, roles mapped from groups
ConfigValues in codeEnvironment variables and secrets store
ErrorsStack tracesFriendly errors, retries, timeouts, alerts
DataLocal filesApproved storage, retention, access logs
QualitySpot checksEvaluation set run in CI, tests for core logic
OperationsYour laptopContainer, deployed in customer environment, monitored, runbook

Decide explicitly whether to evolve the prototype (clean architecture, tests, worth keeping) or rebuild a production version using what you learned (prototype was a spike, structure does not fit). Either is fine; drifting into production with demo code is not.

Hands-on practice

A two-day prototype, demo-ready

  1. Build the FastAPI backend with /health and /ask, backed by any simple logic (your RAG assistant from the previous lessons, or a stub).
  2. Build the Streamlit chat UI that only calls the API, with sources shown under each answer.
  3. Create a seeded demo dataset of ten cases (seven that show value, three that show limitations) and a reset script.
  4. Rehearse a 15-minute demo using the structure from the communication lesson and record a backup video.
  5. Ask two people to use it on realistic tasks while you watch silently; log every hesitation and failure.
  6. Go through the prototype-to-product table and write the list of changes needed before real users depend on it.
Cheat sheet

Rapid prototyping and demos — at a glance

Main things to focus on

  • Logic behind an API, thin UI on top: the API can survive into production.
  • Timebox, use real data early, stub what is not the point.
  • Seeded demo data, reset command, separate demo environment.
  • Never present mocked results as live.
  • Weekly loop with real users; watch, do not just ask.
  • Once users rely on it, it is production: close the gaps or rebuild.

FastAPI

app = FastAPI(title=...)Create the API
@app.post("/ask", response_model=Answer)Typed endpoint
class Ask(BaseModel): ...Validated request body
uvicorn backend.app:app --reloadRun with auto-reload
/docsInteractive OpenAPI docs for free

Streamlit

streamlit run ui/app.pyRun the UI
st.chat_input / st.chat_messageChat interface
st.session_stateKeep state across reruns
st.secretsConfiguration and secrets
@st.cache_resourceReuse expensive clients

Demo checklist

seeded data + reset scriptRepeatable demo state
pre-warmAvoid cold-start pauses
no secrets or PII on screenSafe screen-share
recorded backupFor network or dependency failure
separate demo environmentNever the one users depend on

Common pitfalls

  • Business logic inside the UI script, so nothing can be reused.
  • Prototyping on synthetic data and being surprised by the real documents.
  • Demoing in the same environment users depend on.
  • Hard-coded 'live' answers in a demo.
  • Letting a prototype become production by drift.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →