Downward-only platform stack
Feature packages stand above this stack; platform packages must not pull product logic upward.
- @nebutra/dbPrisma v7, schema policy, generation scripts
- @nebutra/tenant-storeper-tenant serialization and scoped stores
- @nebutra/provider-factoryexplicit/env/detect/fallback provider resolution
- @nebutra/gateway-coreshared gateway contracts below the Hono backend
- @nebutra/trace-storeasync traces for agents, tools, and LLM spans
What it owns
- Prisma schema, database client, migrations, and multi-schema policy
- Tenant locks, trace store, health checks, config, errors, and rate limiting
- Provider factory and repository boundaries used by higher-level packages
Where it stops
- No app-specific UI or product copy belongs in platform packages.
- Feature packages depend downward; platform does not import feature domains.
How we know it works
- schema drift audits, db generation, and architecture dependency tests
- tenant-store and trace-store package-local doctor/debug commands
In code
1import { getTenantDb } from "@nebutra/db";
2import { getCurrentTenant } from "@nebutra/tenant";
3
4const tenant = getCurrentTenant();
5
6// Row-level security scopes every query to the tenant.
7const posts = await getTenantDb(tenant.tenantId).post.findMany({
8 where: { published: true },
9 orderBy: { publishedAt: "desc" },
10 take: 10,
11});Packages
21 packages in packages/platform.
error.rate > 5%p95.latency > 800msdisk.usage > 80%Alert rules + delivery on top of @nebutra/metering. Threshold/anomaly detection, route to PagerDuty, Discord, or in-product banners.
First-party product analytics on ClickHouse — event ingest, funnel queries, no third-party loader on the marketing site.
- config
- db
- queue
- vault
- events
- ai
- tenant
- schedule
pnpm nebutra capability scaffold
Composable capability primitives — pricing tier ↔ feature flag ↔ quota ↔ UI gating wired into one declarative manifest.
- config.database.urlstring· required
- config.ai.defaultModelstring· default "claude-sonnet-5"
- config.ai.maxTokensnumber· default 4096
- config.cache.ttlnumber· default 60
validated at startup
Typed environment + runtime config — Zod schemas at boot, no scattered process.env reads, fail-fast on missing keys.
Typed Prisma client wrapper — extension-aware, RLS-friendly, with per-tenant connection pinning when the deployment splits writes from reads.
BILLING_PROVIDER_TIMEOUTQUEUE_RETRY_LIMITAUTH_TOKEN_REFRESHEDat packages/commerce/billing/src/charge.ts:42at @nebutra/queue: retryHandlerTyped application error taxonomy — UserError, AuthError, RateLimitError. Maps cleanly to HTTP, to logs, to Sentry, to the in-product toast.
Server + client flag evaluator with GrowthBook / Statsig / custom. Per-tenant overrides, sticky bucketing, exported as React hooks.
BFF primitives shared by backends/gateway and edge handlers — middleware chains, route matchers, header normalization, request-id propagation.
Property-graph model layer for knowledge / org / asset graphs. Edges/nodes typed by Zod, persisted via Prisma or Neo4j adapter.
Liveness + readiness probes for every backend service. Aggregates downstream deps (db, queue, search) into one /healthz response.
next-intl bridge — runtime locale, ICU plural, currency/date formatters, sided JSON bundles per route. Build-time guarantees on key drift.
Structured logging with pino + Sentry transport. One log object per request, breadcrumbs forwarded, PII-stripper plugged into the standard sink.
Auto-detecting provider factory pattern — env vars choose between queue / search / notifications backends with a single getX() call.
- /api/posts200 ok87 left
- /api/users429 throttledretry-after 12s
Token-bucket rate limiter — Upstash Redis or in-memory. Per-route + per-tenant policy, 429 with retry-after, decision logged for audit.
Repository-pattern primitives — findAll, findById, create, update, delete behind one Repository'<T>'. Swap Prisma for any backend without changing callers.
Public status page primitives — incident timeline, component graph, subscriber emails. Renders both /status pages and embeddable widgets.
Tenant-bound key/value cache for lookups too hot for the database. Auto-invalidates on tenant settings change.
OpenTelemetry-compatible span store and query layer. Lets agents trace a tool call across iam, billing, and webhooks.
- browser-utilsSmall browser helpers every app needs: storage that survives private mode and blocked site data, and fetch with a timeout.
- prepaid-walletPrepaid balances and API keys for Nebutra Router and Forge: a wallet port, sk-sailor- keys stored as SHA-256 fingerprints, and a usage envelope that records the charge and the supply cost.
- router-supplySupply routing for Nebutra Router: model aliases, engine discovery from the environment, and an upstream chain that falls back when a provider fails.