n8n Workflow Automation
Relevant source files
The following files were used as context for generating this wiki page:
n8n Workflow Automation serves as the orchestration engine for the Nyansa AI "second brain" project. It automates tasks, manages AI agents, and connects various internal services such as Ollama for local LLM inference and Qdrant for vector storage. The system integrates directly with an Obsidian vault to process notes and provide a retrieval-augmented generation (RAG) capability.
Sources: README.md:10-12, README.md:15-17, README.md:92-94
System Architecture
The n8n service operates within an internal Docker network named nyansa. It communicates with other containers using standard internal DNS resolution. The architecture isolates the workflow engine from direct public exposure, requiring a reverse proxy (Caddy) or an SSH tunnel for editor access.
The diagram above shows how n8n interacts with internal services and host storage to execute workflows.
Sources: README.md:38-70, docker-compose.yml:9-25
Core Components
| Component | Service Name | Role |
|---|---|---|
| Workflow Engine | nyansa-n8n | Executes automation logic and manages AI agents. |
| Database | nyansa-postgres | Stores workflow state, execution history, and internal data. |
| Import Tool | nyansa-n8n-import | Bootstraps the environment by importing demo credentials and workflows on first start. |
| Vault Access | /data/obsidian-vault | Provides read/write access to the host Obsidian vault via bind mount. |
Sources: docker-compose.yml:105-156, README.md:92-94
Workflow Initialization
The project uses a dedicated container, nyansa-n8n-import, to ensure a consistent initial state. This container checks if workflows already exist in the database. If the database is empty, it imports credentials from /demo-data/credentials and workflows from /demo-data/workflows.
This sequence ensures that demo data is only loaded once during the initial setup.
Sources: docker-compose.yml:105-120, README.md:17-19
Configuration and Security
n8n is configured using environment variables defined in the docker-compose.yml file and a local .env file. Security is maintained by limiting the environment variables visible to n8n and disabling workflow access to the container's environment.
Key Environment Variables
| Variable | Description | Security Note |
|---|---|---|
N8N_ENCRYPTION_KEY | Encrypts stored credentials. | Must be set in .env. |
CREDENTIALS_OVERWRITE_DATA | Injects secrets into credentials at runtime. | Used for the Qdrant API key. |
N8N_BLOCK_ENV_ACCESS_IN_NODE | Prevents workflows from reading environment variables. | Enhances security of the host environment. |
N8N_SECURE_COOKIE | Ensures cookies are sent over HTTPS. | Set to true by default. |
Sources: docker-compose.yml:33-52, README.md:120-135
Credential Management
n8n uses the CREDENTIALS_OVERWRITE_DATA variable to inject the QDRANT_API_KEY into any credential of type qdrantApi. This method prevents the API key from being stored in the n8n database or checked into Git.
Sources: docker-compose.yml:50-52, README.md:129-131
Demo Workflow Analysis
The project includes a demo workflow (srOnR8PAY3u4RSwb.json) that illustrates basic local AI integration. It uses a Chat Trigger to initiate the process and a Basic LLM Chain to process inputs.
Node Configuration
- Chat Trigger: Acts as a webhook for receiving chat messages.
- Basic LLM Chain: Orchestrates the interaction between the user input and the model.
- Ollama Chat Model: Configured to use the
qwen2.5:3bmodel. It connects to the internal Ollama service via theollamaApicredential.
Sources: n8n/demo-data/workflows/srOnR8PAY3u4RSwb.json:10-70
Integration with memory-api
n8n interacts with the memory-api service to perform RAG operations. It makes HTTP POST requests to the /ingest and /search endpoints using a bearer token defined by MEMORY_API_TOKEN.
- Ingestion: n8n triggers vault parsing and vectorization.
- Search: n8n sends queries to retrieve relevant chunks from the Obsidian vault for AI context.
Sources: services/memory-api/README.md:11-20, README.md:20-25
n8n Workflow Automation provides the central logic layer for the Nyansa project, connecting local inference, vector storage, and file system access into a cohesive private AI system.