Ad Simulation AI — MVP web app to simulate ad performance using an LLM before running ads.
COMPLETEProject Overview
Features
- Build InputForm component
Create /components/InputForm.tsx with controlled inputs for product, audience, pain points, ad goal (select), and winning ads examples (textarea).
- Client-side validation
Ensure required fields are present; trim inputs; basic length limits.
- Submit to API
POST JSON payload to /api/simulate; handle abort/cancel if needed.
- Implement /api/simulate route handler
Create /app/api/simulate/route.ts; accept POST; validate payload; call Claude API with async/await.
- Prompt engineering for strict JSON
Create a structured prompt that forces valid JSON array output; include evaluation rubric (emotional hook, pain relevance, clarity, curiosity, conversion potential).
- Parse and validate response
Parse JSON; handle malformed responses; validate required fields; sort by score desc; return normalized JSON.
- Env var + secrets handling
Use process.env for ANTHROPIC_API_KEY (and model name if configurable). Never log secrets.
- Error handling + status codes
Return 400 for bad input; 500 for LLM errors; include safe error messages.
- Build AdCard component
Create /components/AdCard.tsx to render headline, ad_copy, score, reasoning; include rank index and consistent styling.
- Main page layout
Implement /app/page.tsx to compose InputForm + results list; manage state for loading, error, and results.
- Loading + empty states
Disable submit button during request; show spinner/text; show placeholder when no results.
- API error UX
Show a non-technical error message and optionally details for debugging in dev.
- Define TypeScript types for request/response
Create shared types (inline or /lib/types) for payload and response items; enforce in UI.
- Normalize + sort results server-side
Ensure server returns results sorted by score desc; clamp score to 1-10; drop invalid items.
- Example API response + documentation
Provide README section with example request/response and env setup.
Milestones
Milestone 1
Assigned Features
- Ad simulation input form
- LLM-powered ad generation + scoring (Claude)
- Ranked results UI
- JSON contract + ranking rules
Milestone 2