Frontend Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- packages/frontend/editor-ui/src/constants.ts
- packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts
- packages/frontend/@n8n/design-system/package.json
- packages/@n8n/extension-sdk/package.json
- packages/cli/package.json
- packages/frontend/@n8n/chat/package.json
- packages/@n8n/config/src/index.ts
- packages/nodes-base/nodes/Webhook/Webhook.node.json
- packages/nodes-base/nodes/Start/Start.node.json
The n8n frontend architecture is a modern, modular system built primarily with Vue.js and TypeScript. It is designed to provide a reactive and interactive user experience for creating, managing, and executing workflows. The core of the frontend is the editor-ui package, which serves as the main application entry point.
The architecture heavily relies on centralized state management using Pinia, a component-based structure, and a dedicated design system package (@n8n/design-system) for a consistent look and feel. The system is extensible through a defined SDK (@n8n/extension-sdk), allowing for the integration of new features and UI components.
Core Technologies and Package Structure
The n8n frontend is built upon a stack of modern web technologies. The project is structured as a monorepo, with distinct packages for different functionalities.
| Package | Description | Key Dependencies |
|---|---|---|
n8n (CLI) | The main package that orchestrates the build and serves the n8n-editor-ui. | n8n-editor-ui, n8n-nodes-base |
n8n-editor-ui | The main workflow editor application. Contains the core UI, views, components, stores, and routing logic. | vue, @n8n/design-system |
@n8n/design-system | A dedicated Vue plugin providing reusable UI components, styles (Sass, Tailwind), and icons. | vue, element-plus |
@n8n/chat | A package for chat-related UI components and functionality. | vue, @n8n/design-system |
@n8n/extension-sdk | Provides the SDK for developing frontend extensions, defining interfaces and exports for frontend modules. | vue, vue-router, zod |
@n8n/n8n-extension-insights | An example of an extension built using the SDK, providing insights functionality. | @n8n/extension-sdk |
Sources: packages/cli/package.json, packages/frontend/@n8n/design-system/package.json, packages/frontend/@n8n/chat/package.json, packages/@n8n/extension-sdk/package.json, packages/extensions/insights/package.json
The following diagram illustrates the high-level dependency relationships between key frontend packages.
This diagram shows how the main n8n CLI package serves the editor-ui, which in turn consumes other specialized packages like the design-system and extension-sdk.
Sources: packages/cli/package.json:110-111, packages/frontend/@n8n/design-system/package.json, packages/frontend/@n8n/chat/package.json, packages/@n8n/extension-sdk/package.json, packages/extensions/insights/package.json
State Management with Pinia
State management is handled by Pinia. The application uses a modular store pattern, where different stores are responsible for specific domains of the application state. Test files show the usage of stores like useUIStore for managing UI state (e.g., modals) and useVersionsStore for handling version information.
This modular approach is evident in component testing, where stores are mocked using createTestingPinia and mockedStore utilities. Components interact with these stores to get data and dispatch actions.
Sources: packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:11,23-25,81-86
Modal Interaction Flow
The sequence diagram below shows how a user interaction in a component (WhatsNewModal) triggers actions in different Pinia stores to manage the application's UI state.
This diagram illustrates the flow for handling user actions within the "What's New" modal, leading to either a page redirection or another modal being opened via the UI store.
Sources: packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:200-207,219-221
UI Components and Modals
The frontend is composed of Vue components. A key UI pattern is the use of modals for various user interactions. A central system manages modals, identified by unique keys.
The constants.ts file defines a large number of these keys, indicating a robust and widely used modal system.
| Modal Key | Purpose |
|---|---|
WHATS_NEW_MODAL_KEY | Displays "What's New" information for a release. |
VERSIONS_MODAL_KEY | Shows version history and update options. |
CREDENTIAL_EDIT_MODAL_KEY | For creating or editing credentials. |
WORKFLOW_SETTINGS_MODAL_KEY | To configure workflow-specific settings. |
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY | Handles installation of community packages. |
SOURCE_CONTROL_PUSH_MODAL_KEY | For pushing changes to source control. |
Sources: packages/frontend/editor-ui/src/constants.ts:40-80, packages/frontend/editor-ui/src/components/WhatsNewModal.test.ts:12,221
Constants and Configuration
A significant amount of frontend configuration is centralized in packages/frontend/editor-ui/src/constants.ts. This file acts as a single source of truth for various static values used throughout the application.
Key Constant Categories
- Modal Keys: Unique identifiers for all modals in the application (e.g.,
ABOUT_MODAL_KEY). - Node Types: String constants for all core and extension node types (e.g.,
WEBHOOK_NODE_TYPE,START_NODE_TYPE). This is crucial for logic that depends on the type of a node. - View Names: An enum
VIEWSdefines all available pages/views for the router (e.g.,VIEWS.WORKFLOW,VIEWS.CREDENTIALS). - Documentation URLs: Centralized URLs for documentation pages, ensuring they can be updated in one place.
- Local Storage Keys: Keys used for persisting UI state and user preferences in the browser's local storage (e.g.,
LOCAL_STORAGE_THEME). - Feature Flags & Experiments: Keys for A/B testing and experimental features (e.g.,
NDV_UI_OVERHAUL_EXPERIMENT).
This centralization simplifies maintenance and reduces the risk of errors from duplicated or inconsistent string literals.
Sources: packages/frontend/editor-ui/src/constants.ts
Node Type Definitions
The constants.ts file provides an exhaustive list of node type identifiers. These are used to differentiate nodes within a workflow and apply specific logic or UI. The definitions also help categorize nodes.
This diagram shows how different node definition files (.node.json) map to their designated categories, which are then referenced by constants in the frontend code.
Sources: packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json:4, packages/nodes-base/nodes/Webhook/Webhook.node.json:4, packages/nodes-base/nodes/Function/Function.node.json:5, packages/nodes-base/nodes/Start/Start.node.json:4, packages/nodes-base/nodes/Set/Set.node.json:4, packages/nodes-base/nodes/Slack/Slack.node.json:4, packages/nodes-base/nodes/Wordpress/Wordpress.node.json:4, packages/nodes-base/nodes/Airtable/Airtable.node.json:4, packages/nodes-base/nodes/Github/Github.node.json:4
Conclusion
The n8n frontend architecture is a well-structured, scalable system that leverages the strengths of the Vue.js ecosystem. Its modular design, with clear separation of concerns into packages for UI (editor-ui), styling (design-system), state (Pinia stores), and extensions (extension-sdk), facilitates both maintenance and future development. The extensive use of constants for keys, node types, and URLs ensures consistency and simplifies updates across the entire application.