Salta ai contenuti

Pipeline & Deploy

Questi contenuti non sono ancora disponibili nella tua lingua.

Living Document - Questo documento descrive il flusso di deploy, le variabili d’ambiente e i provider esterni.

main (production)
├── Direct commits (solo per hotfix)
├── Feature branches → PR → main
└── Deploy automatico su Render
dev (development) - Neon Branch
├── Testing & sperimentazione
├── Schema changes validation
└── NO deploy automatico
graph LR
    A[Local Development] --> B[Git Commit]
    B --> C[Git Push to main]
    C --> D[Render Auto-Deploy]
    D --> E[Production Live]

Steps:

  1. Local Dev: Test su http://localhost:3000
  2. Commit: git commit -m "feat: description"
  3. Push: git push origin main
  4. Auto-Deploy: Render rileva il push e fa rebuild
  5. Live: in-1.ai, elements.blacktrails.io, ecc.

Web Service: blacktrails-platform
Region: Frankfurt (EU)
Plan: Starter ($7/month)
Auto-Deploy: Enabled on main branch push

Terminal window
# 1. Install dependencies
npm install
# 2. Build assets (if any)
# (Currently no build step - EJS templates)
# 3. Start server
npm start # → node src/public/server.js

Build Time: ~2-3 minutes

Terminal window
# Render checks:
GET https://in-1.ai/health
# Expected: 200 OK + { status: "healthy" }

VariablePurposeProviderExample
DATABASE_URLPostgreSQL connection (main)Neonpostgresql://user:pass@ep-fancy-dust...
DATABASE_URL_DEVPostgreSQL connection (dev)Neonpostgresql://user:pass@ep-weathered-scene...
ANTHROPIC_API_KEYClaude AI modelsAnthropicsk-ant-api03-...
RESEND_API_KEYEmail serviceResendre_...
JWT_SECRETAuth token signingSelf-generatedrandom-256-bit-string
SESSION_SECRETCookie encryptionSelf-generatedrandom-256-bit-string
NODE_ENVEnvironmentproduction
PORTServer portRender10000 (auto-set)
VariablePurposeDefault
DB_SEARCH_PATHSchema search orderauth,in1,elements,public
LOG_LEVELLogging verbosityinfo
RATE_LIMIT_MAXRate limit max requests100
RATE_LIMIT_WINDOW_MSRate limit window900000 (15 min)
Terminal window
# .env (DO NOT COMMIT TO GIT)
DATABASE_URL=postgresql://localhost:5432/blacktrails_local
DATABASE_URL_DEV=postgresql://user:pass@ep-weathered-scene...
ANTHROPIC_API_KEY=sk-ant-api03-...
RESEND_API_KEY=re_...
JWT_SECRET=local-dev-secret
SESSION_SECRET=local-dev-session-secret
NODE_ENV=development
PORT=3000

Security Note:

  • Real credentials are stored in .env (gitignored)
  • Production secrets are on Render dashboard
  • Sensitive values are also in 1Password (BlackTrails Vault)

ServicePurposePlanCost/MonthCritical
Neon.techPostgreSQL DatabaseFree (with limits)€0✅ Yes
Render.comWeb Service HostingStarter$7✅ Yes
CloudflareDNS, CDN, PagesFree€0✅ Yes
AnthropicAI Models (Claude)Pay-as-you-go~€50✅ Yes
ResendTransactional EmailFree (100/day)€0⚠️ Medium
GitHubCode RepositoryFree (private)€0✅ Yes
VercelDocs Hosting (future)Free€0❌ No

BrandDomainHostingDeploy Trigger
IN-1in-1.aiRendergit push main
Elementselements.blacktrails.ioRendergit push main
Forestforest.blacktrails.ioRendergit push main
gCoregcore.blacktrails.ioRendergit push main
BlackTrailsblacktrails.ioRendergit push main
Docsdocs.blacktrails.ioCloudflare Pagesgit push main (repo: blacktrails-docs)

Note: All brand subdomains run on the SAME Render instance (multi-brand monolith).


