nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Documentation API for N10. Runs as part of the api.nyuchi.dev Cloudflare Worker (Rust/WASM), NOT a Supabase Edge Function. Serves documentation pages, AI instructions, architecture nodes, and changelog entries from the Supabase database via PostgREST. Endpoints: /docs, /ai-instructions, /architecture, /changelog, /counts. All responses use node language (ecosystem_node, nodes_affected). Public read access, no auth required.
View the full component source code below.
// nyuchi-docs-api runs as a Cloudflare Worker (workers-rs/Rust WASM)
import { createClient } from "jsr:@supabase/supabase-js@2"
// NYUCHI DOCS API — N10: Documentation Outlier
//
// Cloudflare Worker (Rust/WASM). Serves documentation and AI instruction
// content from the database. The database is the mechanical source
// of truth; this function is the read layer over it.
//
// Routes:
// GET /docs — list all published documentation pages
// GET /docs/:slug — get a page by slug
// GET /docs/category/:category — filter pages by category
// GET /ai-instructions — list all active AI instruction sets
// GET /ai-instructions/:name — get instruction set by name or target
// GET /architecture — full 3D ecosystem model (all 10 nodes)
// GET /architecture/nodes — node list with counts
// GET /architecture/axes — axis summary
// GET /changelog — recent changelog entries
// GET /changelog/:version — specific version entry
// GET /counts — live system counts (no hardcoded numbers)
const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
"Access-Control-Allow-Methods": "GET, OPTIONS",
}
const CACHE_HEADERS = {
"Cache-Control": "public, max-age=60, stale-while-revalidate=300",
}
function json(data: unknown, status = 200): Response {
return new Response(JSON.stringify(data), {
status,
headers: {
"Content-Type": "application/json",
...CORS_HEADERS,
...CACHE_HEADERS,
},
})
}
function error(message: string, status = 400): Response {
return new Response(JSON.stringify({ error: message }), {
status,
headers: { "Content-Type": "application/json", ...CORS_HEADERS },
})
}
Deno.serve(async (req: Request) => {
// Handle CORS preflight
if (req.method === "OPTIONS") {
return new Response(null, { headers: CORS_HEADERS })
}
if (req.method !== "GET") {
return error("Method not allowed", 405)
}
const supabase = createClient(
Deno.env.get("SUPABASE_URL") ?? "",
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? ""
)
const url = new URL(req.url)
const path = url.pathname.replace(/^\//, "").split("/")
const [resource, ...rest] = path
try {
// ── GET /counts ─────────────────────────────────────────────
if (resource === "counts") {
const { data, error: err } = await supabase.rpc("get_system_counts")
if (err) return error(err.message, 500)
return json(data?.[0] ?? {})
}
// ── GET /docs ────────────────────────────────────────────────
if (resource === "docs") {
const sub = rest[0]
const subsub = rest[1]
// GET /docs/category/:category
if (sub === "category" && subsub) {
const { data, error: err } = await supabase
.from("documentation_pages")
.select("slug, title, category, subcategory, description, keywords, sort_order, related_nodes, related_components, status, updated_at")
.eq("category", subsub)
.eq("status", "published")
.order("sort_order")
if (err) return error(err.message, 500)
return json(data)
}
// GET /docs/:slug — specific page with full content
if (sub && sub !== "category") {
const { data, error: err } = await supabase
.from("documentation_pages")
.select("*")
.eq("slug", sub)
.eq("status", "published")
.single()
if (err) return error("Page not found", 404)
return json(data)
}
// GET /docs — list all pages (no content body, just metadata)
const { data, error: err } = await supabase
.from("documentation_pages")
.select("slug, title, category, subcategory, description, keywords, sort_order, related_nodes, status, updated_at")
.eq("status", "published")
.order("category")
.order("sort_order")
if (err) return error(err.message, 500)
return json(data)
}
// ── GET /ai-instructions ─────────────────────────────────────
if (resource === "ai-instructions") {
const identifier = rest[0]
if (identifier) {
// Try name first, then target
const { data, error: err } = await supabase
.from("ai_instructions")
.select("*")
.eq("status", "active")
.or(`name.eq.${identifier},target.eq.${identifier}`)
.order("version", { ascending: false })
if (err) return error(err.message, 500)
if (!data?.length) return error("Instruction not found", 404)
// If multiple versions match, return the latest
return json(data[0])
}
const { data, error: err } = await supabase
.from("ai_instructions")
.select("id, name, target, description, applies_to_nodes, applies_to_categories, version, status, updated_at")
.eq("status", "active")
.order("target")
if (err) return error(err.message, 500)
return json(data)
}
// ── GET /architecture ────────────────────────────────────────
if (resource === "architecture") {
const sub = rest[0]
// GET /architecture/nodes — node list with component counts
if (sub === "nodes") {
const { data, error: err } = await supabase.rpc("get_node_counts")
if (err) return error(err.message, 500)
return json(data)
}
// GET /architecture/axes — axis summary
if (sub === "axes") {
const { data, error: err } = await supabase.rpc("get_axes_summary")
if (err) return error(err.message, 500)
return json(data)
}
// GET /architecture — full model (all nodes + axes)
const { data, error: err } = await supabase.rpc("get_architecture")
if (err) return error(err.message, 500)
return json(data)
}
// ── GET /changelog ───────────────────────────────────────────
if (resource === "changelog") {
const version = rest[0]
if (version) {
const { data, error: err } = await supabase.rpc("get_changelog_entry", {
p_version: version,
})
if (err) return error(err.message, 500)
if (!data?.length) return error("Version not found", 404)
return json(data[0])
}
const limit = parseInt(url.searchParams.get("limit") ?? "20", 10)
const offset = parseInt(url.searchParams.get("offset") ?? "0", 10)
const { data, error: err } = await supabase.rpc("list_changelog", {
p_limit: Math.min(limit, 100),
p_offset: Math.max(offset, 0),
})
if (err) return error(err.message, 500)
return json(data)
}
return error("Not found", 404)
} catch (e) {
console.error("[nyuchi-docs-api]", e)
return error("Internal server error", 500)
}
})
npx shadcn@latest add https://mzizi.dev/api/v1/ui/nyuchi-docs-apiFetch this component's metadata and source code from the registry API.
/api/v1/ui/nyuchi-docs-api