Reference Implementations
Complete, working implementations of the 4 required Brain Spec endpoints in Node.js, Python, and Go. Copy, paste, replace the sample data with your product, and you're live.
import express from "express";
import crypto from "crypto";
const app = express();
const BRAIN_TOKEN = process.env.BRAIN_API_TOKEN;
// ── Auth middleware ─────────────────────────────────────────────
function authGuard(req, res, next) {
const header = req.headers.authorization;
if (!header?.startsWith("Bearer ") || header.slice(7) !== BRAIN_TOKEN) {
return res.status(401).json({ error: "unauthorized" });
}
next();
}
app.use(authGuard);
// ── Helpers ─────────────────────────────────────────────────────
function checksum(data) {
const hash = crypto.createHash("sha256").update(JSON.stringify(data)).digest("hex");
return `sha256:${hash}`;
}
function envelope(data) {
return {
version: "1.0.0",
lastUpdated: new Date().toISOString(),
checksum: checksum(data),
data,
};
}
// ── GET /brain/manifest ─────────────────────────────────────────
app.get("/brain/manifest", (req, res) => {
res.json({
specVersion: "1.0",
productName: "Taskflow",
productSlug: "taskflow",
availableEndpoints: [
"product/capabilities",
"product/limitations",
"product/faq",
],
});
});
// ── GET /brain/product/capabilities ─────────────────────────────
app.get("/brain/product/capabilities", (req, res) => {
const capabilities = [
{
id: "cap-001",
slug: "kanban-boards",
name: "Kanban Boards",
category: "Task Management",
summary: "Drag-and-drop Kanban boards with custom columns.",
description: "Create unlimited boards with WIP limits, swimlanes, and real-time collaboration.",
status: "available",
available: true,
supportedPlans: ["starter", "pro", "enterprise"],
supportedPersonas: ["project-manager", "developer"],
relatedUseCaseIds: [],
relatedDemoIds: [],
limitations: ["WIP limits only on Pro+"],
caveats: [],
proofRefs: ["https://docs.taskflow.io/kanban"],
faqAnswerIds: ["faq-001"],
tags: ["core", "collaboration"],
lastVerifiedAt: new Date().toISOString(),
version: "1.0.0",
},
];
res.json(envelope(capabilities));
});
// ── GET /brain/product/limitations ──────────────────────────────
app.get("/brain/product/limitations", (req, res) => {
const limitations = [
{
id: "lim-001",
capabilityId: "cap-001",
title: "WIP limits require Pro plan",
description: "Work-in-progress column limits are only available on Pro and Enterprise.",
limitationType: "plan_restriction",
severity: "important",
escalationRequired: false,
lastVerifiedAt: new Date().toISOString(),
version: "1.0.0",
},
];
res.json(envelope(limitations));
});
// ── GET /brain/product/faq ──────────────────────────────────────
app.get("/brain/product/faq", (req, res) => {
const faq = [
{
id: "faq-001",
canonicalQuestion: "How many boards can I create?",
questionType: "product",
approvedAnswer: "All plans include unlimited boards. The Starter plan limits workspace members to 10.",
answerMode: "strict",
escalationRequired: false,
relatedCapabilityIds: ["cap-001"],
relatedLimitationIds: [],
relatedDemoIds: [],
tags: ["pricing", "limits"],
owner: "sales-ops",
lastReviewedAt: new Date().toISOString(),
version: "1.0.0",
},
];
res.json(envelope(faq));
});
app.listen(3001, () => console.log("Brain API running on :3001"));BRAIN_API_TOKEN