Skip to main content

Kloyst Docs Index

Welcome to the documentation for the Kloyst Backend (kloyst-core).

Kloyst is an enterprise-grade, multi-tenant WhatsApp Business SaaS platform. This doc set covers the full backend architecture: contact ingestion, messaging pipeline, pricing engine, observability, security, and deployment.


πŸ“š Documentation Map​

πŸ— Architecture​

πŸ—ƒ Database​

πŸ“₯ Contact Ingestion Pipeline​

πŸ“¨ Messaging​

πŸ’° Pricing Engine​

  • Pricing Engine β€” Rate cards, regional pricing, platform fees, quotation flow

πŸ’³ Billing​

  • Billing & Wallet β€” Credit system, transaction types, wallet debit on send

πŸ”’ Security​

πŸ“Š Observability & Monitoring​

πŸ” Resilience​

πŸ”— Sequences & Flows​

🀝 Integrations​

πŸ§ͺ Upsert Strategy​


πŸ—Ί Deployment Architecture (Staging)​

GitHub (staging branch push)
β”‚
Jenkins Pipeline
β”œβ”€β”€ rsync β†’ /srv/apps/kloyst-core/
β”œβ”€β”€ docker build (on server, no registry)
└── docker compose -f docker-compose.staging.yml up -d
β”‚
β”œβ”€β”€ kloyst-staging-api-gateway β†’ 127.0.0.1:3000
β”œβ”€β”€ kloyst-staging-webhook-worker β†’ 127.0.0.1:3002
β”œβ”€β”€ kloyst-staging-worker-pool β†’ (internal)
β”œβ”€β”€ kloyst-staging-outbox-relay β†’ (internal)
β”œβ”€β”€ kloyst-staging-postgres β†’ (internal)
└── kloyst-staging-redis β†’ (internal)
β”‚
Nginx (SSL termination, basic auth)
β”œβ”€β”€ api.staging.kloyst.com/v1/* β†’ :3000
└── api.staging.kloyst.com/webhook/* β†’ :3002
β”‚
Monitoring Stack (/srv/apps/monitoring/)
β”œβ”€β”€ Grafana β†’ 127.0.0.1:3003 β†’ logs.staging.kloyst.com
β”œβ”€β”€ Loki β†’ 127.0.0.1:3100 (internal)
β”œβ”€β”€ Promtail β†’ (internal, tails Docker + log files)
└── Dozzle β†’ 127.0.0.1:8888 β†’ dozzle.staging.kloyst.com

βš™οΈ Core Philosophy​

  • Never crash on partial errors β€” Invalid rows are rejected; valid ones continue.
  • Tenant isolation is absolute β€” vendorId on every query. No exceptions.
  • Strict normalization β€” All phone numbers parsed with Google's libphonenumber to E.164.
  • Auditability β€” Every import job, chunk, and contact change is logged immutably.
  • Migration safety β€” prisma migrate deploy in all non-local environments. Never db push.
  • Secrets via Jenkins β€” Zero hardcoded credentials. All injected via secret file at deploy time.