High-Level Architecture
Core Components
1. Frontend (Angular + Nginx)
Technology: Angular 17+ with Angular MaterialLocation:
packages/web/Responsibilities:- Visual flow builder (drag-and-drop interface)
- Execution logs viewer
- User management
- Configuration UI
- Real-time updates via WebSockets
- Built to static files in
dist/packages/web/ - Served by Nginx on port 80
- Gzipped and optimized for production
nginx.react.conf):
2. API Server (Fastify + Node.js)
Technology: Node.js 20 with Fastify frameworkLocation:
packages/server/api/Entry Point: src/bootstrap.ts → src/main.tsResponsibilities:- RESTful API endpoints
- User authentication (JWT)
- Flow CRUD operations
- Webhook receivers
- Job scheduling to Redis
- File uploads/downloads
- OAuth flows
- WebSocket connections
Authentication
Authentication
Location:
app/authentication/- JWT token generation/validation
- OAuth 2.0 flows (Google, GitHub)
- API key authentication
- User identity management
- Session handling
- bcrypt password hashing
- JWT with configurable expiration
- Rate limiting on auth endpoints
Flow Management
Flow Management
Location:
app/flows/- Flow entity: Workflow definitions
- FlowVersion entity: Immutable versions
- FlowRun entity: Execution records
- Folder entity: Organization
- Versioning system
- Draft/published states
- Import/export
- Templates
Webhook Handler
Webhook Handler
Location:
app/webhooks/- Dynamic webhook endpoint creation
- Payload validation
- Trigger matching
- Handshake/verification flows
- Replay protection
POST /api/v1/webhooks/:flowId/:simulate?Pieces (Integrations)
Pieces (Integrations)
Location:
app/pieces/- Piece metadata management
- Dynamic piece loading
- Version compatibility
- Piece installation/updates
- Community pieces
- Custom pieces
- Enterprise pieces
3. Database (PostgreSQL)
Technology: PostgreSQL 14+ORM: TypeORMLocation:
app/database/Key Tables:flow: Workflow definitionsflow_version: Immutable workflow versionsflow_run: Execution logs and resultsuser: User accountsproject: Workspaces/projectsapp_connection: OAuth tokens and API keystrigger_event: Queued trigger eventsfile: File metadatastore_entry: Key-value storage
app/database/migration/Automatically applied on startup via TypeORM.4. Job Queue (Redis + BullMQ)
Technology: Redis 7+ with BullMQ libraryLocation:
app/workers/queue/Job Types:ExecuteFlowJob: Workflow executionsPollingJob: Scheduled trigger pollingWebhookJob: Webhook-triggered flowsRenewWebhookJob: Webhook renewalUserInteractionJob: Human-in-the-loop tasksEventDestinationJob: Event forwarding
- Job prioritization
- Delayed jobs
- Job retries with exponential backoff
- Job dependencies
- Cron-based scheduling
- Rate limiting
5. Worker Processes
Location:
app/workers/Responsibilities:- Consume jobs from Redis queue
- Execute workflows via Engine
- Handle polling triggers
- Renew webhook subscriptions
- Process scheduled tasks
AP_WORKER_CONCURRENCYScaling: Horizontal scaling by adding more worker containers6. Execution Engine
Location:
packages/server/engine/Entry Point: src/main.tsTechnology: Node.js with isolated-vm for sandboxingResponsibilities:- Parse flow definitions
- Execute steps sequentially
- Handle branching (router steps)
- Loop processing
- Error handling and retries
- Code step execution (sandboxed)
- Piece action execution
AP_ENGINE_EXECUTABLE_PATH=dist/packages/engine/main.js7. Sandboxing (isolated-vm)
Technology: isolated-vm (V8 isolates)Location:
packages/server/engine/src/lib/core/code/Purpose: Securely execute untrusted user codeFeatures:- Memory isolation (128MB default limit)
- CPU time limits
- No file system access
- No network access (except through provided APIs)
- Separate V8 heap
v8-isolate-code-sandbox.ts:19):
8. File Storage
Options: Local filesystem or S3-compatible storageLocation:
app/file/S3 Implementation: app/file/s3-helper.tsSupported Operations:- Upload files
- Download files
- Generate pre-signed URLs (7-day expiry)
- Batch delete (100 files max)
FILE: User uploadsFLOW_RUN_LOG: Execution logsSTEP_FILE: Step outputsPACKAGE_ARCHIVE: Piece packages
Data Flow
Webhook-Triggered Flow
Scheduled Trigger Flow
Communication Patterns
Internal Communication
- API → Database
- API → Redis
- Worker → Engine
Protocol: PostgreSQL wire protocolConnection: TypeORM with connection poolingOperations:
- CRUD for all entities
- Complex queries with joins
- Transactions for atomic operations
External Communication
- Webhooks
- Piece Actions
Inbound: Receive HTTP POST from external servicesEndpoint:
POST /api/v1/webhooks/:flowIdProcessing:- Validate signature (if configured)
- Match to flow trigger
- Enqueue execution job
- Return 200 OK immediately
Security Architecture
Authentication Layers
Data Encryption
- At Rest:
AP_ENCRYPTION_KEYfor sensitive data (OAuth tokens, API keys) - In Transit: TLS/SSL for all external communication
- Database: Optional PostgreSQL encryption
- Storage: Optional S3 server-side encryption
High Availability
Stateless Design
All components are stateless (state in PostgreSQL/Redis):- API Servers: Scale horizontally behind load balancer
- Workers: Add/remove workers dynamically
- Frontend: Static files, can be CDN-cached
Single Points of Failure
Performance Characteristics
Throughput
- API: ~1000 requests/sec per instance (2 CPU, 4GB RAM)
- Workers: Depends on workflow complexity
- Simple flows: 100-200/min per worker
- Complex flows: 10-50/min per worker
- Database: Bottleneck at ~1000 connections
Latency
- API Response: < 100ms (simple queries)
- Webhook Processing: < 50ms (enqueue only)
- Flow Execution: Depends on steps (typically 1-10s)
Next Steps
Workers
Deep dive into worker processes
Engine
Understand execution engine
Scaling
Scale the architecture
Database
Database architecture