https://github.com/triptyk/tpk-n8n-ai
Base folder for a n8n local installation
https://github.com/triptyk/tpk-n8n-ai
Last synced: 10 months ago
JSON representation
Base folder for a n8n local installation
- Host: GitHub
- URL: https://github.com/triptyk/tpk-n8n-ai
- Owner: TRIPTYK
- License: apache-2.0
- Created: 2025-07-22T08:06:45.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-25T16:09:04.000Z (10 months ago)
- Last Synced: 2025-08-25T17:42:35.692Z (10 months ago)
- Language: Shell
- Size: 3.8 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# n8n AI Docker Environment
## Overview
This Docker project provides a complete self-hosted AI development environment with the following components:
- **n8n**: A workflow automation platform that connects various services and APIs, providing a low-code interface for building AI-powered workflows
- **PostgreSQL**: A powerful, open-source relational database used by n8n to store workflows, credentials, and execution data
- **Qdrant**: A vector database for efficient similarity search and AI embeddings storage
- **Ollama**: A framework for running large language models locally, enabling AI capabilities without relying on external APIs
- **Deepseek Coder**: A specialized code generation model (6.7B parameters) designed for programming tasks
This documentation covers how to manage this environment, with focus on:
- Installation and setup of the complete environment
- Connecting to PostgreSQL from external tools like TablePlus
- Backing up your n8n database
- Restoring your n8n database from backups
### System Architecture
The following diagram illustrates how the components connect together:
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Client │ │ n8n │ │ Ollama │
│ Browser ├────►│ Workflow ├────►│ LLM Server │
│ │ │ Automation │ │ (llama3.2) │
│ │ │ │ │ (deepseek) │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
│
▼
┌─────────────────┐ ┌─────────────────┐
│ │ │ │
│ PostgreSQL │ │ Qdrant │
│ Database │ │ Vector DB │
│ │ │ │
└─────────────────┘ └─────────────────┘
```
In this architecture:
- **n8n** is the central workflow automation platform that orchestrates all components
- **PostgreSQL** stores n8n workflows, credentials, and execution data
- **Ollama** provides local LLM capabilities with models like llama3.2 and deepseek-coder
- **Qdrant** stores vector embeddings for similarity search and AI applications
- All components run in Docker containers with proper networking
## Installation
### Prerequisites
- Docker and Docker Compose installed on your system
- Git (optional, for cloning the repository)
### Shared Files
This project includes a shared folder that allows you to share files between your host machine and the n8n container:
- **Host location**: `./shared` (in the project root)
- **Container location**: `/data/shared` (inside the n8n container)
You can place any files in the `./shared` directory that you want n8n to be able to read or write. This is useful for:
- Input files for n8n workflows
- Output files generated by n8n workflows
- Configuration files
- Data files for processing
### Setup Steps
1. **Clone or download the repository**
```bash
git clone https://github.com/TRIPTYK/tpk-n8n-ai.git
cd tpk-n8n-ai
```
2. **Configure environment variables**
Create a `.env` file in the project root or copy from the example:
```bash
cp .env.example .env
```
Edit the `.env` file to set your PostgreSQL credentials:
```
POSTGRES_USER=root
POSTGRES_PASSWORD=password
POSTGRES_DB=n8n
```
3. **Start the environment**
```bash
docker-compose up --profile=cpu -d
```
This will start all services including PostgreSQL, n8n, and other required components.
4. **Verify PostgreSQL is running**
```bash
docker ps | grep postgres
```
You should see the PostgreSQL container running with port 5432 exposed.
## Database Management
### Connecting to PostgreSQL from External Tools
The PostgreSQL database is configured to be accessible from external tools like TablePlus, pgAdmin, or any other PostgreSQL client. This allows you to directly interact with your database for debugging, data exploration, or manual modifications.
#### Connection Details
```
Host: localhost (or 127.0.0.1)
Port: 5432
Username: root (or the value in your .env file's POSTGRES_USER)
Password: password (or the value in your .env file's POSTGRES_PASSWORD)
Database: n8n (or the value in your .env file's POSTGRES_DB)
```
#### Connection Diagram
```
┌─────────────────┐ ┌─────────────────┐
│ │ │ │
│ TablePlus or │ │ PostgreSQL │
│ other DB tool ├─────►│ Container │
│ on your Mac │ │ (port 5432) │
│ │ │ │
└─────────────────┘ └─────────────────┘
```
### Database Backup and Restore
To ensure data safety and enable migration between environments, this project includes scripts for backing up and restoring your n8n database. These scripts connect directly to the PostgreSQL Docker container, so you don't need to have PostgreSQL installed on your host machine.
#### Backup Script
The `backup_n8n_db.sh` script creates a backup of your PostgreSQL database directly from the Docker container.
**Usage:**
```bash
./backup_n8n_db.sh
```
**What it does:**
1. Connects to the PostgreSQL container
2. Creates a SQL dump of your n8n database
3. Saves the backup to a `backups` directory with a timestamp
4. Creates both uncompressed (.sql) and compressed (.gz) versions
**Example output:**
```
Loading environment variables from .env file...
Starting PostgreSQL backup of n8n database...
Using database: n8n
Using username: root
Backup will be saved to: /path/to/project/backups/n8n_backup_20250722_115054.sql
Using PostgreSQL container: tpk-n8n-ai-postgres-1
Backup completed successfully!
Backup saved to: /path/to/project/backups/n8n_backup_20250722_115054.sql
Compressed backup saved to: /path/to/project/backups/n8n_backup_20250722_115054.sql.gz
Done!
```
#### Restore Script
The `restore_n8n_db.sh` script restores your database from a previously created backup.
**Usage:**
```bash
./restore_n8n_db.sh path/to/backup.sql
# OR
./restore_n8n_db.sh path/to/backup.sql.gz
```
**What it does:**
1. Stops the n8n container to prevent connection issues
2. Drops the existing database and creates a fresh one
3. Restores the database from your backup file
4. Restarts the n8n container
**Example:**
```bash
./restore_n8n_db.sh backups/n8n_backup_20250722_115054.sql.gz
```
#### Backup and Restore Flow Diagram
```
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ n8n with │ │ Backup │ │ Backup │
│ PostgreSQL ├────►│ Script ├────►│ Files │
│ Database │ │ │ │ (.sql/.gz) │
│ │ │ │ │ │
└──────┬──────┘ └─────────────┘ └──────┬──────┘
│ │
│ │
│ ┌─────────────┐ │
│ │ │ │
└─────►│ Restore │◄─────────────────┘
│ Script │
│ │
└─────────────┘
```
### Best Practices
#### Backup and Restore Flow Diagram
```
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ n8n with │ │ Backup │ │ Backup │
│ PostgreSQL ├────►│ Script ├────►│ Files │
│ Database │ │ │ │ (.sql/.gz) │
│ │ │ │ │ │
└──────┬──────┘ └─────────────┘ └──────┬──────┘
│ │
│ │
│ ┌─────────────┐ │
│ │ │ │
└─────►│ Restore │◄─────────────────┘
│ Script │
│ │
└─────────────┘
```
### Best Practices
- **Regular Backups**: Schedule regular backups of your database, especially before making significant changes to your workflows or configurations.
- **Version Control**: Keep your backup files in version control or a secure storage location.
- **Test Restores**: Periodically test the restore process to ensure your backups are valid and the process works as expected.
- **Backup Before Updates**: Always create a backup before updating n8n or any of its components.
## 💬 Support
Join the conversation in the [n8n Forum](https://community.n8n.io/), where you
can:
- **Share Your Work**: Show off what you’ve built with n8n and inspire others
in the community.
- **Ask Questions**: Whether you’re just getting started or you’re a seasoned
pro, the community and our team are ready to support with any challenges.
- **Propose Ideas**: Have an idea for a feature or improvement? Let us know!
We’re always eager to hear what you’d like to see next.