UCD.js Docs

API

Architecture notes for apps/api

apps/api is the public HTTP worker for UCD.js.

Role

  • Serves the version, file, schema, well-known, and task endpoints.
  • Publishes the .well-known discovery document used by @ucdjs/client.
  • Owns the API-facing boundary between external consumers and upstream Unicode data services.

Mental Model

The app has one Hono/OpenAPI process with three concerns:

  • register the HTTP surface
  • apply shared worker policy
  • expose both machine-readable OpenAPI and human-readable API docs

It is the canonical network entrypoint for most public consumers.

Request Flows

Worker startup

route modulesworker-utilsOpenAPIHonoworker.tsroute modulesworker-utilsOpenAPIHonoworker.tsRuntimeinitialize modulecreate OpenAPIHono()setupCors(app)setupRatelimit(app)mount versions/files/schemas/well-known/tasks routersregister Scalar UI and /openapi.jsonfetch-capable worker appRuntime

Normal API request

bound service or upstream fetchroute handlershared middlewareapps/apibound service or upstream fetchroute handlershared middlewareapps/apiClientGET /api/v1/...apply CORS + rate limit + error boundarydispatch to matching routerresolve requested dataresponse data or failureJSON/text responseClient

Discovery request

route config builder/.well-known routerroute config builder/.well-known routerClientGET /.well-known/ucd-config.jsonconstruct endpoint configvalidated discovery payloadendpoint URLs for files, versions, schemas, configClient

OpenAPI document request

buildOpenApiConfig()worker env/openapi.jsonbuildOpenApiConfig()worker env/openapi.jsonConsumerGET /openapi.jsonread ENVIRONMENT and API_VERSIONbuild server list and metadataOpenAPI 3.1 documentJSON specConsumer

Design Notes

  • Route modules own endpoint behavior, while worker.ts owns composition.
  • OpenAPI and Scalar are first-class parts of the app, not afterthoughts.
  • Discovery lives beside the main API because the client depends on one canonical source of endpoint truth.
  • Shared middleware keeps this worker aligned with the store worker where possible.

Testing Use

  • route registration and request dispatch
  • .well-known discovery payload correctness
  • OpenAPI server selection by environment
  • error and rate-limit behavior via shared worker-utils integration

On this page