Architecture: hbf-core-api
C4 Component Diagram
Key Flows
Instantiation and Request Lifecycle
const client = new HBFCoreApi("https://core.helvia.io", jwtToken);
const deployment = await client.BotDeploymentClient.findByHandle("my-bot");
HBFCoreApiconstructor storesurlandtoken. No HTTP calls are made at construction time.- Getter (e.g.,
.BotDeploymentClient) creates a new instance of the sub-client, passingthisas the core client reference. - Sub-client method builds the URL path and calls
coreClient.requestHBFCore(method, path, payload?). requestHBFCoreaddsAuthorization: Bearer <token>andContent-Type: application/jsonheaders, then delegates tomakeApiRequest.makeApiRequestcalls axios. On network error (no response), it retries up to 3 times with exponential backoff (delay =(e^attempt - 2*random) * 1000ms). On HTTP error response (non-2xx), it returns the response without throwing. On axios setup error, it returns a synthetic 503.- The result is wrapped in
HBFCoreApiResponseand returned to the sub-client. - Sub-client calls the appropriate extractor (
.getOptionalValue<BotDeployment>()) and returns the typed value or throws on error.
List Responses
hbf-core returns paginated lists as { items: T[], page: number, pageSize: number, total: number }. HBFCoreApiResponse.getList<T>() reads body.items. TenantsClient.listPaged() handles multi-page collection by looping until all pages are fetched.
Resource Creation (ID Extraction)
POST endpoints in hbf-core return the created resource ID either in the Location header (format: /{resource}/{id}) or in the response body as { id: string }. HBFCoreApiResponse.getSavedId(resource) handles both cases.
Shared Data Model
All TypeScript interfaces live in src/datamodel/. They are re-exported from src/index.ts and consumed by other HBF services (hbf-bot, hbf-console, etc.) that import this package. Keeping types here ensures a single source of truth for the shared domain model across the Node.js ecosystem.