$ show n8n-io/n8n
n8n is a production-grade workflow automation and AI agent platform. In production, it runs as a Node.js Express server with a Vue 3 frontend, executing user-defined workflows composed of nodes (triggers, actions, LLM calls). Workflows can be triggered manually, via webhooks, schedules, or events, and the execution engine handles concurrency, retries, errors, and data passing between nodes. The platform supports AI agents through an SDK that manages LLM calls, tool execution, memory, conversation loops, and MCP (Model Context Protocol) integration, enabling autonomous multi-step agents. Architecturally, the monorepo is organized into backend (packages/cli, packages/core, @n8n/engine), frontend (packages/frontend/editor-ui), database layer (@n8n/db with TypeORM), AI/agent packages (@n8n/agents, @n8n/ai-utilities, @n8n/instance-ai), and a vast node/credential library (packages/nodes-base, @n8n/nodes-langchain). Dependency injection is handled by @n8n/di, controllers are decorated with @RestController, and database models use a forked TypeORM. The system supports multiple database backends (PostgreSQL, SQLite) and can scale with Redis and worker processes. Key data flows: Workflow definitions are persisted in the database with version history. Execution data (inputs, outputs, binary data) is stored for monitoring and replay. The AI agent runtime uses a persistent message store for conversation memory, supports checkpoint/restore for long-running agents, and integrates with external LLMs (OpenAI, Anthropic, etc.) via a unified model factory. The platform exposes REST APIs for CRUD operations on workflows, credentials, users, and executions, as well as WebSocket push for real-time UI updates. External dependencies include a database, optional Redis for scaling, and numerous third-party services via nodes and credentials.
The LLM identified 4 files worth highlighting for reuse:
A custom LLM failed attempt handler that classifies errors (rate limit, context length, auth, etc.) and applies exponential backoff with jitter. It can be extracted into any AI project requiring resilient LLM retry logic.
Manages an in-memory vector store with configurable size limits, memory usage tracking, and automatic cleanup of least-recently-used vectors. Reusable in any context requiring a bounded in-memory vector store.
A test harness for n8n nodes that sets up credential fixtures, loads workflow JSON files, mocks HTTP via nock, and executes nodes in a controlled environment. The pattern is portable to any node-based integration testing.
Adapts tool definitions into the agent runtime, supporting a middleware chain for approval, validation, and error handling. Demonstrates a clear composable pattern for building agent tool execution pipelines.