High-Level Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- packages/nodes-base/nodes/Webhook/Webhook.node.json
- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json
- packages/nodes-base/nodes/HtmlExtract/test/workflow.dotNotation.json
- packages/nodes-base/nodes/Github/Github.node.json
- packages/nodes-base/nodes/Slack/Slack.node.json
- packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts
- packages/frontend/editor-ui/src/constants.ts
- packages/nodes-base/nodes/Function/Function.node.json
- packages/nodes-base/nodes/If/If.node.json
- packages/nodes-base/nodes/Start/Start.node.json
The n8n project is a workflow automation tool with a modular architecture. It enables users to connect various applications and services through a visual, node-based editor. The system is fundamentally composed of a backend engine for executing workflows, a frontend user interface for creating and managing them, and an extensive library of nodes that represent specific operations or integrations.
The architecture is designed around the concept of workflows, which are JSON-based definitions of interconnected nodes. Each node performs a specific task, such as triggering a workflow, manipulating data, or interacting with an external API. This node-based design allows for high extensibility, as new functionality can be added by creating new nodes.
Core Components
The n8n application is divided into several key components, primarily the frontend UI, the backend server, and the node packages.
Frontend (Editor UI)
The frontend is a Vue.js single-page application that provides the visual workflow editor. It is responsible for rendering the canvas where users can add, connect, and configure nodes. State management is handled by Pinia, with dedicated stores for UI state (useUIStore) and version management (useVersionsStore). The UI is composed of various components, including a modal system for user interactions like viewing "What's New" updates or managing credentials.
Sources: packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:9, packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:11
The diagram below illustrates the interaction flow when a user interacts with a UI element that triggers a modal.
This diagram shows a typical frontend interaction where a user action in a Vue component dispatches an action to a Pinia store, which in turn updates the application's state to render a modal.
Sources: packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:200-202, [packages/frontend/editor-ui/src/constants.ts:46]
Nodes (n8n-nodes-base)
Nodes are the fundamental building blocks of n8n workflows. Each node is defined by a .node.json file that specifies its properties, including its name, category, input parameters, and documentation links. This declarative JSON structure makes it straightforward to define new integrations and logic.
Nodes are categorized to help users find them in the editor. Common categories include Core Nodes, Development, Communication, and Data & Storage. Core nodes are further divided into subcategories like Helpers, Data Transformation, and Flow.
The following table lists some key node types and their functions:
| Node Type | Identifier | Category | Description |
|---|---|---|---|
| Start | n8n-nodes-base.start | Core Nodes | The entry point for a manually executed workflow. |
| Webhook | n8n-nodes-base.webhook | Core Nodes | Triggers a workflow when an HTTP request is received. |
| HTTP Request | n8n-nodes-base.httpRequest | Core Nodes | Makes a generic HTTP request to any API. |
| IF | n8n-nodes-base.if | Core Nodes | Implements binary conditional logic to route data. |
| Function | n8n-nodes-base.function | Core Nodes | Executes custom JavaScript code. |
| Set | n8n-nodes-base.set | Core Nodes | Sets or modifies data fields for subsequent nodes. |
| Slack | n8n-nodes-base.slack | Communication | Interacts with the Slack API. |
| Github | n8n-nodes-base.github | Development | Interacts with the GitHub API. |
Sources: packages/nodes-base/nodes/Start/Start.node.json:2, packages/nodes-base/nodes/Webhook/Webhook.node.json:2, packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json:2, packages/nodes-base/nodes/If/If.node.json:2, packages/nodes-base/nodes/Function/Function.node.json:2, packages/nodes-base/nodes/Set/Set.node.json:2, packages/nodes-base/nodes/Slack/Slack.node.json:2, packages/nodes-base/nodes/Github/Github.node.json:2
Workflow Structure
An n8n workflow is represented as a JSON object. This object contains two primary keys: nodes and connections. The nodes array defines each node in the workflow, including its type, parameters, position on the canvas, and a unique ID. The connections object defines the data flow, mapping the output of one node to the input of another.
The diagram below visualizes the structure of a sample workflow.
This flow represents a test workflow where a manual trigger provides mock HTML data. This data is then processed in parallel by an HTML Extract node and a Set node, with the Set node's output being fed into a second HTML Extract node.
Sources: packages/nodes-base/nodes/HtmlExtract/test/workflow.dotNotation.json:4-142
Node Definition Structure
The structure of a node is defined in its corresponding .node.json file. This file acts as a manifest, providing all the necessary metadata for the n8n application to understand and render the node in the editor.
This diagram shows the key properties of a node definition, such as its unique identifier (node), version, categories for the editor, and associated resources like documentation links.
Sources: packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json:2-8, packages/nodes-base/nodes/Webhook/Webhook.node.json:2-8, packages/nodes-base/nodes/Slack/Slack.node.json:2-10
Frontend Constants and Configuration
The frontend application relies on a set of constants to manage its behavior, such as identifying nodes, modals, and other key entities. These are centrally located for consistency.
Node Type Constants
Specific node types are referenced in the frontend code using string constants. This avoids magic strings and allows for easier maintenance.
| Constant Name | Value |
|---|---|
START_NODE_TYPE | n8n-nodes-base.start |
WEBHOOK_NODE_TYPE | n8n-nodes-base.webhook |
HTTP_REQUEST_NODE_TYPE | n8n-nodes-base.httpRequest |
IF_NODE_TYPE | n8n-nodes-base.if |
FUNCTION_NODE_TYPE | n8n-nodes-base.function |
SLACK_NODE_TYPE | n8n-nodes-base.slack |
GITHUB_NODE_TYPE | n8n-nodes-base.github |
Sources: packages/frontend/editor-ui/src/constants.ts:182, packages/frontend/editor-ui/src/constants.ts:190, packages/frontend/editor-ui/src/constants.ts:162, packages/frontend/editor-ui/src/constants.ts:165, packages/frontend/editor-ui/src/constants.ts:153, packages/frontend/editor-ui/src/constants.ts:180, packages/frontend/editor-ui/src/constants.ts:208
Modal Keys
The modal system uses unique keys to identify and manage different modals that can be displayed to the user.
| Constant Name | Value |
|---|---|
WHATS_NEW_MODAL_KEY | whatsNew |
VERSIONS_MODAL_KEY | versions |
CREDENTIAL_EDIT_MODAL_KEY | editCredential |
WORKFLOW_SETTINGS_MODAL_KEY | settings |
Sources: packages/frontend/editor-ui/src/constants.ts:46, packages/frontend/editor-ui/src/constants.ts:51, packages/frontend/editor-ui/src/constants.ts:77, packages/frontend/editor-ui/src/constants.ts:48
Conclusion
The high-level architecture of n8n is a well-defined, modular system that separates the concerns of workflow execution, user interface, and node functionality. Its reliance on JSON for defining both workflows and nodes provides a flexible and extensible foundation. The frontend leverages modern web technologies like Vue.js and Pinia to create a rich, interactive experience for users, while the backend is responsible for the robust execution of the defined automation logic. This separation allows for independent development and scaling of the different parts of the application.