System Overview
High-level architecture of the Linea platform.
System Overview
Linea is a multi-tenant workflow automation platform. Its backend is a NestJS monolith divided into feature modules, backed by PostgreSQL with pgvector, and a BullMQ job queue over Redis.
Component Diagram
Rendering diagram…
Request Lifecycle
- Frontend calls the API with a Clerk JWT
- AuthGuard validates the token and resolves the
Userrecord viaclerkId - WorkspaceGuard checks
workspace_membersand attachesreq.workspace+req.membership - SpaceGuard (for space-scoped routes) verifies the space belongs to the workspace and attaches
req.space - Controller delegates to a Service which queries via Drizzle ORM
- For workflow execution: the service enqueues a BullMQ job; a Worker picks it up and processes it asynchronously
Module Boundary Rules
- Each NestJS module owns exactly one domain (e.g.,
WorkflowsModuleonly touchesworkflowstable) - Cross-module reads go through exported services, never direct table access from another module
- The
DatabaseModuleis global; all modules receive the Drizzle client via@Inject(DB_TOKEN) SpacesModuleexportsSpacesServiceand is imported byWorkflowsModule,ExecutionsModule,SchedulesModule,WebhooksModule
Error Handling
All service methods throw NestJS built-in exceptions (NotFoundException, ForbiddenException, etc.). Guards return structured 401/403/404 before the controller is reached. Unhandled errors are caught by NestJS's global exception filter.