Split View: n8n, Dify, Mermaid 완전 가이드 — AI 에이전트와 다이어그램 자동화
n8n, Dify, Mermaid 완전 가이드 — AI 에이전트와 다이어그램 자동화
들어가며
AI 에이전트 시대가 도래하면서, 단순한 챗봇을 넘어 복잡한 업무를 자동화하는 워크플로우가 핵심 역량이 되고 있습니다. 이 글에서는 세 가지 강력한 도구를 심층적으로 다룹니다.
- n8n -- 오픈소스 워크플로우 자동화 플랫폼
- Dify -- LLM 앱 빌더 플랫폼
- Mermaid -- 코드로 그리는 다이어그램 도구
각 도구의 기본 개념부터 실전 활용까지, 바로 따라 할 수 있는 예제와 함께 설명합니다.
Part 1: n8n -- 오픈소스 워크플로우 자동화
1. n8n이란?
n8n(노드에이트엔)은 오픈소스 워크플로우 자동화 플랫폼입니다. Zapier나 Make(구 Integromat)와 유사하지만, 가장 큰 차별점은 셀프호스팅이 가능하다는 점입니다.
핵심 특징:
| 항목 | 설명 |
|---|---|
| 라이선스 | Fair-code (소스 공개, 상업 사용 가능) |
| 통합 수 | 400개 이상의 서비스 연동 |
| 호스팅 | 셀프호스팅 또는 n8n Cloud |
| AI 지원 | AI Agent, LLM 체인, Tool 노드 내장 |
| UI | 노코드 비주얼 에디터 |
| 커스텀 코드 | JavaScript/Python 코드 노드 지원 |
n8n의 강점은 데이터가 자신의 서버에 머문다는 것입니다. 민감한 데이터를 다루는 기업에서 특히 유용합니다.
2. 설치 방법
Docker로 설치 (권장)
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v n8n_data:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
설치 후 브라우저에서 http://localhost:5678 로 접속하면 됩니다.
Docker Compose로 설치
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=your-secure-password
- N8N_HOST=your-domain.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://your-domain.com/
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
npx로 빠르게 실행
npx n8n
n8n Cloud
셀프호스팅이 부담스럽다면 n8n Cloud를 사용할 수 있습니다. 무료 체험 후 월 20유로부터 시작합니다.
3. AI 에이전트 워크플로우 구성
n8n의 2024-2025년 가장 큰 업데이트는 AI 에이전트 기능입니다. LangChain 기반으로 구현되어 있으며, 노코드로 AI 에이전트를 만들 수 있습니다.
AI 에이전트의 핵심 구성 요소
graph TD
A[트리거 노드] --> B[AI Agent 노드]
B --> C[LLM 모델]
B --> D[Tool 노드들]
B --> E[Memory 노드]
D --> D1[웹 검색]
D --> D2[DB 조회]
D --> D3[API 호출]
D --> D4[코드 실행]
E --> E1[Window Buffer Memory]
E --> E2[Postgres Chat Memory]
OpenAI / Claude 노드 연결
n8n에서 LLM을 사용하려면 먼저 Credentials를 설정해야 합니다.
- 설정(Settings) 에서 Credentials 메뉴로 이동
- OpenAI API Key 또는 Anthropic API Key 등록
- AI Agent 노드에서 해당 Credential 선택
지원하는 LLM 모델:
- OpenAI GPT-4o, GPT-4 Turbo, o1, o3
- Anthropic Claude 3.5 Sonnet, Claude 3 Opus
- Google Gemini
- Ollama (로컬 LLM)
- Azure OpenAI
Tool 노드 구성
AI 에이전트가 외부 세계와 상호작용하는 방법이 바로 Tool 노드입니다.
주요 Tool 노드 종류:
- SerpAPI / Google Search -- 웹 검색 수행
- HTTP Request -- 외부 API 호출
- Postgres / MySQL -- 데이터베이스 조회
- Code (JavaScript/Python) -- 커스텀 로직 실행
- Calculator -- 수학 연산
- Wikipedia -- 위키백과 검색
- Vector Store -- RAG용 벡터 검색
Tool을 여러 개 연결하면, AI 에이전트가 상황에 따라 적절한 도구를 선택하여 사용합니다.
Memory 노드
대화의 맥락을 유지하려면 Memory 노드가 필요합니다.
- Window Buffer Memory -- 최근 N턴의 대화를 메모리에 저장 (가장 간단)
- Postgres Chat Memory -- PostgreSQL에 대화 기록 영구 저장
- Redis Chat Memory -- Redis에 대화 기록 저장 (빠른 접근)
- Zep Memory -- Zep 서버를 통한 장기 기억 관리
Agent 체인 구성 예시
다음은 n8n에서 AI Agent를 구성하는 워크플로우 JSON 예시입니다. 이 워크플로우는 Webhook으로 질문을 받아 AI Agent가 웹 검색과 계산기를 사용하여 답변합니다.
{
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "ai-agent",
"responseMode": "responseNode"
},
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [240, 300]
},
{
"parameters": {
"agent": "openAiFunctionsAgent",
"systemMessage": "당신은 도움이 되는 AI 어시스턴트입니다. 사용자의 질문에 정확하게 답변하세요.",
"options": {
"maxIterations": 10,
"returnIntermediateSteps": true
}
},
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [480, 300]
},
{
"parameters": {
"model": "gpt-4o",
"options": {
"temperature": 0.7,
"maxTokens": 4096
}
},
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [480, 500]
},
{
"parameters": {},
"name": "SerpAPI",
"type": "@n8n/n8n-nodes-langchain.toolSerpApi",
"position": [620, 500]
},
{
"parameters": {},
"name": "Calculator",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [760, 500]
},
{
"parameters": {
"sessionKey": "={{$json.body.session_id}}",
"contextWindowLength": 10
},
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [480, 700]
}
],
"connections": {
"Webhook": {
"main": [
[{ "node": "AI Agent", "type": "main", "index": 0 }]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]
]
},
"SerpAPI": {
"ai_tool": [
[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]
]
},
"Calculator": {
"ai_tool": [
[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]
]
},
"Window Buffer Memory": {
"ai_memory": [
[{ "node": "AI Agent", "type": "ai_memory", "index": 0 }]
]
}
}
}
4. 실전 예제: 이메일 자동 분류 AI 에이전트
실제 업무에서 유용한 이메일 자동 분류 에이전트를 만들어 봅시다.
워크플로우 흐름
graph LR
A[Gmail 트리거] --> B[AI Agent]
B --> C{분류 결과}
C -->|긴급| D[Slack 알림]
C -->|일반| E[라벨 추가]
C -->|스팸| F[휴지통 이동]
B --> G[구글 시트 기록]
시스템 프롬프트
AI Agent 노드에 다음과 같은 시스템 프롬프트를 설정합니다.
당신은 이메일 분류 전문가입니다. 수신된 이메일을 분석하여 다음 카테고리 중 하나로 분류하세요:
1. URGENT -- 즉시 확인이 필요한 긴급 이메일 (장애 알림, 고객 불만, 계약 관련)
2. NORMAL -- 일반적인 업무 이메일 (회의 요청, 보고서, 정보 공유)
3. SPAM -- 광고, 프로모션, 스팸 메일
응답 형식:
- category: 분류 카테고리 (URGENT, NORMAL, SPAM 중 하나)
- reason: 분류 이유 (한 줄 설명)
- summary: 이메일 요약 (2-3문장)
분류 결과를 처리하는 Switch 노드 설정
Switch 노드에서 AI Agent의 출력값에 따라 분기합니다. URGENT이면 Slack 알림, NORMAL이면 라벨 추가, SPAM이면 휴지통으로 이동합니다.
이 워크플로우를 활성화하면, 새 이메일이 도착할 때마다 AI가 자동으로 분류하고 적절한 조치를 취합니다.
Part 2: Dify -- LLM 앱 빌더
5. Dify란?
Dify는 오픈소스 LLM 앱 개발 플랫폼입니다. 코드 작성 없이 AI 애플리케이션을 만들고 배포할 수 있습니다.
핵심 특징:
| 항목 | 설명 |
|---|---|
| 라이선스 | Apache 2.0 (오픈소스) |
| 앱 유형 | Chatbot, Text Generator, Agent, Workflow |
| RAG 지원 | Knowledge Base 내장 (벡터 검색) |
| 모델 지원 | OpenAI, Anthropic, Hugging Face, Ollama 등 |
| 배포 방식 | Docker 셀프호스팅 또는 Dify Cloud |
| API | RESTful API 자동 생성 |
Dify 설치 (Docker Compose)
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d
설치 후 http://localhost/install 에서 초기 설정을 진행합니다.
6. 주요 기능
Chatbot 모드
대화형 AI 앱을 만들 수 있습니다. 프롬프트 설정, 모델 선택, 변수 정의만으로 완성됩니다.
# 시스템 프롬프트 예시
당신은 고객 서비스 챗봇입니다.
회사명: ABC 테크
제품: 클라우드 호스팅 서비스
규칙:
1. 친절하고 전문적으로 응답하세요
2. 기술 지원 문의는 티켓 시스템으로 안내하세요
3. 가격 관련 문의는 영업팀 연결을 안내하세요
4. 모르는 질문에는 솔직하게 모른다고 답하세요
Agent 모드
Dify의 Agent 모드는 LLM이 도구(Tool)를 사용하여 복잡한 작업을 수행하도록 합니다.
내장 도구 목록:
- 웹 검색 (Google, Bing, DuckDuckGo)
- Wikipedia
- DALL-E 이미지 생성
- Stable Diffusion
- 날씨 정보
- 주식 시세
- 수학 계산
- 웹 스크래핑
- 커스텀 API 도구
Workflow 모드
복잡한 로직을 시각적 흐름도로 구성할 수 있습니다.
graph TD
A[시작] --> B[사용자 입력]
B --> C[LLM: 의도 분석]
C --> D{의도 분류}
D -->|FAQ| E[Knowledge Base 검색]
D -->|번역| F[LLM: 번역 실행]
D -->|요약| G[LLM: 텍스트 요약]
E --> H[LLM: 답변 생성]
F --> I[결과 반환]
G --> I
H --> I
Workflow 모드는 조건 분기, 반복, 병렬 처리를 지원하며, 각 단계에서 서로 다른 LLM 모델을 사용할 수도 있습니다.
7. RAG 파이프라인 구성
RAG(Retrieval-Augmented Generation)는 Dify의 핵심 기능입니다.
RAG 구성 단계
graph LR
A[문서 업로드] --> B[청크 분할]
B --> C[임베딩 생성]
C --> D[벡터 DB 저장]
E[사용자 질문] --> F[질문 임베딩]
F --> G[유사도 검색]
D --> G
G --> H[관련 청크 추출]
H --> I[LLM에 컨텍스트 전달]
I --> J[답변 생성]
Knowledge Base 설정
- 문서 업로드: PDF, TXT, Markdown, HTML, DOCX 지원
- 청크 설정: 청크 크기(기본 500토큰), 오버랩(기본 50토큰)
- 임베딩 모델 선택: OpenAI text-embedding-3-small, Cohere, 로컬 모델
- 벡터 DB: Weaviate, Qdrant, Milvus, PGVector 지원
검색 전략 설정
검색 방식 옵션:
- 의미 검색 (Semantic Search): 벡터 유사도 기반 (기본값)
- 전문 검색 (Full-text Search): BM25 키워드 기반
- 하이브리드 검색 (Hybrid): 의미 + 전문 검색 결합 (권장)
하이브리드 검색 가중치 설정:
- 의미 검색 가중치: 0.7
- 전문 검색 가중치: 0.3
- Top-K: 5 (상위 5개 청크 반환)
- Score Threshold: 0.5 (유사도 0.5 이상만 반환)
8. Dify vs LangChain vs n8n 비교
| 기준 | Dify | LangChain | n8n |
|---|---|---|---|
| 유형 | LLM 앱 빌더 | LLM 프레임워크 | 워크플로우 자동화 |
| 인터페이스 | 웹 UI (노코드) | 코드 (Python/JS) | 웹 UI (노코드) |
| RAG 지원 | 내장 (Knowledge Base) | 코드로 구현 | 벡터 스토어 노드 |
| Agent | 내장 Agent 모드 | 코드로 구현 | AI Agent 노드 |
| 통합 수 | 제한적 (API 위주) | 방대한 생태계 | 400개 이상 서비스 |
| 학습 곡선 | 낮음 | 높음 | 중간 |
| 커스터마이징 | 중간 | 매우 높음 | 높음 |
| 배포 | Docker / Cloud | 직접 구현 | Docker / Cloud |
| 적합 대상 | 빠른 AI 앱 프로토타이핑 | 깊은 커스터마이징 필요 시 | 서비스 간 연동 자동화 |
| 가격 (셀프호스팅) | 무료 | 무료 | 무료 |
추천 시나리오:
- Dify -- 빠르게 RAG 챗봇이나 AI 앱을 만들고 싶을 때
- LangChain -- 복잡한 AI 파이프라인을 코드로 세밀하게 제어하고 싶을 때
- n8n -- AI를 포함한 다양한 서비스 간 연동 자동화가 필요할 때
세 도구를 함께 사용하는 것도 좋은 전략입니다. 예를 들어, Dify로 RAG 앱을 만들고, n8n으로 트리거와 후처리를 자동화할 수 있습니다.
Part 3: Mermaid -- 코드로 그리는 다이어그램
9. Mermaid 문법 기초
Mermaid는 텍스트 기반 다이어그램 도구입니다. 코드를 작성하면 자동으로 다이어그램이 렌더링됩니다.
Mermaid의 장점:
- 코드로 관리하므로 버전 관리(Git) 가능
- GitHub, GitLab, Notion, Obsidian 등에서 네이티브 지원
- 별도 도구 설치 없이 마크다운 내 즉시 렌더링
- AI가 다이어그램을 자동 생성 가능
지원하는 다이어그램 유형
| 유형 | 키워드 | 용도 |
|---|---|---|
| 플로우차트 | flowchart / graph | 프로세스 흐름 |
| 시퀀스 다이어그램 | sequenceDiagram | API 호출 흐름 |
| 클래스 다이어그램 | classDiagram | 객체 설계 |
| 상태 다이어그램 | stateDiagram-v2 | 상태 전이 |
| ER 다이어그램 | erDiagram | 데이터베이스 설계 |
| 간트 차트 | gantt | 프로젝트 일정 |
| 파이 차트 | pie | 비율 시각화 |
| 마인드맵 | mindmap | 개념 정리 |
10. 다이어그램 유형별 예시
Flowchart (플로우차트)
가장 기본적이고 자주 쓰이는 다이어그램입니다.
flowchart TD
A[코드 작성] --> B{테스트 통과?}
B -->|Yes| C[코드 리뷰]
B -->|No| D[버그 수정]
D --> A
C --> E{리뷰 승인?}
E -->|Yes| F[메인 브랜치 병합]
E -->|No| G[수정 사항 반영]
G --> C
F --> H[배포]
문법 포인트:
TD는 Top-Down (위에서 아래),LR은 Left-Right (왼쪽에서 오른쪽)- 대괄호
[]는 사각형, 중괄호 모양은 마름모(조건), 괄호()는 둥근 사각형 - 화살표:
-->실선,-.->점선,==>굵은 선
Sequence Diagram (시퀀스 다이어그램)
API 호출 흐름이나 시스템 간 상호작용을 표현합니다.
sequenceDiagram
actor User
participant Frontend
participant API
participant Auth
participant DB
User->>Frontend: 로그인 요청
Frontend->>API: POST /auth/login
API->>Auth: 토큰 검증
Auth-->>API: 검증 결과
alt 인증 성공
API->>DB: 사용자 정보 조회
DB-->>API: 사용자 데이터
API-->>Frontend: 200 OK + JWT 토큰
Frontend-->>User: 대시보드 이동
else 인증 실패
API-->>Frontend: 401 Unauthorized
Frontend-->>User: 오류 메시지 표시
end
문법 포인트:
->>실선 화살표,-->>점선 화살표alt/else/end로 조건 분기loop,opt,par등 다양한 블록 지원
Class Diagram (클래스 다이어그램)
객체 지향 설계를 표현합니다.
classDiagram
class User {
+String name
+String email
-String password
+login() boolean
+logout() void
}
class Post {
+String title
+String content
+Date createdAt
+publish() void
+draft() void
}
class Comment {
+String body
+Date createdAt
+edit(newBody: String) void
}
User "1" --> "*" Post : writes
Post "1" --> "*" Comment : has
User "1" --> "*" Comment : writes
State Diagram (상태 다이어그램)
시스템이나 객체의 상태 전이를 표현합니다.
stateDiagram-v2
[*] --> Draft
Draft --> Review : 제출
Review --> Approved : 승인
Review --> Rejected : 반려
Rejected --> Draft : 수정
Approved --> Published : 배포
Published --> Archived : 보관
Archived --> [*]
state Review {
[*] --> PeerReview
PeerReview --> ManagerReview
ManagerReview --> [*]
}
ER Diagram (엔티티 관계 다이어그램)
데이터베이스 테이블 구조와 관계를 표현합니다.
erDiagram
USER {
int id PK
string name
string email UK
datetime created_at
}
POST {
int id PK
string title
text content
int author_id FK
datetime published_at
}
COMMENT {
int id PK
text body
int post_id FK
int user_id FK
datetime created_at
}
TAG {
int id PK
string name UK
}
POST_TAG {
int post_id FK
int tag_id FK
}
USER ||--o{ POST : "작성"
USER ||--o{ COMMENT : "작성"
POST ||--o{ COMMENT : "포함"
POST ||--o{ POST_TAG : "태깅"
TAG ||--o{ POST_TAG : "태깅"
Gantt Chart (간트 차트)
프로젝트 일정과 진행 상황을 표현합니다.
gantt
title AI 챗봇 개발 프로젝트
dateFormat YYYY-MM-DD
section 기획
요구사항 분석 :done, req, 2026-04-01, 5d
기술 검토 :done, tech, after req, 3d
아키텍처 설계 :active, arch, after tech, 4d
section 개발
백엔드 API :dev1, after arch, 10d
프론트엔드 UI :dev2, after arch, 8d
AI 모델 통합 :dev3, after dev1, 5d
section 테스트
단위 테스트 :test1, after dev3, 3d
통합 테스트 :test2, after test1, 4d
사용자 테스트 :test3, after test2, 5d
section 배포
스테이징 배포 :deploy1, after test3, 2d
프로덕션 배포 :deploy2, after deploy1, 1d
Pie Chart (파이 차트)
비율과 구성을 표현합니다.
pie title LLM 사용 비율 (2026년 1분기)
"GPT-4o" : 35
"Claude 3.5" : 28
"Gemini" : 18
"Llama 3" : 12
"기타" : 7
Mindmap (마인드맵)
개념과 아이디어를 계층적으로 정리합니다.
mindmap
root((AI 자동화))
워크플로우
n8n
셀프호스팅
400+ 통합
Zapier
클라우드 전용
쉬운 사용
LLM 앱
Dify
RAG 내장
노코드
LangChain
코드 기반
유연함
다이어그램
Mermaid
텍스트 기반
Git 친화적
Draw.io
GUI 기반
다양한 도구
11. 실전 활용: 다양한 환경에서 Mermaid 사용하기
GitHub에서 사용
GitHub는 마크다운 파일과 이슈, PR에서 Mermaid를 네이티브로 지원합니다. README.md나 이슈 본문에 Mermaid 코드 블록을 작성하면 자동으로 렌더링됩니다.
```mermaid
graph LR
A[이슈 생성] --> B[브랜치 생성]
B --> C[개발]
C --> D[PR 생성]
D --> E[코드 리뷰]
E --> F[머지]
```
Notion에서 사용
Notion에서는 /mermaid 명령어로 Mermaid 블록을 삽입할 수 있습니다.
또는 코드 블록을 만들고 언어를 Mermaid로 설정하면 됩니다.
블로그에서 사용 (Next.js + MDX)
Next.js 블로그에서는 remark-mermaid 플러그인이나 mermaid.js를 사용하여 렌더링할 수 있습니다.
npm install mermaid
VS Code에서 사용
VS Code에서는 Markdown Preview Mermaid Support 확장을 설치하면, 마크다운 미리보기에서 Mermaid 다이어그램을 실시간으로 확인할 수 있습니다.
Mermaid Live Editor
웹 브라우저에서 https://mermaid.live 에 접속하면 온라인 에디터를 사용할 수 있습니다.
실시간 미리보기와 함께 PNG, SVG 내보내기를 지원합니다.
세 도구를 함께 활용하는 시나리오
시나리오: AI 기반 기술 블로그 자동 생성 파이프라인
graph TD
A[RSS 피드 수집<br/>n8n Trigger] --> B[AI 요약 생성<br/>Dify Agent]
B --> C[다이어그램 코드 생성<br/>Dify Workflow]
C --> D[Mermaid 렌더링<br/>n8n Code Node]
D --> E[블로그 포스트 생성<br/>n8n HTTP Request]
E --> F[GitHub PR 자동 생성<br/>n8n GitHub Node]
F --> G[Slack 알림<br/>n8n Slack Node]
파이프라인 설명:
- n8n이 RSS 피드에서 새 기술 글을 감지합니다
- Dify Agent가 원문을 읽고 핵심 내용을 요약합니다
- Dify Workflow가 요약 내용을 바탕으로 Mermaid 다이어그램 코드를 생성합니다
- n8n Code 노드에서 Mermaid를 SVG로 렌더링합니다
- n8n이 마크다운 블로그 포스트를 조합하여 GitHub에 PR을 생성합니다
- 모든 과정이 끝나면 Slack으로 알림을 보냅니다
시나리오: 시스템 모니터링 대시보드 자동 업데이트
sequenceDiagram
participant Cron as n8n 스케줄러
participant Prom as Prometheus API
participant Dify as Dify Agent
participant Mermaid as Mermaid 렌더러
participant Wiki as Confluence Wiki
Cron->>Prom: 메트릭 수집 (5분 간격)
Prom-->>Cron: CPU, 메모리, 에러율 데이터
Cron->>Dify: 데이터 분석 요청
Dify-->>Cron: 분석 결과 + 상태 다이어그램 코드
Cron->>Mermaid: 다이어그램 렌더링
Mermaid-->>Cron: SVG 이미지
Cron->>Wiki: 대시보드 페이지 업데이트
팁과 모범 사례
n8n 팁
- 에러 핸들링: Error Trigger 노드를 활용하여 워크플로우 실패 시 알림을 받으세요
- 환경 변수: 민감한 정보(API 키 등)는 환경 변수로 관리하세요
- 실행 데이터 보관: 프로덕션에서는 실행 데이터 보관 기간을 설정하여 디스크를 관리하세요
- Webhook 보안: Webhook 엔드포인트에는 인증 헤더 검증을 추가하세요
Dify 팁
- 프롬프트 버전 관리: Dify는 프롬프트 변경 이력을 자동으로 저장합니다
- 모델 폴백: 주 모델 실패 시 대체 모델로 자동 전환 설정이 가능합니다
- 청크 최적화: RAG 성능은 청크 크기와 오버랩 설정에 크게 의존합니다. 문서 유형에 따라 실험하세요
- API 배포: Dify는 자동으로 REST API를 생성하므로, 외부 서비스에서 쉽게 호출할 수 있습니다
Mermaid 팁
- 테마 설정: init 지시문을 사용하여 다이어그램 테마를 변경할 수 있습니다
- 스타일링: 노드별로 CSS 클래스를 적용할 수 있습니다
- 큰 다이어그램 분할: 다이어그램이 너무 크면 여러 개로 분할하는 것이 가독성에 좋습니다
- 접근성: 다이어그램과 함께 텍스트 설명을 포함하면 접근성이 향상됩니다
마치며
n8n, Dify, Mermaid는 각각 다른 영역에서 강력한 도구이지만, 함께 사용하면 AI 기반 업무 자동화의 완전한 파이프라인을 구축할 수 있습니다.
- n8n으로 트리거, 연동, 자동화의 백본을 구성하고
- Dify로 AI의 두뇌 역할을 하는 LLM 앱을 만들고
- Mermaid로 시스템 구조와 흐름을 문서화합니다
세 도구 모두 오픈소스이며 셀프호스팅이 가능하므로, 데이터 주권과 비용 절감이 중요한 환경에서 특히 유용합니다.
지금 바로 Docker로 n8n과 Dify를 설치하고, Mermaid로 첫 다이어그램을 그려 보세요.
n8n, Dify, and Mermaid Complete Guide -- AI Agent and Diagram Automation
Introduction
With the advent of the AI agent era, complex workflow automation beyond simple chatbots has become a core competency. This article covers three powerful tools in depth:
- n8n -- Open-source workflow automation platform
- Dify -- LLM app builder platform
- Mermaid -- Diagram-as-code tool
We explain each tool from basic concepts to practical applications, with examples you can follow along immediately.
Part 1: n8n -- Open-Source Workflow Automation
1. What is n8n?
n8n (pronounced "nodemation") is an open-source workflow automation platform. Similar to Zapier or Make (formerly Integromat), its biggest differentiator is that it supports self-hosting.
| Feature | Description |
|---|---|
| License | Fair-code (source available, commercial use OK) |
| Integrations | 400+ service connections |
| Hosting | Self-hosted or n8n Cloud |
| AI Support | Built-in AI Agent, LLM chains, Tool nodes |
| UI | No-code visual editor |
| Custom Code | JavaScript/Python code nodes supported |
n8n's strength is that your data stays on your server, making it especially useful for organizations handling sensitive data.
2. Installation
Docker Installation (Recommended)
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v n8n_data:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
After installation, access http://localhost:5678 in your browser.
Docker Compose Installation
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=your-secure-password
- N8N_HOST=your-domain.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://your-domain.com/
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Quick Start with npx
npx n8n
3. AI Agent Workflow Configuration
The biggest update to n8n in 2024-2025 is its AI Agent functionality. Built on LangChain, it allows creating AI agents with no code.
Core Components of an AI Agent
The AI Agent node connects to LLM models, Tool nodes (web search, DB queries, API calls, code execution), and Memory nodes (Window Buffer Memory, Postgres Chat Memory, Redis Chat Memory).
Tool Node Configuration
Tool nodes are how AI agents interact with the external world.
Key Tool node types:
- SerpAPI / Google Search -- Web search
- HTTP Request -- External API calls
- Postgres / MySQL -- Database queries
- Code (JavaScript/Python) -- Custom logic execution
- Calculator -- Mathematical operations
- Wikipedia -- Wikipedia search
- Vector Store -- Vector search for RAG
When multiple tools are connected, the AI agent selects the appropriate tool based on the situation.
4. Practical Example: Email Auto-Classification AI Agent
An email auto-classification agent useful in actual work.
System Prompt
You are an email classification expert. Analyze received emails and classify them into one of the following categories:
1. URGENT -- Emails requiring immediate attention (incident alerts, customer complaints, contract-related)
2. NORMAL -- Regular business emails (meeting requests, reports, information sharing)
3. SPAM -- Advertisements, promotions, spam
Response format:
- category: Classification category (one of URGENT, NORMAL, SPAM)
- reason: Classification reason (one-line explanation)
- summary: Email summary (2-3 sentences)
The Switch node branches based on the AI Agent's output. URGENT triggers a Slack notification, NORMAL adds a label, and SPAM moves to trash.
Part 2: Dify -- LLM App Builder
5. What is Dify?
Dify is an open-source LLM app development platform. You can create and deploy AI applications without writing code.
| Feature | Description |
|---|---|
| License | Apache 2.0 (open source) |
| App Types | Chatbot, Text Generator, Agent, Workflow |
| RAG Support | Built-in Knowledge Base (vector search) |
| Model Support | OpenAI, Anthropic, Hugging Face, Ollama, etc. |
| Deployment | Docker self-hosting or Dify Cloud |
| API | Auto-generated RESTful API |
Dify Installation (Docker Compose)
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d
After installation, proceed with initial setup at http://localhost/install.
6. Key Features
Chatbot Mode
Create conversational AI apps with just prompt settings, model selection, and variable definitions.
Agent Mode
Dify's Agent mode enables LLMs to perform complex tasks using tools. Built-in tools include web search, Wikipedia, DALL-E, weather, stocks, math, web scraping, and custom API tools.
Workflow Mode
Build complex logic as visual flowcharts. Workflow mode supports conditional branching, loops, and parallel processing, and different LLM models can be used at each step.
7. RAG Pipeline Configuration
RAG (Retrieval-Augmented Generation) is a core Dify feature.
Knowledge Base Setup
- Document Upload: Supports PDF, TXT, Markdown, HTML, DOCX
- Chunk Settings: Chunk size (default 500 tokens), overlap (default 50 tokens)
- Embedding Model Selection: OpenAI text-embedding-3-small, Cohere, local models
- Vector DB: Supports Weaviate, Qdrant, Milvus, PGVector
Search Strategy Settings
Search method options:
- Semantic Search: Vector similarity based (default)
- Full-text Search: BM25 keyword based
- Hybrid Search: Semantic + Full-text combined (recommended)
Hybrid search weight settings:
- Semantic search weight: 0.7
- Full-text search weight: 0.3
- Top-K: 5 (return top 5 chunks)
- Score Threshold: 0.5 (return only similarity 0.5+)
8. Dify vs LangChain vs n8n Comparison
| Criterion | Dify | LangChain | n8n |
|---|---|---|---|
| Type | LLM app builder | LLM framework | Workflow automation |
| Interface | Web UI (no-code) | Code (Python/JS) | Web UI (no-code) |
| RAG | Built-in Knowledge Base | Implement in code | Vector Store nodes |
| Agent | Built-in Agent mode | Implement in code | AI Agent nodes |
| Integrations | Limited (API-centric) | Vast ecosystem | 400+ services |
| Learning curve | Low | High | Medium |
| Customization | Medium | Very high | High |
| Best for | Rapid AI app prototyping | Deep customization needs | Cross-service automation |
Recommended scenarios:
- Dify -- When you want to quickly build a RAG chatbot or AI app
- LangChain -- When you need fine-grained code control over complex AI pipelines
- n8n -- When you need automation connecting various services including AI
Using all three together is also a great strategy.
Part 3: Mermaid -- Diagrams as Code
9. Mermaid Syntax Basics
Mermaid is a text-based diagram tool. Write code and diagrams are automatically rendered.
Advantages of Mermaid:
- Code-managed, so version control (Git) is possible
- Native support in GitHub, GitLab, Notion, Obsidian, etc.
- Instant rendering within Markdown without installing separate tools
- AI can auto-generate diagrams
Supported Diagram Types
| Type | Keyword | Use |
|---|---|---|
| Flowchart | flowchart / graph | Process flows |
| Sequence Diagram | sequenceDiagram | API call flows |
| Class Diagram | classDiagram | Object design |
| State Diagram | stateDiagram-v2 | State transitions |
| ER Diagram | erDiagram | Database design |
| Gantt Chart | gantt | Project schedules |
| Pie Chart | pie | Ratio visualization |
| Mindmap | mindmap | Concept organization |
10. Diagram Type Examples
Flowchart
The most basic and frequently used diagram.
flowchart TD
A[Write Code] --> B{Tests Pass?}
B -->|Yes| C[Code Review]
B -->|No| D[Fix Bugs]
D --> A
C --> E{Review Approved?}
E -->|Yes| F[Merge to Main]
E -->|No| G[Apply Feedback]
G --> C
F --> H[Deploy]
Syntax points:
TDis Top-Down,LRis Left-Right- Square brackets
[]for rectangles, curly braces for diamonds (conditions), parentheses()for rounded rectangles - Arrows:
-->solid,-.->dotted,==>thick
Sequence Diagram
Represents API call flows and inter-system interactions.
sequenceDiagram
actor User
participant Frontend
participant API
participant Auth
participant DB
User->>Frontend: Login request
Frontend->>API: POST /auth/login
API->>Auth: Token verification
Auth-->>API: Verification result
alt Auth success
API->>DB: Query user info
DB-->>API: User data
API-->>Frontend: 200 OK + JWT token
Frontend-->>User: Navigate to dashboard
else Auth failure
API-->>Frontend: 401 Unauthorized
Frontend-->>User: Show error message
end
ER Diagram
Represents database table structures and relationships.
erDiagram
USER {
int id PK
string name
string email UK
datetime created_at
}
POST {
int id PK
string title
text content
int author_id FK
datetime published_at
}
COMMENT {
int id PK
text body
int post_id FK
int user_id FK
datetime created_at
}
TAG {
int id PK
string name UK
}
POST_TAG {
int post_id FK
int tag_id FK
}
USER ||--o{ POST : "writes"
USER ||--o{ COMMENT : "writes"
POST ||--o{ COMMENT : "contains"
POST ||--o{ POST_TAG : "tagged"
TAG ||--o{ POST_TAG : "tagged"
Gantt Chart
Represents project schedules and progress.
gantt
title AI Chatbot Development Project
dateFormat YYYY-MM-DD
section Planning
Requirements Analysis :done, req, 2026-04-01, 5d
Technical Review :done, tech, after req, 3d
Architecture Design :active, arch, after tech, 4d
section Development
Backend API :dev1, after arch, 10d
Frontend UI :dev2, after arch, 8d
AI Model Integration :dev3, after dev1, 5d
section Testing
Unit Tests :test1, after dev3, 3d
Integration Tests :test2, after test1, 4d
User Testing :test3, after test2, 5d
section Deployment
Staging Deploy :deploy1, after test3, 2d
Production Deploy :deploy2, after deploy1, 1d
11. Practical Usage: Mermaid in Various Environments
GitHub
GitHub natively supports Mermaid in Markdown files, issues, and PRs.
Notion
In Notion, use the /mermaid command to insert a Mermaid block.
VS Code
Install the Markdown Preview Mermaid Support extension to see Mermaid diagrams in real-time in Markdown preview.
Mermaid Live Editor
Access https://mermaid.live in your browser for an online editor with real-time preview and PNG/SVG export.
Using All Three Tools Together
Scenario: AI-Based Tech Blog Auto-Generation Pipeline
- n8n detects new tech articles from RSS feeds
- Dify Agent reads and summarizes the original content
- Dify Workflow generates Mermaid diagram code based on the summary
- n8n Code node renders Mermaid to SVG
- n8n assembles a Markdown blog post and creates a GitHub PR
- A Slack notification is sent when the entire process completes
Tips and Best Practices
n8n Tips
- Error Handling: Use Error Trigger nodes for workflow failure notifications
- Environment Variables: Manage sensitive info (API keys) as environment variables
- Execution Data Retention: Set retention periods in production to manage disk space
- Webhook Security: Add authentication header validation to webhook endpoints
Dify Tips
- Prompt Version Control: Dify automatically saves prompt change history
- Model Fallback: Configure automatic failover to backup models
- Chunk Optimization: RAG performance heavily depends on chunk size and overlap settings
- API Deployment: Dify auto-generates REST APIs for easy external service integration
Mermaid Tips
- Theme Settings: Use init directives to change diagram themes
- Styling: Apply CSS classes per node
- Split Large Diagrams: Break overly large diagrams into multiple smaller ones for readability
- Accessibility: Include text descriptions alongside diagrams for improved accessibility
Conclusion
n8n, Dify, and Mermaid are powerful tools in their respective domains, but when used together they enable building a complete AI-based workflow automation pipeline.
- n8n forms the backbone of triggers, integrations, and automation
- Dify serves as the AI brain by creating LLM apps
- Mermaid documents system structures and flows
All three tools are open source and support self-hosting, making them especially useful in environments where data sovereignty and cost savings matter.
Start now by installing n8n and Dify with Docker, and draw your first diagram with Mermaid.