Run an industry pattern from a Next.js app
Guide — implement an industry pattern end-to-end from a Next.js app, fusing pattern config + backend-call + browser UI.
Architecture
Browser (React)
→ POST /api/eval (Next.js route)
→ fetch stratix.layerlens.ai/api/v1/evaluations (X-API-Key)
→ poll evaluations/{id} until completed
→ return result to browser (or stream via SSE)Step 1: Configure the pattern (one-time, server-side)
const headers = {
"X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!,
"Content-Type": "application/json",
};
// Pricing-citation JSON-schema scorer
const schemaScorer = await fetch("https://stratix.layerlens.ai/api/v1/scorers", {
method: "POST",
headers,
body: JSON.stringify({
name: "pricing-citation",
type: "json_schema_validate",
config: {
schema: {
type: "object",
required: ["rate_card_row_id", "citation_ts"],
properties: {
rate_card_row_id: { type: "string" },
citation_ts: { type: "string", format: "date-time" },
},
},
},
}),
});
const { id: schemaScorerId } = await schemaScorer.json();
console.log("Schema scorer:", schemaScorerId);Step 2: Build the Next.js API route
Step 3: Stream progress to the browser via SSE
Step 4: Browser-side React component
Step 5: Wire it into your CI
What you've built
Apply this to other patterns
See also
Last updated
Was this helpful?