Repository navigation
api rest endpoints
Scope. Endpoints of
@safrs/api(golden-path). This is not an inventory of SentraBot oRPC, Kediri, or Avery.
Purpose: Every HTTP endpoint in the golden-path API: request/response shapes, Zod rules, error envelope. Defined in packages/api/src/app.ts, validated with @safrs/schemas (packages/schemas/src/demo.ts).
The Hono app uses .basePath("/api"), so all routes below are served under /api. In the Next.js golden-path app, the Hono app is mounted via the catch-all route at projects/internal/golden-path/apps/web/src/app/api/[[...route]]/route.ts.
| Method | Path | Success | Failure |
|---|---|---|---|
| GET | /api/health |
200 | 500 |
| GET | /api/demos |
200 | 500 |
| POST | /api/demos |
201 | 400, 500 |
| GET | /api/openapi.json |
200 | 500 |
| GET | /api/docs |
200 (HTML) | 500 |
- Every response carries an
x-correlation-idheader generated per request in middleware. - On error, the body is the
ApiErrorenvelope (see below) and thex-correlation-idmatches thecorrelationIdin the body for correlation.
All errors follow apiErrorSchema from @safrs/schemas (packages/schemas/src/demo.ts), built by packages/api/src/error.ts:
{
"code": "VALIDATION_ERROR",
"message": "Permintaan tidak valid.",
"correlationId": "8b8f6c3a-...",
"fieldErrors": { "name": ["String must contain at least 1 character(s)"] }
}| Field | Type | Description |
|---|---|---|
code |
string |
VALIDATION_ERROR or INTERNAL_ERROR
|
message |
string | User-facing (Bahasa Indonesia) message |
correlationId |
string | UUID matching the x-correlation-id header |
fieldErrors |
object (optional) | Field → messages map, present on validation errors |
Unexpected errors are redacted: the onError handler always returns INTERNAL_ERROR with no stack trace or internal detail, so database URLs and stacks never leak to clients.
- Purpose: Readiness check for the service.
-
Implementation:
packages/api/src/app.ts—.get("/health", ...). - Success 200:
{ "status": "ok" }- Purpose: List all demo records.
-
Implementation: calls
store.demo.findMany()and serializes each record throughdemoSchema.parse(). -
Success 200 — array of
Demorecords:
[
{
"id": "5c2d5001-3f71-4c61-bef8-e8f55cc20cea",
"name": "Atlas",
"createdAt": "2026-08-10T00:00:00.000Z"
}
]The Demo shape (demoSchema) is:
| Field | Type | Constraint |
|---|---|---|
id |
string | UUID |
name |
string | any |
createdAt |
string | ISO-8601 datetime |
- Purpose: Create a new demo record.
-
Implementation: validates the JSON body with
zValidator("json", createDemoInputSchema, ...)before invokingstore.demo.create. -
Request body —
CreateDemoInput(createDemoInputSchema):
{ "name": "Atlas" }| Field | Type | Constraint |
|---|---|---|
name |
string | trimmed, min 1, max 80 characters |
-
Created 201 — a
Demorecord:
{
"id": "5c2d5001-3f71-4c61-bef8-e8f55cc20cea",
"name": "Atlas",
"createdAt": "2026-08-10T00:00:00.000Z"
}-
Bad request 400 —
VALIDATION_ERRORenvelope withfieldErrorsnaming each invalid field. Example:{ "name": "" }returnsnameerrors. -
Internal error 500 —
INTERNAL_ERRORenvelope (redacted).
- Purpose: Serve the OpenAPI 3.1 description of the API.
-
Implementation:
packages/api/src/openapi.ts—buildOpenApiDocument()builds the document directly from the Zod schemas withz.toJSONSchema(...). -
Success 200 — an OpenAPI 3.1 document with
components.schemasforApiError,Demo, andCreateDemoInput, andpathsfor/api/healthand/api/demos.
- Purpose: Serve an interactive Swagger UI for exploring the API.
-
Implementation:
openApiDocsHtml()inpackages/api/src/openapi.tsreturns an HTML page that loads Swagger UI from a CDN and points it at/api/openapi.json. -
Success 200 —
text/htmlSwagger UI page. Safe for local development.
Zod schemas in @safrs/schemas are the single source of truth for the API contract. @hono/zod-validator validates requests, demoSchema.parse() validates serialized responses, and the typed RPC client (hc<AppType>) provides compile-time drift detection. See API overview and Schemas package.
- API overview — architecture, mount point, RPC client
-
API package — the
@safrs/apipackage - Schemas package — the Zod contracts
- Patterns and conventions — error handling
SAFRS — the Sentra Agent-First Repository Standard — defines how a software repository should be structured, governed, and enforced when autonomous Artificial Intelligence agents perform a substantial share of engineering work by Sentra Artificial Intelligence.
SAFRS v1.1 addresses that problem through five coupled mechanisms:
- a six-layer repository architecture from Trust Boundary to Human Authority;
- a role-based permission model in which capability never implies trust;
- a four-tier risk model with cumulative mandatory controls;
- a multi-agent execution protocol with explicit task states and one mutation owner per bounded scope;
- a knowledge governance model that distinguishes current architecture, historical decisions, execution plans, Git history, and running code.
Built in Indonesia as part of the Sentra Artificial Intelligence ecosystem.
Sentra Artificial Intelligence · Source Repository · Official Website
Dr Ferdi Iskandar — Creator & Maintainer
LinkedIn ·
ORCID ·
Hugging Face ·
Kaggle ·
Medium ·
Substack ·
X ·
Threads
MyPrompt · Sentra Artificial Intelligence · Indonesia
- SentraBot
- Kediri History
- Academic Smartboard
- Avery
- Portfolio Dr. Novia
- Golden Path (legacy demonstrator)
- Control Center
- Capsule template
- Risk model (R0–R3)
- Agent roles and permissions
- Capsule sovereignty
- Multi-agent protocol
- Document lifecycle
- Sensitive paths
- Verification integrity
Lore — how this repository grew
- Schemas (
@safrs/schemas) - Environment (
@safrs/env) - Database (
@safrs/database) - API (
@safrs/api) - UI (
@safrs/ui) - Telemetry (
@safrs/telemetry) - Token (
@sentra/token) - Config (
@safrs/config) - Auth (
packages/auth)
- SAFRS governance checkers
- SAFRS Automation Control Plane
- Gaffer Runtime
- Doctor
- Project wizard
- project-standalone
- Capabilities
- Codegen
- Deps-graph
- Status CLI
- Task CLI