Quickback Compiler
Transform declarative resource definitions into a production-ready API. The Quickback compiler generates optimized code, validates security, and creates migrations.
The Quickback compiler transforms your declarative resource definitions into a complete, production-ready API. It analyzes your TypeScript definitions at build time, generates optimized code, validates your security configuration, and creates database migrations.
What the Compiler Does
When you run quickback compile, the compiler:
- Reads your definitions - Analyzes all
defineTable()configurations in yourdefinitions/folder - Validates security - Checks that firewall, guards, access, and masking are properly configured
- Generates API routes - Creates REST endpoints for each resource (GET, POST, PATCH, DELETE, plus batch operations)
- Generates actions - Creates custom endpoints from your
defineActions()definitions - Creates middleware - Generates authentication, authorization, and data validation logic
- Generates TypeScript types - Creates type-safe interfaces for your API
- Generates migrations - Automatically runs
drizzle-kit generateto create database migration files
Input:
quickback/
├── quickback.config.ts # Compiler configuration
└── definitions/
└── features/
└── rooms/
├── rooms.ts # defineTable(...)
└── actions.ts # defineActions(...)Output:
src/
├── routes/
│ └── rooms.ts # Generated API handlers
├── middleware/
│ ├── auth.ts # Authentication logic
│ └── firewall.ts # Data isolation queries
└── types/
└── rooms.ts # TypeScript interfacesBasic Usage
Compile Your Project
quickback compileThis command:
- Reads your
quickback.config.ts - Analyzes all resource definitions
- Generates the complete API codebase
- Reports any configuration errors
After Compilation
Once compilation succeeds, you need to:
-
Apply migrations:
Run the database migration for your provider. The generated
package.jsonincludes the appropriate migration script for your setup.Note: The compiler automatically runs
drizzle-kit generateduring compilation, so you only need to apply the migrations. -
Deploy your API:
npm run deploy # Cloudflare Workers # or npm start # Local development
The Compilation Process
1. Configuration Loading
The compiler reads your quickback.config.ts:
import { defineConfig, defineRuntime, defineDatabase, defineAuth } from "@quickback/compiler";
export default defineConfig({
name: 'my-app',
template: 'hono',
features: ['organizations'],
providers: {
runtime: defineRuntime('cloudflare'),
database: defineDatabase('cloudflare-d1'),
auth: defineAuth('better-auth'),
},
});This determines:
- Which application template to use (
honoor experimentalnextjs) - Which database adapter to use (D1, SQLite, Turso, etc.)
- Which authentication system to integrate
- Which runtime to target (Cloudflare Workers, Bun, Node.js)
- Which auth plugins to enable (based on
features)
2. Resource Discovery
The compiler scans definitions/features/ and identifies:
Resources (with routes):
// definitions/features/rooms/rooms.ts
export default defineTable(rooms, { ... });
// → Generates: GET/POST/PATCH/DELETE /api/v1/rooms
// → Also generates: POST/PATCH/DELETE/PUT /api/v1/rooms/batch (auto-enabled)Internal tables (no routes):
// definitions/features/rooms/room-bookings.ts
export const roomBookings = sqliteTable(...);
// NO default export → No routes generatedActions:
// definitions/features/rooms/actions.ts
export default defineActions(rooms, {
book: { ... },
cancel: { ... }
});
// → Generates: POST /api/v1/rooms/:id/book, POST /api/v1/rooms/:id/cancel3. Validation
The compiler validates your configuration at build time, catching errors before deployment. See Definitions for details on what's validated.
4. Code Generation
The compiler generates different files based on your provider:
Cloudflare Workers (Hono)
// Generated: src/routes/rooms.ts
import { Hono } from 'hono';
import { applyFirewall } from '../middleware/firewall';
import { checkAccess } from '../middleware/access';
const app = new Hono();
app.get('/rooms', async (c) => {
const ctx = c.get('ctx');
let query = db.select().from(rooms);
query = applyFirewall(query, ctx, 'rooms');
await checkAccess(ctx, 'rooms', 'list');
const results = await query;
return c.json(results);
});5. Type Generation
The compiler generates TypeScript types for your API:
// Generated: src/types/rooms.ts
export type Room = typeof rooms.$inferSelect;
export type RoomInsert = typeof rooms.$inferInsert;Build-Time vs Runtime
Build Time (Compilation)
The compiler validates security configuration, checks for schema/firewall mismatches, generates API route handlers, creates TypeScript types, and prepares migration setup.
Runtime (API Requests)
When your API receives a request: Authentication → Firewall → Access → Guards → Masking → Response. The compiled code handles all of this automatically.
Development Workflow
- Define resources in
definitions/features/ - Compile with
quickback compile - Review migrations in
drizzle/ - Apply migrations for your provider
- Test locally with
npm run dev - Deploy with
npm run deploy
Next Steps
- Getting Started — Create your first project
- Definitions — Schema, security layers, and actions
- Using the API — CRUD endpoints and filtering
- Cloud Compiler — CLI and authentication