Katalog Docs
Studio β†’
Overview

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.

Getting Started Β· 01

System Requirements

RequirementMinimumRecommended
Node.jsv22 LTSv22 LTS or v24
pnpmv9.xv10.x
PostgreSQLv15+ (local/Docker)Neon Serverless PostgreSQL
Redisv7+ (local/Docker)Upstash Serverless Redis
RAM1 GB2 GB+
Getting Started Β· 02

External Services

You need accounts on these platforms before running Katalog AI in production.

ServicePurposeRequiredFree Tier
FirebaseAuth β€” Email OTP + Google OAuthYesβœ…
Cloudflare R2File storage + CDN deliveryYesβœ… 10 GB/mo
Upstash RedisBullMQ job queue + bot stateYesβœ…
Neon PostgreSQLPrimary databaseYesβœ…
fal.aiAI image & video generationYes❌ Pay-per-use
Google Vertex AIImagen 4 Ultra (premium tier)Optional❌
RazorpayRegional billing (India/South Asia)Optionalβœ… Test mode
StripeUSD / global billingOptionalβœ… Test mode
Getting Started Β· 03

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
Getting Started Β· 04

Installation

There are two ways to install Katalog AI. Both produce the same running stack β€” pick whichever matches your comfort level.

Way 1 β€” UI WizardWay 2 β€” CLI Script
Best forFirst-time setup, non-technical usersPower users, CI/CD, re-deployments
Config methodBrowser form β€” no text editingEdit infra/docker/.env manually
Entry commandmake setup./deploy.sh up
Env file writteninfra/docker/.env (auto)infra/docker/.env.katalog (manual)
Uptime KumaGuided in Final GuideManual β€” open browser after start
Way 1

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)

  1. Browser β€” open localhost:3001 β†’ choose SQLite β†’ create your Uptime Kuma admin account using the credentials from your .env
  2. Terminal β€” press Ctrl+C to stop the make setup dev server
  3. Terminal β€” run make startto build & launch the full Docker stack (3–5 min). The Makefile picks docker-compose-local.yml or docker-compose.yml automatically based on your chosen target.
  4. 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.

Way 2

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
CommandWhat it does
./deploy.sh upBuild images, start all services, run migrations
./deploy.sh downStop all services (volumes preserved)
./deploy.sh restartRestart containers without rebuilding
./deploy.sh rebuildFull rebuild from scratch, then restart
./deploy.sh logsTail logs from all containers
./deploy.sh migrateRun pending DB migrations only
./deploy.sh seedRun DB seed script
./deploy.sh psShow 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.

Getting Started Β· 05

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
Getting Started Β· 06

Deploying Chatbots

Both bots are Hono apps deployed to Cloudflare Workers edge.

WhatsApp (Evolution)

  1. Configure verify tokens in apps/whatsapp/wrangler.toml
  2. Deploy: pnpm --filter @katalog/whatsapp deploy
  3. Add Worker URL as webhook in Meta Developers Panel

Telegram

  1. Get bot token from @BotFather
  2. Deploy: pnpm --filter @katalog/telegram deploy
  3. Register webhook: POST .../setWebhook?url=<WORKER_URL>/tg/webhook
Features Β· 01

Four-Step Generation Wizard

The core Web dashboard experience β€” four streamlined phases from garment photo to studio result.

Features Β· 02

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.

4K Outputs15-Min TrainingAuto Face CropMulti-Brand

Training Pipeline

  1. 1. Upload 5–15 face reference images
  2. 2. Auto-align + normalise resolution
  3. 3. fal.ai fine-tunes Flux LoRA weight
  4. 4. Weight stored in Cloudflare R2
  5. 5. Model appears in your Hub instantly
Features Β· 03

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

Features Β· 04

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
Features Β· 05

Billing & Payments

Dual-gateway billing with idempotent webhook processing. Each tenant subscribes to a plan that controls image generation quotas.

GatewayCurrenciesFeatures
StripeUSD, EUR, GBP, AUD, CAD …Global card processing, automated VAT/GST invoices, localized webhooks
RazorpayINR (India) / regionalUPI QR, Indian cards, net banking, domestic tax-compliant invoices
Features Β· 06

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.

Features Β· 07

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.

Architecture Β· 01

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 Β· Prettier
Architecture Β· 02

Async 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.

SSE STATEFUL

Click a stage above to see its execution details.

Architecture Β· 03

System Flowchart

Structural flow from ingest routing through queue validation, worker dispatch, and CDN edge saves.

