Lección 7 · Módulo 3: Your AI Operating System on a Private Server
Project: a reusable AI OS blueprint you can deploy for any project
- Package your whole AI OS as one folder
- Separate what stays the same from what changes per client
- Deploy the blueprint for a new client, step by step
Why this matters
Once you have built an AI assistant for one client, a second client usually wants the same thing, and rebuilding from zero can wipe out the profit from the first. A reusable blueprint packages the whole stack into one folder that you copy, fill in with a few client details and deploy again. What stays the same is written once. Only the settings change.
Key ideas
- The blueprint is one folder. It holds a compose file, a Caddyfile, a settings file and your exported workflows. Copying the folder copies the whole system.
- Separate what stays the same from what changes. The compose file and the Caddyfile are identical for every client. Only the settings file (
.env) holds the client name, domain and passwords. - Generate fresh secrets for each client. Random passwords come from the computer, not from you. Example:
secrets.token_urlsafe(16)gives a 22-character password such asq7Xk2mP9..., which is different for every client. - Workflows are templates. Build each one once, export it as JSON, and read client details from settings instead of typing them into nodes. Then import only the workflows each client needs.
- Deploy in the same order every time. Firewall and DNS come first, then the copy, then
docker compose up, then backups and monitoring. A fixed checklist makes the second deployment faster than the first.
Try it before you watch
A client wants the same assistant, and you copy the blueprint folder to their server. Which files do you edit, and which do you leave alone?
Show answerHide answer
Edit only the settings file (.env), filling in the client's name, domain and freshly generated passwords. Leave the compose file, the Caddyfile and the workflow templates unchanged, because they hold nothing personal. This shows that the blueprint works because only one small file differs per client.
Words to know
- VPS: a virtual server, a computer you rent in the cloud that runs 24 hours a day.
- Docker Compose: a tool that starts several programs (containers) together from one description file.
- Caddy: a web server that sits at the front, handles the domain name and fetches the SSL padlock automatically.
- pgvector: an add-on for Postgres that stores documents so an agent can search them by meaning.
- **Environment file (
.env)**: a plain text file of settings such as names and passwords, kept separate from the main configuration. - Template: a reusable version of something, built once and filled in with the details of each new case.
What to watch for
- Notice which lines in the compose file contain client details. The answer is none, and that is why one file can be copied to many servers.
- Follow the message path from the customer through Caddy, n8n, Postgres and Ollama, and back again. Count how many services each message passes through.
- Pay attention to the checklist order, especially why firewall and DNS come before the copy, and why the trap of one shared database fails.
Apréndelo con tu tutor en la pizarra en vivo
Puntos clave del video
One build, many clients
- You built an AI assistant for one client
- A second client wants the same thing
- Starting from zero eats your profit
- A blueprint turns weeks into an afternoon
layout: side
tree:
Blueprint: [Dental clinic, Bakery, Yoga studio]
direction: down
start: none
steps:
- at: "Picture this"
note: "One build, many clients"
- at: "as a blueprint"
show: Blueprint
- at: "dental clinic"
show: Dental clinic
- at: "logs new leads"
note: "Messages, bookings and leads"
- at: "second client"
note: "Same blueprint, new client"
- at: "online bakery"
show: Bakery
- at: "zero again"
note: "Starting from zero"
- at: "profit disappears"
note: "Profit disappears"
- at: "one reusable folder"
note: "One folder, copied"
- at: "yoga studio"
show: Yoga studio
- at: "an afternoon"
note: "An afternoon, not two weeks" What you will learn
- Package your whole AI OS as one folder
- Separate what stays the same from what changes per client
- Deploy the blueprint for a new client, step by step
layout: side
tree:
Lesson: [Folder, Rule, Workflows]
direction: down
start: none
steps:
- at: "plan for this lesson"
show: Lesson
- at: "one folder"
show: Folder
- at: "the proxy with SSL"
note: "Proxy, n8n, database, model"
- at: "design rule"
show: Rule
- at: "working workflows"
show: Workflows
- at: "sell again and again"
note: "Something you can sell" The blueprint at a glance
- Caddy: front door with SSL
- n8n: runs every workflow
- Postgres plus pgvector: memory and documents
- Ollama: a local AI model
layout: side
direction: TB
components:
customer: {kind: user, label: Customer}
proxy: {kind: gateway, label: Caddy}
n8n: {kind: service, label: n8n}
db: {kind: database, label: Postgres}
llm: {kind: llm, label: Ollama}
zones:
- {label: Your VPS, contains: [proxy, n8n, db, llm]}
links: [customer->proxy, proxy->n8n, n8n->db, n8n->llm]
steps:
- at: "whole system"
note: "The whole system"
- at: "four services"
note: "Four services, one server"
- at: "rented computer"
note: "A VPS: a computer you rent"
- at: "Caddy is the front door"
show: proxy
- at: "n8n runs your workflows"
show: n8n
- at: "Postgres keeps your memory"
show: db
- at: "Ollama runs the local"
show: llm
- at: "a customer writes in"
show: customer
flow: ["customer>proxy: message", "proxy>n8n", "n8n>db: history", "n8n>llm", "llm>n8n", "n8n>proxy", "proxy>customer: answer"]
- at: "four boxes"
highlight: [proxy, n8n, db, llm] One folder per client
mkdir ai-os
cd ai-os
cp ~/blueprint/docker-compose.yml .
cp ~/blueprint/Caddyfile .
cp ~/blueprint/.env.example .env
cp -r ~/blueprint/workflows . The compose file never changes
services:
caddy:
image: caddy:2
ports: ["80:80", "443:443"]
env_file: .env
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
n8n:
image: n8nio/n8n
env_file: .env
postgres:
image: pgvector/pgvector:pg16
env_file: .env
ollama:
image: ollama/ollama The settings file changes per client
import secrets
def make_env(client, domain):
pw = secrets.token_urlsafe(16)
key = secrets.token_hex(16)
return "\n".join([
f"CLIENT={client}",
f"DOMAIN={domain}",
f"POSTGRES_PASSWORD={pw}",
"DB_TYPE=postgresdb",
"DB_POSTGRESDB_HOST=postgres",
f"DB_POSTGRESDB_PASSWORD={pw}",
f"N8N_ENCRYPTION_KEY={key}",
])
print(make_env("lotus-yoga", "ai.lotusyoga.com")) Workflows as templates
- Build each workflow once, export it as JSON
- Keep client details in settings, not in nodes
- Import the ones each client needs
layout: full
parts:
lib: {chip: Template library}
steps:
- at: "treat each one as a template"
highlight: lib
- at: "Build each workflow once"
note: "Build once, export as JSON"
- at: "into the nodes"
note: "Client details stay out of nodes"
- at: "from settings"
note: "Details come from settings"
- at: "import only the ones"
note: "Import what each client needs"
- at: "a sales report"
spokes: {of: lib, items: [Answer messages, Book appointments, Qualify leads, Send invoices, Sales report]}
- at: "A salon might use two"
note: "Two for a salon, three for a consultant" Worked example: Lotus Yoga
- Phone: answers from timetable and prices
- Server: 4 services, 3 workflows
- Report: every Monday
- Setup: about 2 hours
layout: side
direction: TB
components:
cust: {kind: user, label: Customers}
n8n: {kind: service, label: n8n}
db: {kind: database, label: Postgres}
kb: {kind: file, label: Timetable and prices}
rep: {kind: dashboard, label: Weekly summary}
links: [cust->n8n, n8n->db, n8n->kb, n8n->rep]
steps:
- at: "a small yoga studio"
note: "Lotus Yoga"
- at: "owner's phone"
note: "The owner's phone"
- at: "Customers message"
show: cust
- at: "timetable"
show: kb
- at: "Next, the server"
note: "A VPS with 8 gigabytes of memory"
- at: "running n8n"
show: n8n
- at: "and Postgres"
show: db
- at: "from the blueprint"
note: "Four services, three workflows"
- at: "Finally, the report"
note: "Every Monday"
- at: "summary of bookings"
show: rep
- at: "Total setup time"
note: "About two hours" The deployment checklist
- Same order for every client
- Firewall and DNS before anything else
- Backups and monitoring at handover
layout: full
parts:
lib: {chip: Checklist}
steps:
- at: "whole deployment checklist"
highlight: lib
spokes: {of: lib, items: [Rent VPS, Firewall and DNS, Copy blueprint, Fill settings, Compose and SSL, Backups and monitoring]}
- at: "same order for every client"
note: "Same order for every client"
- at: "Firewall and DNS come before anything else"
note: "Firewall and DNS first"
- at: "Rent the server"
note: "Rent a server, firewall on"
- at: "Leave open only"
note: "Web ports and SSH only"
- at: "set up DNS"
note: "Point the domain at the server"
- at: "Copy the blueprint folder"
note: "Copy the blueprint, fill settings"
- at: "Run docker compose up"
note: "Caddy fetches the SSL certificate"
- at: "switch on backups and monitoring"
note: "Backups and monitoring at handover"
- at: "the same way every time"
note: "Same checklist every time" Common mistake: one server for everyone
- Many clients sharing one database
- One leak exposes every client
- One crash takes everyone down
- Fix: one copy of the blueprint per client
layout: side
direction: TB
components:
clinic: {kind: user, label: Dental clinic}
bakery: {kind: user, label: Bakery}
yoga: {kind: user, label: Yoga studio}
db: {kind: database, label: Shared database}
links: [clinic->db, bakery->db, yoga->db]
steps:
- at: "trap that catches"
note: "The trap"
- at: "one shared database"
show: db
- at: "It works for a while"
note: "Works for now"
- at: "clinic's patient messages"
show: clinic
flow: ["clinic>db: patient messages"]
- at: "bakery's orders"
show: bakery
flow: ["bakery>db: orders"]
- at: "yoga studio's bookings"
show: yoga
flow: ["yoga>db: bookings"]
- at: "single leak"
highlight: [clinic, bakery, yoga]
- at: "fills the disk"
highlight: db
- at: "one crash takes everyone down"
note: "Everyone goes offline"
- at: "leave with their data"
note: "Data stays behind"
- at: "The fix is simple"
note: "One copy per client"
- at: "trust is worth"
note: "Trust is worth far more" Recap
- One folder: compose file, Caddyfile, settings, workflows
- Only the settings file changes per client
- Same checklist, one copy per client
layout: full
parts:
lib: {chip: Blueprint}
steps:
- at: "wrap up"
note: "Recap"
- at: "Your blueprint"
highlight: lib
- at: "compose file"
spokes: {of: lib, items: [Compose file, Caddyfile, Settings, Workflows]}
- at: "only that file changes"
note: "Only settings change per client"
- at: "same checklist"
note: "Same checklist, one copy each"
- at: "sell many times"
note: "Build once, sell many times" Exercise: deploy it twice
- Build your blueprint folder from this module
- Deploy it for two imaginary clients
- Time the second deployment and note each step
layout: full
parts:
lib: {chip: Blueprint folder}
steps:
- at: "Now it's your turn"
note: "Your turn"
- at: "at least two exported workflows"
highlight: lib
- at: "a hair salon"
spokes: {of: lib, items: [Hair salon, Plant shop, Stopwatch, Second deployment]}
- at: "cheap servers"
note: "Cheap servers or test folders"
- at: "Time the second deployment"
note: "Write down every step"
- at: "clearly faster"
note: "Faster the second time"
- at: "finished the module"
note: "Module complete" Transcripción
One build, many clients. Picture this. You built an AI assistant as a blueprint for a dental clinic. It answers customer messages, books appointments and logs new leads, and it took you two weeks. Now a second client, a small online bakery, wants exactly the same thing. Do you start from zero again? Most people do, and that's where the profit disappears. In this final project of the module, you'll turn everything from this module into one reusable folder you copy, fill in and deploy. The next client, a yoga studio, then takes an afternoon instead of two weeks.
What you will learn. Here's the plan for this lesson. First, you'll package the whole stack from this module into one folder. That stack is the proxy with SSL, n8n, the database with memory and documents, and the AI model. Second, you'll learn the design rule of any blueprint: separate what never changes from the few details that change for every client. Third, you'll deploy it for a new client, from an empty server to working workflows. By the end, you'll have something you can sell again and again.
The blueprint at a glance. Let's look at the whole system before we package it. There are four services on one server. That server is a VPS, a rented computer in the cloud. Caddy is the front door: it handles the domain and the SSL padlock. n8n runs your workflows. Then, a moment later, Postgres keeps your memory, the conversations and business data, and with pgvector it also holds your documents for RAG, meaning the agent looks things up in your files first. Ollama runs the local AI model on the server itself. When a customer writes in, the message goes through Caddy to n8n, which reads the history, asks the model and sends the answer back. Every client gets the same four boxes.
One folder per client. The blueprint is just a folder, and a folder is easy to copy. Inside it there are four things. The compose file describes the four services, and it's identical for every client. The Caddyfile is a tiny file for Caddy. It reads the domain from the settings and sends every visitor on to n8n. The settings file, called dot env, holds everything that's specific to one client. The workflows folder holds your exported n8n workflows as JSON files, which are plain text files describing each workflow. For a new client, you make a fresh folder on their server and copy those four things in. That's the whole setup step, and it takes less than a minute.
The compose file never changes. Here's a trimmed version of the compose file. Docker Compose reads it and starts all four services together with one command. Notice what's missing: there's no domain name, no password and no client name anywhere in it. The services that need settings read them from the same dot env file, and Caddy also gets the Caddyfile from the folder. That's the trick. Because the compose file holds nothing personal, you can copy it to fifty servers without editing a single line. The moment you type a client's password into this file, it stops being a blueprint and becomes a one-off build again.
The settings file changes per client. Now the part that does change. This small Python script writes a fresh settings file for one client. It sets the client name and their domain, then creates a strong random database password and a random encryption key for n8n. The database lines tell n8n to use Postgres and give it that same password. Random here means generated by the computer so nobody can guess it, like a new key cut for every front door. Run it once per client and you never reuse a password between clients again. Paste the output into the dot env file, and the client's identity is done.
Workflows as templates. Your workflows follow the same rule, so treat each one as a template. Build each workflow once and export it from n8n as a JSON file. Inside the workflows, don't type the business name or the email address into the nodes. Read them from settings or from a small table instead. Then, for each new client, import only the ones they need. Over this course you built five of them: answering messages, booking appointments, qualifying leads, sending invoices and a sales report. A salon might use two of them, and a consultant might use three.
Worked example: Lotus Yoga. Let's deploy it for a real client, a small yoga studio called Lotus Yoga. Start with the owner's phone. Customers message the studio about class times and prices, and the answer workflow replies from the timetable and price list in the knowledge base. Next, the server: a VPS with 8 gigabytes of memory, running n8n and Postgres. It runs the four services from the blueprint, with three workflows imported for messages, bookings and sales. Finally, the report. Every Monday morning the owner gets a summary of bookings and income. Total setup time: about two hours.
The deployment checklist. Let's walk through the whole deployment checklist, because the sequence matters. It's the same order for every client. Firewall and DNS come before anything else, so they go first. Rent the server and keep the firewall on, the guard that blocks every door you don't need. Leave open only the web ports and SSH, the secure remote login. Then set up DNS, which means pointing the client's domain name at the server's address. Copy the blueprint folder and fill in the settings file. Run docker compose up, and Caddy reads the domain and fetches the SSL certificate on its own. Last, before handover, switch on backups and monitoring, with an uptime check. Keep this checklist the same way every time.
Common mistake: one server for everyone. Here's the trap that catches many beginners. To save money, they put every client on one server with one shared database. It works for a while. Then the clinic's patient messages sit next to the bakery's orders and the yoga studio's bookings. A single leak exposes all of them. Then one bad workflow fills the disk, and one crash takes everyone down, so every client goes offline at once. Clients also can't leave with their data cleanly. The fix is simple: give each client their own copy of the blueprint, ideally on their own server. A server costs a few dollars a month, and trust is worth far more.
Recap. Let's wrap up. Your blueprint, your AI operating system, now fits in one folder: a compose file and a Caddyfile that never change, a settings file that holds each client's details, and a library of workflows. Everything personal lives in the settings, and only that file changes per client, so the rest can be copied freely. And every deployment follows the same checklist, with one separate copy per client so that their data and their uptime stay their own. That's the difference between a project you build once and a product you can sell many times.
Exercise: deploy it twice. Now it's your turn. Build your blueprint folder from this module, with the compose file, the Caddyfile, a settings example and at least two exported workflows. Deploy it for two imaginary clients, say a hair salon and an online plant shop, each with its own settings file. Use cheap servers or two folders on one test machine, just for practice. Time the second deployment with a stopwatch and write down every step you took. If the second one is clearly faster than the first, your blueprint works. And with that, you've finished the module.
Explora las animaciones
Las animaciones del video, exactas y en vivo: reprodúcelas, pausa, arrastra el control deslizante o salta a un paso a tu propio ritmo.
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Responde todas las preguntas y luego comprueba. Apruebas con 70%; puedes intentarlo las veces que quieras.
Resumen de la lección
- Lectura
- Video visto
- Cuestionario aprobado (70%)
- One folder: compose file, Caddyfile, settings, workflows
- Only the settings file changes per client
- Same checklist, one copy per client