library/public/*.md (Git)
↓ (Manual trigger)
npm run sync-library
↓ (Parse frontmatter + MD5 hash)
PostgreSQL: library.documents
↓ (Generate embeddings - future)
PostgreSQL: library.embeddings (pgvector)
↓ (Semantic search)
AI RAG (IN-1, Forest, gCore)

Script: scripts/sync-library.js

Usage:

Terminal window
# Dry run (preview changes)
npm run sync-library -- --dry-run
# Sync to production
npm run sync-library

How it works:

  1. Scans library/public/ for .md files
  2. Parses YAML frontmatter (title, slug, category, author, etc.)
  3. Calculates MD5 hash of content
  4. Upserts into library.documents (create or update if hash changed)
  5. Logs stats (created, updated, skipped, errors)

Triggers:

  • Manual (via npm script)
  • Future: Automatic on Git push (GitHub Actions webhook)

Terminal window
# 1. Test locale
npm run dev
# → http://localhost:3000
# 2. Test IN-1 Rhama generation
# → http://localhost:3000/in1/rhama
# → Avvia esperienza, dialoga 4-5 turni, verifica Rhama
# 3. Test Elements booking
# → http://localhost:3000/elements
# → Verifica disponibilità camere
# 4. Verify database connection
npm run verify-production
Terminal window
# 1. Check health endpoint
curl https://in-1.ai/health
# 2. Check Render logs
# → https://dashboard.render.com/web/[service-id]/logs
# 3. Test critical flows
# → IN-1 Rhama generation
# → Elements booking form
# → Forest gallery load

{
"scripts": {
"start": "node src/public/server.js",
"dev": "nodemon src/public/server.js",
"verify-production": "node scripts/verify-production.js",
"sync-library": "node scripts/sync-library.js",
"generate-embeddings": "node scripts/generate-embeddings.js",
"migrate:haiku-to-rhama": "node scripts/migrate-haiku-to-rhama.js",
"setup-db": "node scripts/setup-production-db.js",
"setup-db:prod": "node -r dotenv/config scripts/setup-production-db.js dotenv_config_path=.env.production",
"translate-rhamas": "node scripts/translate-rhamas.js"
}
}
ScriptPurposeUsage
npm startStart production serverAuto-run by Render
npm run devStart dev server (nodemon)Local development
npm run verify-productionCheck DB connection & dataPre/post-deploy
npm run sync-librarySync docs to databaseAfter doc changes
npm run setup-dbCreate schemas & tablesInitial DB setup

If a deploy breaks production:

  1. Revert commit:
Terminal window
git revert HEAD
git push origin main
  1. Or: Rollback on Render:

    • Go to Render Dashboard
    • Select web service
    • Click “Manual Deploy”
    • Choose previous commit
    • Click “Deploy”
  2. Or: Database rollback (Neon):

    • Go to Neon Console
    • Select blacktrails project
    • Click on main branch
    • Go to “Point in Time Restore”
    • Restore to timestamp before deploy

Recovery Time: ~5 minutes


  • Logs: Render Dashboard → Logs tab
  • Health Check: Manual curl to /health
  • Database: Neon Console → Query Editor
  • UptimeRobot: Ping /health every 5 minutes
  • Sentry: Error tracking & alerts
  • LogTail: Log aggregation
  • Slack Webhook: Deploy notifications

AI Assistant: Quando il processo di deploy cambia (nuovi provider, variabili d’ambiente, script), esegui:

Terminal window
# 1. Analizza i file di configurazione
read_file E:\BLACKTRAILS-PLATFORM\package.json
read_file E:\BLACKTRAILS-PLATFORM\DEPLOY_CHECKLIST.md
list_dir E:\BLACKTRAILS-PLATFORM\scripts
# 2. Aggiorna questo file mantenendo:
# - Tabella provider aggiornata
# - Nuove variabili d'ambiente
# - Nuovi script npm
# - Workflow Git Flow (se cambia)
# 3. NON includere API keys reali (usa nomi variabili)
# 4. Commit con messaggio:
git commit -m "docs(truth): update pipeline flow"

Last Auto-Update: 2025-12-21
Next Review: On infrastructure change
Maintainer: BlackTrails AI Agent
Render Dashboard: dashboard.render.com
Neon Console: console.neon.tech