INGESTION LAYERClient App / Edge BotsVALIDATION GATEWAYNext.js API & Quota checkQUEUE ORCHESTRATIONUpstash Redis (BullMQ)EXECUTION DISPATCHERBullMQ Worker ProcessGPU CLUSTERfal.ai Model RunWebhook CallbackAPI ENDPOINT/api/webhooks/falSTORAGE & DATACloudflare R2 & Neon PGSSE stream update
Architecture Β· 04

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

packages/db/src/schema.ts

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 helpers
Architecture Β· 05

Hono Workers & Bot APIs

Both bot integrations are standalone Hono applications deployed to Cloudflare's global edge network.

Worker Features
  • Edge Execution

    Cloudflare global CDN β€” ultra-low latency for incoming bot webhooks.

    Edge Worker
  • Redis State

    Conversational steps stored in Upstash Redis REST client (no ioredis on edge).

    Upstash REST
  • Queue Dispatch

    Pushes generation jobs to the core BullMQ cluster via HTTP abstraction.

    BullMQ HTTP
  • Signature Verification

    All incoming webhooks verified with HMAC-SHA256 before processing.

    Security
Architecture Β· 06

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.

Architecture Β· 07

Security Hardening

Production hardening applied as part of Phase 12 launch preparation.

Security Controls
  • Security Headers

    HSTS, X-Frame-Options, CSP (tightened style-src), X-Content-Type-Options, Permissions-Policy β€” via Next.js config.

    HTTP Headers
  • Rate Limiting

    Upstash ratelimit on all API routes β€” per-IP and per-Bearer-token sliding windows in middleware.

    Rate Limit
  • SSRF Guard

    User-supplied URLs validated against private IPv4 ranges, IPv6 loopback, and malformed octets before any outbound fetch.

    SSRF
  • JWT + HttpOnly Sessions

    Firebase ID tokens validated server-side; session stored in HttpOnly signed cookies via jose.

    Auth
  • Webhook Signature Verification

    fal.ai, Stripe, and Razorpay webhooks all verified with HMAC-SHA256 before processing.

    Webhooks
  • IDOR Protection

    All dynamic routes wrapped in assertTenantAccess(). Admin routes use assertAdmin().

    Access Control
  • Cookie Consent + GDPR

    Cookie consent banner included. Data export (GET /api/me/data-export) and account deletion (DELETE /api/me) endpoints provided.

    Compliance
Architecture Β· 08

Environment Variables

Copy .env.example at root and fill in all keys before deploying.

VariableServicePurpose
DATABASE_URLNeonPooled Postgres connection for runtime
DIRECT_DATABASE_URLNeonUnpooled connection for migrations
REDIS_URLUpstashBullMQ queue β€” TLS: rediss://
CLOUDFLARE_R2_BUCKETCloudflare R2Bucket name per environment
CLOUDFLARE_R2_ACCESS_KEY_IDCloudflare R2S3-compatible access key
CLOUDFLARE_R2_SECRET_ACCESS_KEYCloudflare R2S3-compatible secret
CLOUDFLARE_R2_PUBLIC_URLCloudflare R2CDN base URL for public assets
FIREBASE_PROJECT_IDFirebase AdminAdmin SDK project ID
FIREBASE_CLIENT_EMAILFirebase AdminService account email
FIREBASE_PRIVATE_KEYFirebase AdminPrivate key PEM string
NEXT_PUBLIC_FIREBASE_API_KEYFirebase ClientBrowser-side API key
SESSION_SECRETAuthSigns HttpOnly session cookies (32-byte hex)
FAL_KEYfal.aiAPI key for image & video generation
FAL_WEBHOOK_SECRETfal.aiHMAC secret for webhook verification
FAL_WEBHOOK_BASE_URLfal.aiPublic URL base for fal.ai callbacks
GOOGLE_CLOUD_PROJECTVertex AIGCP project ID (premium tier only)
VERTEX_ACCESS_TOKENVertex AIBearer token for Imagen 4 Ultra REST API
RAZORPAY_KEY_IDRazorpayPublic key for regional (India) billing
RAZORPAY_KEY_SECRETRazorpaySecret key for order creation
RAZORPAY_WEBHOOK_SECRETRazorpayHMAC secret for webhook verification
STRIPE_SECRET_KEYStripeSecret key for USD/global billing
STRIPE_WEBHOOK_SECRETStripeWebhook signing secret
WHATSAPP_APP_SECRETWhatsAppHMAC secret for webhook signature
NEXT_PUBLIC_APP_URLAppPublic base URL (e.g. https://app.kataloga.com)
Support

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.