Multi-tenant headless CMS powered by Payload CMS v2 with AI content generation for all KodaLabs projects.
Centralized content management system that:
- Serves multiple websites from one installation (PJ-CLT Calculator, KodaLabs main site, future projects)
- AI-powered content generation using Claude API for automated article creation
- Multi-language support (Portuguese, English, Spanish)
- Human review workflow for quality assurance
- Next.js ISR integration for optimal performance
- CMS: Payload CMS v2.30.3 (standalone Express server)
- Database: PostgreSQL 16
- Editor: Slate Rich Text
- Runtime: Node.js 20+
- Language: TypeScript 5.9.3
- Deployment: Docker + Traefik
Each site has:
- Unique API key for content access
- Separate content collections
- Custom webhook for deployment
- Language-specific content
- Node.js 20+
- Docker & Docker Compose
- Git
-
Clone the repository
git clone <repository-url> cd kodalabs-cms
-
Install dependencies
npm install
-
Configure environment
cp .env.example .env # Edit .env with your configuration -
Generate secrets
# Payload secret (min 32 chars) node -e "console.log('PAYLOAD_SECRET=' + require('crypto').randomBytes(32).toString('hex'))" # PostgreSQL password node -e "console.log('POSTGRES_PASSWORD=' + require('crypto').randomBytes(16).toString('hex'))"
-
Start development server
# With Docker (recommended) npm run docker:dev -
Access CMS Admin
- URL: http://localhost:3001/admin
- Create your first admin user
- Start managing content!
npm run dev # Start development server (requires PostgreSQL)
npm run build # Build Payload admin panel + compile TypeScript
npm run serve # Run production build
npm run generate:types # Generate TypeScript types from collectionsnpm run ai:create-post # Generate blog post with AI (draft mode)npm run docker:build # Build production Docker image
npm run docker:dev # Start development containers (app + PostgreSQL)
npm run docker:prod # Start production containers- Sites - Multi-tenant site configuration with API keys
- Posts - Blog articles with AI-generated metadata
- Categories - Hierarchical content taxonomy
- Tags - Content labeling and filtering
- Media - File uploads and images
- Users - Admin and editor accounts
All content supports:
- Portuguese (pt) - default
- English (en)
- Spanish (es)
Required configuration (see .env.example):
# Server
PORT=3001
PAYLOAD_SECRET=<min-32-chars> # Generate with crypto.randomBytes(32)
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3001
NODE_ENV=development
# Database (PostgreSQL 16)
DATABASE_URL=postgresql://kodalabs_cms:password@localhost:5432/kodalabs_cms
POSTGRES_DB=kodalabs_cms
POSTGRES_USER=kodalabs_cms
POSTGRES_PASSWORD=<16-chars> # Generate with crypto.randomBytes(16)
# Development (Docker)
PAYLOAD_CONFIG_PATH=src/payload.config.ts
CI=true # Auto-accept database migrations
PAYLOAD_DROP_DATABASE=false
# CORS (for frontend apps)
CORS_ORIGIN_PJ_CLT=https://pjouclt.com.br
CORS_ORIGIN_KODALABS=https://kodalabs.dev
# AI Content Generation (Optional)
ANTHROPIC_API_KEY=sk-ant-your-key
# Webhooks (Optional)
WEBHOOK_PJ_CLT=https://api.vercel.com/v1/integrations/deploy/xxx# Get published posts for a site
GET /api/posts?where[site][equals]=site-id&where[status][equals]=published
Headers: Authorization: Bearer {site-api-key}# Login
POST /api/users/login
Body: {"email": "[email protected]", "password": "password"}
# Create post
POST /api/posts
Headers: Authorization: Bearer {jwt-token}
Body: {post-data}GET /api/health
Response: {
"status": "healthy",
"timestamp": "2025-10-21T09:53:09.000Z",
"version": "1.0.0",
"environment": "development"
}# Start development environment (app + PostgreSQL)
npm run docker:dev
# Access at: http://localhost:3001/admin# Build production image
npm run docker:build
# Deploy with Traefik networking
npm run docker:prod
# Access at: https://cms.kodalabs.dev/adminComplete technical documentation in CLAUDE.md:
- Payload v2 migration details
- SCSS transpilation fix
- VPS deployment guide
- Troubleshooting guide
- API patterns and examples
- Login to CMS admin panel
- Navigate to Sites collection
- Create new site record:
- Name: "Your Site Name"
- Slug: "your-site-slug"
- Domain: "yoursite.com"
- Default language: Select from PT/EN/ES
- Copy the auto-generated API key
- Configure webhook URL (optional)
- Use API key in your frontend application
Manual Creation:
- Login to admin panel
- Navigate to Posts collection
- Create new post
- Select site, category, author
- Write content using Slate rich text editor
- Set status to "published"
- Webhook triggers frontend rebuild
AI-Generated:
# Edit scripts/ai-content-generator.ts with your topic
npm run ai:create-post
# AI creates draft post
# Review in admin panel at /admin
# Approve and publishError: SyntaxError: Invalid or unexpected token in .scss files
Solution: Ensure register-scss-stub.js is loaded (already configured in production):
node -r ./src/register-scss-stub.js dist/server.js# Check PostgreSQL is running
docker ps | grep postgres
# View database logs
docker logs kodalabs-cms-postgres-dev
# Connect to database directly
docker exec -it kodalabs-cms-postgres-dev psql -U kodalabs_cmsProblem: Server stuck on "Is table created or renamed?" prompts
Solution: Set CI=true environment variable (already configured)
# Clean and rebuild
rm -rf dist/ build/ node_modules/
npm install
npm run build# Regenerate types from Payload collections
npm run generate:typeskodalabs-cms/
βββ src/
β βββ collections/ # Payload CMS collections (β
implemented)
β βββ access/ # Access control rules (β
implemented)
β βββ hooks/ # Lifecycle hooks
β βββ fields/ # Reusable field definitions
β βββ payload.config.ts # β
Main Payload v2 configuration
β βββ server.ts # β
Express server with Payload
β βββ register-scss-stub.js # β
SCSS transpilation fix
βββ scripts/ # AI content generation
βββ deployment/docker/ # Production deployment configs
β βββ Dockerfile # β
Multi-stage production build
β βββ docker-compose.dev.yml # β
Development environment
β βββ docker-compose.prod.yml # β
Production with Traefik
βββ build/ # Webpack-compiled admin panel (auto-generated)
βββ dist/ # TypeScript-compiled server (auto-generated)
βββ public/ # Static files and media uploads
βββ package.json
βββ tsconfig.json
βββ CLAUDE.md # β
Complete technical documentation
βββ .env.example
- Phase 1: Repository setup & PostgreSQL migration
- Phase 2: Payload v2 configuration & collections
- Phase 3: SCSS transpilation fix & development environment
- Phase 4: Production deployment configuration
- Phase 5: AI content generation integration
- Phase 6: Multi-site expansion
- Phase 7: Advanced webhooks & automation
- Technical Documentation: See
CLAUDE.md - API Documentation: Built into Payload admin at
/api-docs - Issues: GitHub Issues
- Project: Part of KodaLabs ecosystem
Version: 2.0.0 Status: β Fully Operational - Ready for VPS Deployment CMS: Payload v2.30.3 (standalone Express server) Database: PostgreSQL 16 Environment: Development β | Production β
- β Payload v2 CMS fully operational
- β PostgreSQL database configured
- β Admin panel at http://localhost:3001/admin
- β REST API endpoints
- β All 6 collections implemented
- β Multi-language support (PT/EN/ES)
- β Health check endpoint
- β Docker development environment
- β Production build configuration
- Deploy to VPS (see
CLAUDE.mdfor deployment guide) - Create first admin user
- Configure sites and content
- Integrate with frontend applications
- Enable AI content generation
Developed by KodaLabs | kodalabs.dev