Katalog AI
Katalog AI is a complete, self-hosted multi-tenant SaaS for fashion brands and textile wholesalers. Upload a phone photo of any garment, choose an AI model, select a backdrop β and receive a studio-quality catalogue image in under 60 seconds. Built for Indian SMBs but architected for any fashion business worldwide.
AI Catalogue Studio
Phone photo β professional catalogue image. No physical studio, model, or retouching required.
Async Pipeline
BullMQ workers + SSE streaming. Renders complete in background β no HTTP timeouts.
Global Billing
Razorpay for regional billing. Stripe for USD/global. Idempotent webhook handling included.
System Requirements
| Requirement | Minimum | Recommended |
|---|---|---|
| Node.js | v22 LTS | v22 LTS or v24 |
| pnpm | v9.x | v10.x |
| PostgreSQL | v15+ (local/Docker) | Neon Serverless PostgreSQL |
| Redis | v7+ (local/Docker) | Upstash Serverless Redis |
| RAM | 1 GB | 2 GB+ |
External Services
You need accounts on these platforms before running Katalog AI in production.
| Service | Purpose | Required | Free Tier |
|---|---|---|---|
| Firebase | Auth β Email OTP + Google OAuth | Yes | β |
| Cloudflare R2 | File storage + CDN delivery | Yes | β 10 GB/mo |
| Upstash Redis | BullMQ job queue + bot state | Yes | β |
| Neon PostgreSQL | Primary database | Yes | β |
| fal.ai | AI image & video generation | Yes | β Pay-per-use |
| Google Vertex AI | Imagen 4 Ultra (premium tier) | Optional | β |
| Razorpay | Regional billing (India/South Asia) | Optional | β Test mode |
| Stripe | USD / global billing | Optional | β Test mode |
Local Installation
1 β Clone & install
git clone <your-repo-url> cd katalog_ai pnpm install
2 β Configure environment
cp .env.example .env # Fill in Firebase, fal.ai, R2, Redis, Postgres credentials
3 β Database setup
pnpm db:migrate pnpm db:seed
4 β Start dev servers
pnpm dev
Installation
There are two ways to install Katalog AI. Both produce the same running stack β pick whichever matches your comfort level.
| Way 1 β UI Wizard | Way 2 β CLI Script | |
|---|---|---|
| Best for | First-time setup, non-technical users | Power users, CI/CD, re-deployments |
| Config method | Browser form β no text editing | Edit infra/docker/.env manually |
| Entry command | make setup | ./deploy.sh up |
| Env file written | infra/docker/.env (auto) | infra/docker/.env.katalog (manual) |
| Uptime Kuma | Guided in Final Guide | Manual β open browser after start |
UI Installation Wizard
A built-in browser wizard at /setup collects every credential and writes infra/docker/.env for you. No terminal text-editing required.
Step 1 β Start the wizard
git clone <your-repo-url> katalog_ai && cd katalog_ai pnpm install make setup # Open http://localhost:3000 in your browser
make setup starts a temporary Next.js dev server with SETUP_MODE=true. The wizard writes your real config to infra/docker/.env when you finish.
The 7 wizard steps
Step 2 β Follow the Final Guide (4 ordered actions)
- Browser β open
localhost:3001β choose SQLite β create your Uptime Kuma admin account using the credentials from your .env - Terminal β press
Ctrl+Cto stop themake setupdev server - Terminal β run
make startto build & launch the full Docker stack (3β5 min). The Makefile picksdocker-compose-local.ymlordocker-compose.ymlautomatically based on your chosen target. - Terminal β once all containers are healthy, run
./scripts/seed-uptime-kuma.sh --env local(or--env prod) to auto-populate monitors and the status page.
Useful Makefile commands: make info (show active compose file), make stop, make restart, make logs, make migrate.
CLI Script β deploy.sh
For power users, CI/CD pipelines, or re-deployments where you already have an infra/docker/.env.katalog file. No browser required.
Step 1 β Create your env file
cp setup.env infra/docker/.env.katalog # Edit the file and fill in your real credentials
setup.env ships with the repo as a template with safe placeholder values. Replace every change-me-* value before continuing.
Step 2 β Launch the stack
./deploy.sh up
Builds all Docker images, starts every container, and runs database migrations automatically. First build takes 3β5 min.
Step 3 β Initialise Uptime Kuma
# Open in browser: http://localhost:3001 # (local) https://status.yourdomain.com # (VPS) # Choose SQLite β Next β create admin account # Then seed monitors: ./scripts/seed-uptime-kuma.sh --env prod
| Command | What it does |
|---|---|
| ./deploy.sh up | Build images, start all services, run migrations |
| ./deploy.sh down | Stop all services (volumes preserved) |
| ./deploy.sh restart | Restart containers without rebuilding |
| ./deploy.sh rebuild | Full rebuild from scratch, then restart |
| ./deploy.sh logs | Tail logs from all containers |
| ./deploy.sh migrate | Run pending DB migrations only |
| ./deploy.sh seed | Run DB seed script |
| ./deploy.sh ps | Show running container status |
VPS or Docker required
Shared hosting (cPanel, Plesk) is not supported. Katalog AI requires Docker, Node.js 22, and PostgreSQL with the pgvector extension. Any VPS running Ubuntu 20.04+ with 2 GB RAM and Docker installed will work.
Docker Deployment
For VPS deployments (AWS EC2, DigitalOcean, Hetzner). Provides containerised Next.js, worker, Postgres, and Redis.
Create infra/docker/.env.katalog
DATABASE_URL=postgresql://postgres:postgres@katalog-postgres:5432/katalog REDIS_URL=redis://katalog-redis:6379 FIREBASE_PROJECT_ID=your-project-id FAL_KEY=fal-xxx
Launch all containers
docker compose -f infra/docker/docker-compose.yml \ --env-file infra/docker/.env.katalog up -d --build
Run migrations inside container
docker compose -f infra/docker/docker-compose.yml exec web pnpm db:migrate
Deploying Chatbots
Both bots are Hono apps deployed to Cloudflare Workers edge.
WhatsApp (Evolution)
- Configure verify tokens in
apps/whatsapp/wrangler.toml - Deploy:
pnpm --filter @katalog/whatsapp deploy - Add Worker URL as webhook in Meta Developers Panel
Telegram
- Get bot token from
@BotFather - Deploy:
pnpm --filter @katalog/telegram deploy - Register webhook:
POST .../setWebhook?url=<WORKER_URL>/tg/webhook
Four-Step Generation Wizard
The core Web dashboard experience β four streamlined phases from garment photo to studio result.
Custom LoRA Training
Train a dedicated model face by feeding 5β15 reference headshots. The resulting LoRA weight locks face structure across all future shoots β guaranteeing consistent lookbooks regardless of backdrop or pose.
The "Same-Model" Advantage
Training takes ~15 minutes on fal.ai GPU infrastructure. Once complete, the custom model weight appears in your Model Hub and can be applied to any generation job.
Training Pipeline
- 1. Upload 5β15 face reference images
- 2. Auto-align + normalise resolution
- 3. fal.ai fine-tunes Flux LoRA weight
- 4. Weight stored in Cloudflare R2
- 5. Model appears in your Hub instantly
Video Showcase Reels
Convert any generated catalogue image into a 5β15 second cinematic video clip β ready for Instagram Reels, WhatsApp Status, or product pages.
Image-to-Video
Submit any completed generation as a video job. Worker dispatches to fal.ai video models.
Social Ready
Output is a standard MP4 optimised for vertical (9:16) or square (1:1) social formats.
Same Queue
Video jobs enter the BullMQ pipeline β async processing with SSE progress updates.
Workflow
Dashboard β Reels (/t/[slug]/reels) β select a generation β "Create Reel" β SSE progress β download MP4
Conversational Bots
WhatsApp and Telegram bring the studio into chat β same AI pipeline, no web browser required.
WhatsApp (Evolution API)
Send a garment photo to the business number β receive studio renders in chat. Node-based Evolution integration with automated media attachment ingest.
- β’ Interactive list menus for model/scene selection
- β’ Quota status commands
- β’ HMAC webhook signature verification
Telegram Bot
Conversational menu interface with inline keyboard selectors for model, aspect ratio, and scene. Renders delivered as Telegram photos.
- β’ Hono on Cloudflare Workers
- β’ Upstash Redis for conversation state
- β’ Inline keyboard menus
Billing & Payments
Dual-gateway billing with idempotent webhook processing. Each tenant subscribes to a plan that controls image generation quotas.
| Gateway | Currencies | Features |
|---|---|---|
| Stripe | USD, EUR, GBP, AUD, CAD β¦ | Global card processing, automated VAT/GST invoices, localized webhooks |
| Razorpay | INR (India) / regional | UPI QR, Indian cards, net banking, domestic tax-compliant invoices |
Workspace & Library
Each tenant gets an isolated workspace with dedicated sections for every aspect of the generation workflow.
/catalogues
Completed Renders
Lightbox preview, presigned link copy, and delete β all with instant grid updates.
/library
Garment Library
Upload raw images, crop garment regions, manage asset resolutions.
/models
Model Hub
Curated platform models + tenant-trained LoRA models with training status badges.
/history
Generation History
Full log of every job β status, model, scene, timestamps, cost estimates.
/reels
Video Reels
Showcase reel library β submit image-to-video jobs and download finished MP4 clips.
/settings
Workspace Settings
Team invites, API keys, notification preferences, billing portal link.
Admin Panel
Super-admin dashboard at /admin for platform operators. Requires the SUPER_ADMIN role.
/admin/tenants
Tenant Management
View all tenants, suspend/re-activate accounts, manually set quotas.
/admin/users
User Management
Browse all users across tenants, inspect roles, trigger password resets.
/admin/generations
Generation Monitor
Global view of all generation jobs β status, model used, cost estimates.
/admin/plans
Plan Configuration
Create/edit subscription plans, credit limits, and pricing for both gateways.
/admin/platform-models
Platform Models
Manage the built-in model catalogue visible to all tenants.
/admin/channels
Bot Channels
Configure WhatsApp and Telegram channel settings globally.
Monorepo Structure
pnpm workspaces + Turborepo for build caching and isolated execution contexts.
katalog-ai/
βββ apps/
β βββ web/ # Next.js (App Router Β· RSC Β· SSE Β· TypeScript)
β βββ worker/ # Node.js BullMQ process (fal.ai, face-crop, video jobs)
β βββ whatsapp/ # Hono + Cloudflare Workers (Evolution webhook)
β βββ telegram/ # Hono + Cloudflare Workers (Telegram Bot API)
β
βββ packages/
βββ db/ # Neon PostgreSQL Β· Drizzle ORM Β· Migrations Β· Seeders
βββ ai-router/ # Model adapter β fal.ai + Google Vertex AI
βββ shared/ # Zod schemas Β· BullMQ queues Β· storage helpers Β· errors
βββ config/ # ESLint Β· TSConfig Β· PrettierAsync Generation Pipeline
Generative tasks are heavy and async. Katalog prevents HTTP timeouts using a stateful pipeline around BullMQ and webhooks.
Interactive Data Flow
Click any stage to inspect pipeline mechanics.
Click a stage above to see its execution details.
System Flowchart
Structural flow from ingest routing through queue validation, worker dispatch, and CDN edge saves.
Database & Row-Level Security
Neon serverless PostgreSQL mapped via Drizzle ORM. Multi-tenant boundaries enforced at the database layer via RLS policies.
Core Entities
users Β· tenants Β· memberships Β· assets Β· platformModels Β· backgroundScenes Β· generationJobs Β· videos Β· plans Β· subscriptions
Row-Level Security
Postgres RLS policies filter access based on the user's active session tenant. No user can read, delete, or overwrite resources belonging to other brands β enforced at the database layer, not just application logic.
Enforced via Drizzle RLS helpersHono Workers & Bot APIs
Both bot integrations are standalone Hono applications deployed to Cloudflare's global edge network.
- Edge Worker
Edge Execution
Cloudflare global CDN β ultra-low latency for incoming bot webhooks.
- Upstash REST
Redis State
Conversational steps stored in Upstash Redis REST client (no ioredis on edge).
- BullMQ HTTP
Queue Dispatch
Pushes generation jobs to the core BullMQ cluster via HTTP abstraction.
- Security
Signature Verification
All incoming webhooks verified with HMAC-SHA256 before processing.
fal.ai & Vertex AI Integration
Model interfaces are unified inside @katalog/ai-router. This adapter layer maps generation parameters to fal.ai and Google Vertex AI endpoints.
// packages/ai-router β modular adapter interface
import { fal } from "@fal-ai/client";
export async function dispatchImageGeneration(payload: ImageJobPayload) {
return await fal.queue.submit("fal-ai/flux-lora", {
input: {
prompt: payload.structuredPrompt,
image_size: payload.aspectRatio,
loras: payload.customLoraUrl
? [{ path: payload.customLoraUrl, scale: 0.85 }]
: [],
num_inference_steps: 28,
enable_safety_checker: true,
},
webhookUrl: `${process.env.FAL_WEBHOOK_BASE_URL}?jobId=${payload.jobId}`,
});
}fal.ai (Standard & Pro)
Flux, SDXL, Imagen β 600+ models via single adapter. Async queue with webhook callback.
Google Vertex AI (Premium)
Imagen 4 Ultra for premium-tier tenants. REST predict endpoint with bearer token auth via VERTEX_ACCESS_TOKEN.
Security Hardening
Production hardening applied as part of Phase 12 launch preparation.
- HTTP Headers
Security Headers
HSTS, X-Frame-Options, CSP (tightened style-src), X-Content-Type-Options, Permissions-Policy β via Next.js config.
- Rate Limit
Rate Limiting
Upstash ratelimit on all API routes β per-IP and per-Bearer-token sliding windows in middleware.
- SSRF
SSRF Guard
User-supplied URLs validated against private IPv4 ranges, IPv6 loopback, and malformed octets before any outbound fetch.
- Auth
JWT + HttpOnly Sessions
Firebase ID tokens validated server-side; session stored in HttpOnly signed cookies via jose.
- Webhooks
Webhook Signature Verification
fal.ai, Stripe, and Razorpay webhooks all verified with HMAC-SHA256 before processing.
- Access Control
IDOR Protection
All dynamic routes wrapped in assertTenantAccess(). Admin routes use assertAdmin().
- Compliance
Cookie Consent + GDPR
Cookie consent banner included. Data export (GET /api/me/data-export) and account deletion (DELETE /api/me) endpoints provided.
Environment Variables
Copy .env.example at root and fill in all keys before deploying.
| Variable | Service | Purpose |
|---|---|---|
| DATABASE_URL | Neon | Pooled Postgres connection for runtime |
| DIRECT_DATABASE_URL | Neon | Unpooled connection for migrations |
| REDIS_URL | Upstash | BullMQ queue β TLS: rediss:// |
| CLOUDFLARE_R2_BUCKET | Cloudflare R2 | Bucket name per environment |
| CLOUDFLARE_R2_ACCESS_KEY_ID | Cloudflare R2 | S3-compatible access key |
| CLOUDFLARE_R2_SECRET_ACCESS_KEY | Cloudflare R2 | S3-compatible secret |
| CLOUDFLARE_R2_PUBLIC_URL | Cloudflare R2 | CDN base URL for public assets |
| FIREBASE_PROJECT_ID | Firebase Admin | Admin SDK project ID |
| FIREBASE_CLIENT_EMAIL | Firebase Admin | Service account email |
| FIREBASE_PRIVATE_KEY | Firebase Admin | Private key PEM string |
| NEXT_PUBLIC_FIREBASE_API_KEY | Firebase Client | Browser-side API key |
| SESSION_SECRET | Auth | Signs HttpOnly session cookies (32-byte hex) |
| FAL_KEY | fal.ai | API key for image & video generation |
| FAL_WEBHOOK_SECRET | fal.ai | HMAC secret for webhook verification |
| FAL_WEBHOOK_BASE_URL | fal.ai | Public URL base for fal.ai callbacks |
| GOOGLE_CLOUD_PROJECT | Vertex AI | GCP project ID (premium tier only) |
| VERTEX_ACCESS_TOKEN | Vertex AI | Bearer token for Imagen 4 Ultra REST API |
| RAZORPAY_KEY_ID | Razorpay | Public key for regional (India) billing |
| RAZORPAY_KEY_SECRET | Razorpay | Secret key for order creation |
| RAZORPAY_WEBHOOK_SECRET | Razorpay | HMAC secret for webhook verification |
| STRIPE_SECRET_KEY | Stripe | Secret key for USD/global billing |
| STRIPE_WEBHOOK_SECRET | Stripe | Webhook signing secret |
| WHATSAPP_APP_SECRET | HMAC secret for webhook signature | |
| NEXT_PUBLIC_APP_URL | App | Public base URL (e.g. https://app.kataloga.com) |
FAQ & Troubleshooting
Q: Why are images stuck on "Processing"?
The BullMQ worker must be running. In local dev: pnpm dev (all services) or pnpm --filter @katalog/worker dev. In Docker, check that the Redis container is healthy and the worker container started without errors.
Q: How do I run migrations on Neon?
Always use DIRECT_DATABASE_URL (non-pooled) for migrations β pooled connections fail on DDL statements. In Docker: exec into the web container and run pnpm db:migrate.
Q: Can I use my own PostgreSQL instead of Neon?
Yes β any PostgreSQL 15+ server works. Neon is recommended for serverless scalability but not required.
Q: Can I swap fal.ai for another AI provider?
The @katalog/ai-router package abstracts model providers. Add an adapter implementing the provider interface to support Replicate, Together AI, or any other provider.
Q: Does this include a mobile app?
No. The WhatsApp and Telegram bots provide mobile access. A native iOS/Android app is not included.
Q: Can I white-label this for my clients?
Yes. The Regular License covers one end product. An Extended License allows operating it as your own SaaS for multiple end users.
Q: Does /docs require login?
No β /docs is fully public and does not redirect to /login. It is accessible to prospective buyers and new users before they create an account.