Skip to content

Manas-Kenge/n8n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

n8n — Visual Workflow Automation Platform

An open-source workflow automation platform inspired by n8n. Build automations visually with a drag-and-drop canvas, connect services like Telegram and Gmail, and run AI-powered workflows.

Demo

n8n-demo.mp4

Architecture

Web (Next.js :3000)
  ↕ HTTP REST  →  Server (Express :8000)
  ↕ WebSocket       ↓
                Redis "tasks" list (BLPOP)
                    ↓
               Worker (Bun)
                    ↓ Redis pub/sub "updates:<workflowId>"
                    ↑ Server WebSocketManager → Web
                    ↓
               PostgreSQL (via Server/Prisma)

The monorepo has three packages:

Package Role
web/ Next.js frontend — visual workflow editor
server/ Express API — workflow storage, credential resolution, execution orchestration
worker/ Bun process — pops tasks from Redis queue and executes node functions

Tech Stack

Layer Stack
Frontend Next.js 15, React 19, Tailwind CSS v4, React Flow (@xyflow/react)
State Zustand, TanStack Query
Backend Express 5 on Bun
Worker Bun runtime, LangChain, Google Gemini
Database PostgreSQL + Prisma ORM
Queue Redis (list for tasks, pub/sub for status updates)
Real-time ws WebSocket library
Email Resend SDK
AI LangChain + @langchain/google-genai

Prerequisites

  • Bun v1.2+
  • Docker and Docker Compose (for PostgreSQL)
  • Redis running locally on port 6379
  • A Resend account for Gmail nodes
  • A Telegram bot token for Telegram nodes
  • A Google API key for AI agent nodes

Setup

1. Clone

git clone https://github.com/Manas-Kenge/n8n.git
cd n8n

2. Install dependencies

bun install          # root dev deps (concurrently)
cd server && bun install
cd ../worker && bun install
cd ../web && bun install

3. Start PostgreSQL

cd server
docker compose up -d

Default credentials: myuser / mysecretpassword / db: mydb / port: 5432

4. Environment variables

server/.env

DATABASE_URL="postgresql://myuser:mysecretpassword@localhost:5432/mydb"
RESEND_API_KEY=your_resend_api_key   # fallback if not set per-credential
PORT=8000

web/.env.local

NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000

worker/.env

GOOGLE_API_KEY=your_google_api_key   # required only for AI agent nodes
REDIS_URL=redis://localhost:6379

5. Push database schema

cd server
npx prisma db push
npx prisma generate

Always use prisma db push — not prisma migrate dev. See CLAUDE.md for details.

6. Start all services

# From repo root
bun run dev:all          # server + worker + web

# Or individually
bun run dev:backend      # server + worker only
bun run dev:server       # server only
bun run dev:worker       # worker only
bun run dev:web          # web only
Service URL
Web http://localhost:3000
Server http://localhost:8000

Usage

  1. Open http://localhost:3000
  2. Click New Workflow on the dashboard
  3. Drag nodes from the left panel onto the canvas
  4. Connect nodes by dragging from one node's handle to another
  5. Click a node to open its configuration panel
  6. Add credentials via Dashboard → Credentials before configuring nodes
  7. Click Save, then Run (or the play button on the Manual node)

Node Types

Node Trigger / Action Credential required
Manual Trigger Trigger — starts the workflow None
Telegram Action — sends a message via Bot API Bot Token
Gmail Action — sends email via Resend Resend API Key (optional, falls back to env)
AI Agent Action — LangChain tool-calling agent Google API Key (via env)

Credentials

Credentials are created at Dashboard → Credentials and stored in PostgreSQL. Each node's configuration panel shows a dropdown of compatible credentials. The credential ID is stored in the node's formData and resolved by the server at execution time.


API Reference

Workflows

Method Endpoint Description
GET /workflows List all workflows
POST /workflows Create new workflow
GET /workflow/:id Get workflow by ID
PUT /workflow/save Save workflow nodes and edges
PUT /workflows/:id/name Rename workflow
DELETE /workflows/:id Delete workflow
POST /workflow/execute/:id Execute workflow

Credentials

Method Endpoint Description
GET /credentials List all credentials
POST /credentials Create credential (returns ID for node formData)
GET /credentials/:workflowId Get credentials for a workflow
DELETE /credentials/:id Delete credential

Adding a New Node Type

  1. Add node config to web/lib/nodes.ts — define credentials, formFields, and modes
  2. Create a node component in web/components/nodes/
  3. Register it in web/components/nodes/NodesLibrary.tsx
  4. Add execution handler in worker/exec/functions/functions.ts
  5. Register the handler in worker/exec/functions/configs.ts

Project Structure

n8n/
├── web/                        # Next.js frontend
│   ├── app/                    # App router pages
│   ├── components/             # React components
│   │   ├── nodes/              # Node-specific components
│   │   └── ui/                 # shadcn/ui components
│   ├── hooks/                  # Custom hooks (WebSocket, etc.)
│   ├── lib/                    # Node configs, utilities
│   ├── store/                  # Zustand stores
│   └── helper/                 # HTTP helpers, form data embedding
├── server/                     # Express API
│   ├── execution/              # WorkFlowExecutor (BFS orchestration)
│   ├── helper/                 # Node serialization
│   ├── prisma/                 # Schema and Prisma client
│   ├── validations/            # Zod schemas
│   └── websocket.ts            # WebSocketManager
├── worker/                     # Task executor
│   ├── exec/
│   │   ├── agent/              # LangChain AI agent
│   │   └── functions/          # Node execution handlers
│   ├── index.ts                # Redis BLPOP consumer loop
│   ├── redis.ts                # Redis pub/sub helpers
│   └── resend.ts               # Email sending via Resend
└── README.md

Acknowledgements

About

Workflow automation platform with AI agents, real-time execution, and multi-service integrations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors