The problem
New backends tend to start with familiar chores: routes, database access, migrations, and module boundaries. Hono-Kiln packages those patterns into a Bun and Hono scaffold, including support for keeping tenants separate.
The approach: Bun and Hono provide the runtime and routing. Generated modules keep application logic, persistence, and tenant handling organized.
Reported project measurements: Sub-1ms cold start on edge runtimes; 100% tenant isolation across database repositories; automated OpenAPI spec generation from Drizzle/Zod schemas.
How it works
The monorepo puts HTTP transport (@kiln/api), domain logic (@kiln/sdk) and database persistence (@kiln/shared) in separate workspace packages.
Middleware checks the tenant at the HTTP gateway and carries it into every Drizzle ORM query.
Inngest step functions run inside Hono route handlers, so background tasks need no separate worker infrastructure.
How the pieces connect
flowchart TD
A[HTTP Request: Edge / Serverless] --> B[Hono Edge Router]
B --> C[Tenant Auth & Context Guard]
C --> D[Clean Architecture Controller]
D --> E[Domain Service Layer]
E --> F[Tenant-Scoped Drizzle ORM Repository]
F --> G[(PostgreSQL / SQLite Database)]
E --> H[Inngest Event Dispatcher]
H --> I[Async Background Step Workflows]
Implementation notes
Type-Safe Tenant Auth Guard (packages/api/src/middleware/tenant.ts)
// Type-Safe Tenant Auth Guard for Multi-Tenant Edge Routing
import { createMiddleware } from "hono/factory";
const tenantAuthGuard = createMiddleware(async (c, next) => {
const tenantId = c.req.header("x-tenant-id");
if (!tenantId) return c.json({ error: "Missing required tenant identity" }, 401);
c.set("tenantId", tenantId);
await next();
});
Embedded Inngest Background Function (packages/api/src/functions/sync.ts)
// Embedded Inngest Step Workflow inside Hono
import { inngest } from "../inngest/client";
const processTenantDataSync = inngest.createFunction(
{ id: "tenant-data-sync", retries: 3 },
{ event: "tenant/data.sync" },
async ({ event, step }) => {
const records = await step.run("fetch-records", async () => {
return fetchRemoteRecords(event.data.tenantId);
});
await step.run("persist-records", async () => {
return persistToDatabase(event.data.tenantId, records);
});
return { success: true, count: records.length };
}
);
Tradeoffs and lessons
- Bun's native HTTP server with Hono removed the Node.js cold-start penalty and brought p99 response times under 12ms.
- Hono's context storage keeps background tasks and database queries scoped to the tenant that made the request.