How to design a prompt playground (frontend)
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
- The problem
- Clarifying questions
- The requirements menu
- Non-functional requirements
- Core entities
- The API
- The high-level design
- What breaks first
- The deep dives
- Entity fields
- One setup, many controls, one run
- Saving, sharing and loading presets
- Two people editing one preset
- Comparing runs side by side
- Variants
- What each level is expected to show
- The 30-second answer
- Quiz
The problem
A prompt playground is a form with many controls that feed one request: pick a model, set its parameters, write a prompt, run it and watch the output stream in, then save the setup as a preset a teammate can load. The answer turns on holding the whole setup in one place. Then a run sends a copy taken at the instant run was pressed, a preset loads with a single write, a model switch can check each value against the new limits, and a save can say which version it started from so two teammates don't overwrite each other.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
Which parameters does a setup hold, and are they the same for each model? | The count sizes the setup object and the preset, and whether limits differ per model decides whether a model switch can leave values out of range. | Say 8: model, temperature, max output tokens, top p, penalties, stop sequences, system prompt and response format. Limits differ per model: one allows up to 16,384 output tokens and others allow fewer, and |
Does the output arrive whole or as a stream, and how long does a run take? | A stream turns a run from a request into a long-lived piece of state with its own stop button, and the duration says how long editing and running overlap. | A stream of events. The first output should show within 2 seconds and a run keeps streaming for about 20, so people will edit while one is running. |
Who can see a preset, and can two people change the same one? | Private presets can live anywhere. Shared ones need a server, an owner and a rule for two saves that land on the same preset. | Shared with teammates, and two people can open the same preset. Live co-editing isn't required. |
Does the browser call the model provider directly? | If it did, the page would need provider credentials or a delegated sign-in of its own, and streaming, cancel and run records would have to be rebuilt per provider. | No. The browser talks to our server, which holds the keys and runs the models. How the server runs them is not part of this round. |
How many columns can a compare hold, and does each have its own model? | It sizes the number of streams open at once and how much state each column carries. | No maximum is given. Assume a few columns, each with its own model and parameters, all started from one press of run. |
Do past runs need to be kept, and with what? | Comparing later and repeating a run need the setup that produced each output, not just the text. | Yes. A run keeps the setup it used, its output, how many tokens it used and how long the first output took. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
A change to any control answers within 200 milliseconds | A control edit writes to local state and paints in the same frame, with no server round trip in the handler. Interaction to Next Paint measures this from the click, tap or key press to the next frame, and 200 milliseconds or less is the good threshold. So stream rendering for a run has to be batched, or chunks arriving several times a second compete with the slider for the main thread. |
A run can be repeated: the exact setup it used is kept with it | The run takes a deep copy of the setup when run is pressed and stores it in the run record, next to the output and metrics. Edits made during the 20 seconds of streaming change the setup on screen, not the record. |
Unsaved changes are kept, and the page warns before leaving when the browser allows it | A dirty marker that compares the setup with the preset it was loaded from, a confirm before loading another preset over unsaved edits, and a |
Provider keys never reach the browser | The browser calls our server for models, runs, cancels and presets. The stream is our server's event stream, not the provider's, and the server translates stop into whatever the provider needs. |
Core entities
| Entity | What it holds |
|---|---|
Setup | Everything one run needs, held in one object that the controls edit. |
Preset | A saved setup with a name and an owner, stored server-side for teammates to load. |
Run | One execution of one setup, from pressing run to done, failed or canceled. |
Model | A model the server offers, with the limits its parameters must respect. |
Compare column | One column in a side-by-side view, with a setup and a run of its own. |
The API
| Endpoint | Notes |
|---|---|
| Fetched once when the page opens and cached. The limits drive the limit check on model switch and preset load, so the page needs them before the first run. |
| The body is the deep copy of the setup. The response is read from |
| Sent after |
| The list is paged by cursor and cached in the client for the sidebar. Opening one fetches it by id so the setup and version are the latest, then writes the setup into the state in one step. |
|
|
The high-level design
Step 1 of 4
Controls, setup, run, output
Start with the four pieces the prompt names: controls for the model and its parameters, a setup object they edit, a run controller that posts the setup and an output panel that draws the events as they stream in. This works for one person running one setup, and it already has gaps: the run reads the live setup, so a keystroke in the prompt box during the 20 seconds of streaming is ambiguous; nothing checks values against the limits of the chosen model; and nothing survives a reload.
What breaks first
The deep dives
One setup, many controls, one run. Someone switches the model, moves the temperature slider, edits the system prompt and presses run while still typing in the prompt box. Where does each value live, and what does the request carry?
Saving, sharing and loading presets. Someone saves a setup as a preset and shares it. A teammate opens it later with a different model chosen. What does the preset hold, and what happens to each value on the way into the controls?
Two people editing one preset. Two teammates open the same shared preset. One saves a new system prompt; the other, still on the old copy, changes the temperature and saves. What does each of them see?
Comparing runs side by side. Someone sets up three columns with different models and presses run once. What happens on the screen over the next 20 seconds, and what gets slow first?
Concepts this guide uses
Sources
- PostHog docs: LLM analytics playground
- PostHog docs: Prompt management
- web.dev: Web Vitals
- MDN: AbortSignal
- Front End Interview Handbook: OpenAI front end interview questions
- web.dev: Interaction to Next Paint (INP)
- MDN: Window beforeunload event
- MDN: If-Match header
- MDN: HTTP conditional requests
- MDN: AbortController
- MDN: Using the Fetch API
- MDN: Using readable streams
- MDN: Window requestAnimationFrame()
- MDN: Window structuredClone()
- MDN Glossary: Deep copy