Skip to main content

Why Logic Bee?

Most backend frameworks were designed for humans writing controllers by hand. Logic Bee 🐝 was designed for a world where AI agents generate business logic and thousands of tenants share the same runtime. This page explains the architectural shift and why it matters.

Classic OOP APIs vs Event-Driven Hooks

Classic OOP APILogic Bee (Event-Driven)
Unit of workController class with many methodsSingle @LogicHook class — one file, one job
RoutingOne route per endpoint, manually registeredUniversal dynamic route — /api/v2/universal/:cfpSlug/:dataType/:action
WiringImport into modules, update DI arrays, modify barrel filesAuto-registered on import — drop a file, it works
Tenant isolationManual query filters (WHERE tenant_id = ?) on every queryBuilt into FlowQuery ORM — tenant-scoping is automatic
ScalingHorizontal scaling of entire appCluster-mode workers + per-hook concurrency control
AI compatibilityLarge multi-method classes are hard for models to parseOne-file, one-purpose hooks are ideal prompt context
StreamingBolt-on WebSocket or pollingNative SSE channels with session lifecycle

In a traditional API you end up with fat controllers that grow indefinitely. Every new feature means editing an existing file, updating a router, and hoping you got the dependency injection right. Logic Bee inverts this: every feature is a new file, and the framework does the rest.

The Five Architectural Wins

1. Fastify-First Performance

Logic Bee registers Fastify routes directly — no NestJS controller layer in the hot path. Combined with Node.js cluster mode and PM2 process management, this keeps latency low even when thousands of dynamically-resolved hooks share the same deployment.

2. One Hook, One File

The @LogicHook decorator enforces a strict single-responsibility pattern:

@LogicHook({
name: 'FinanceBillsCalculateBill',
path: 'finance-bills/calculate-bill',
library: 'finance-bills',
method: 'calculate-bill',
})
export class FinanceBillsCalculateBill {
public static execute() {
return async (bob: BobRequest) => { /* … */ }
}
}

No barrel edits. No module imports. The hook is its own contract — name, path, library, and method are all declared in the decorator, and the framework auto-registers it on boot.

3. FlowQuery — Tenant-Safe by Default

In a multi-tenant system, one missing WHERE tenantId = ? is a data leak. FlowQuery eliminates this risk by scoping every query to the active FlowUser's business unit automatically. When an AI agent writes a database query through FlowQuery, it is inherently sandboxed — no extra guardrails needed from the author.

4. Native AI Integration

Logic Bee repositories include .agents/skills/ directories that make the codebase self-describing. Instead of relying on an AI agent to reverse-engineer your project structure, skill files tell the agent what hooks exist, what conventions to follow, and how to contribute new code. The result: AI-generated hooks that conform to project standards on the first pass.

5. Universal Routing + SSE Streaming

Instead of generating hundreds of REST endpoints, Logic Bee funnels all traffic through a small set of universal routes. The action is resolved dynamically from the path, so the router never needs to be touched. For long-running operations — AI agent pipelines, heavy data imports, report generation — built-in SSE streaming pushes incremental results to the client in real time, avoiding HTTP timeout walls entirely.

When to Choose Logic Bee

Logic Bee is purpose-built for platforms that need to:

  • Execute AI-generated business logic safely in production
  • Serve multiple tenants from a single deployment with strict data isolation
  • Scale horizontally without rewriting routing or middleware
  • Stream long-running operations (AI agents, ETL jobs) back to a frontend in real time

If you are building a visual low-code builder, Logic Bee is the deployment execution engine underneath. Users drag nodes in the UI; the system translates blueprints into @LogicHook files; Logic Bee ingests, secures, and exposes them — all through one API surface.