Skip to main content

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 in pnpm-workspace.yaml:

Build Orchestration

Turbo (turbo.json) orchestrates builds with dependency awareness:
The ^ 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

Development Packages

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 from n8n-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 any type - use proper types or unknown
  • Avoid type casting with as - use type guards instead
  • Define shared interfaces in @n8n/api-types for FE/BE communication
Error Handling:
  • Use UnexpectedError, OperationalError, or UserError
  • Deprecated: ApplicationError class
Frontend Development:
  • All UI text must use i18n - add translations to @n8n/i18n
  • Use CSS variables - never hardcode spacing as px values
  • data-testid must be a single value (no spaces)

Next Steps