Project Overview
n8n is a workflow automation platform built with TypeScript, using a monorepo structure managed by pnpm workspaces. The platform consists of:- Node.js backend with Express and TypeORM
- Vue 3 frontend with Vite and Pinia
- Extensible node-based workflow engine
- Multiple specialized packages for different concerns
Monorepo Structure
n8n uses pnpm workspaces with Turbo for build orchestration. This enables:- Isolated package development with shared dependencies
- Automatic file-linking between interdependent modules
- Parallel builds with smart caching
- Independent versioning and testing
Workspace Configuration
The monorepo is defined inpnpm-workspace.yaml:
Build Orchestration
Turbo (turbo.json) orchestrates builds with dependency awareness:
^ prefix means “run this task on all dependencies first.”
Package Structure
The monorepo is organized into logical packages with clear responsibilities:Core Packages
Frontend Packages
Integration Packages
Shared Packages
| Package | Purpose | Used By |
|---|---|---|
@n8n/api-types | TypeScript interfaces for API | Frontend & Backend |
@n8n/config | Centralized configuration | All packages |
@n8n/di | Dependency injection container | Backend services |
@n8n/utils | Shared utilities | All packages |
Development Packages
| Package | Purpose |
|---|---|
@n8n/node-cli | CLI to create new n8n nodes |
packages/testing/playwright | E2E tests with Playwright |
packages/testing/containers | Testcontainers for local testing |
packages/testing/janitor | Test architecture enforcement |
Directory Structure
Technology Stack
Backend
- Runtime: Node.js 24+
- Framework: Express
- Language: TypeScript
- ORM: TypeORM
- Databases: SQLite, PostgreSQL, MySQL
- Queue: Bull (Redis-based)
- Testing: Jest (unit), Supertest (integration)
Frontend
- Framework: Vue 3
- Build Tool: Vite
- State Management: Pinia
- Router: Vue Router
- UI Library: Element Plus + Custom Design System
- Component Development: Storybook
- Testing: Vitest (unit), Playwright (E2E)
Code Quality
- Formatting: Biome
- Linting: ESLint
- Type Checking: TypeScript
- Git Hooks: Lefthook
Architectural Patterns
1. Dependency Injection
n8n uses@n8n/di for IoC (Inversion of Control):
2. Controller-Service-Repository
Backend follows MVC-like pattern:3. Event-Driven Architecture
Internal event bus enables decoupled communication:4. Context-Based Execution
Workflows execute in different contexts based on node types:5. Frontend State Management
Pinia stores manage application state:6. Design System
Centralized components ensure consistency:Data Flow
Workflow Execution Flow
Node Communication
Nodes communicate through connections:Workflow Traversal
Use graph traversal utilities fromn8n-workflow:
Module Organization
Backend Modules
Features are organized into modules with clear boundaries:Frontend Modules
Vue components follow feature-based organization:Development Workflows
Each package can be developed independently:Key Conventions
TypeScript Best Practices:
- Never use
anytype - use proper types orunknown - Avoid type casting with
as- use type guards instead - Define shared interfaces in
@n8n/api-typesfor FE/BE communication
Error Handling:
- Use
UnexpectedError,OperationalError, orUserError - Deprecated:
ApplicationErrorclass
Frontend Development:
- All UI text must use i18n - add translations to
@n8n/i18n - Use CSS variables - never hardcode spacing as px values
data-testidmust be a single value (no spaces)
Next Steps
- Learn about testing practices
- Review contribution guidelines
- Explore the development setup guide