Skip to main content

Seed Strategy & Data Injection

To ensure pricing calculations work immediately upon deployment, Kloyst uses an automated database seeding pipeline. The seed files populate Meta's base message rates, country regions, volume tiers, and default platform fee rules.

🚀 Seed Injection Pipeline

JSON Raw Source Files
[ pricing-regions.json ] --> Mapped countries & dialing codes
[ pricing-rates.json ] --> 2026 Meta WhatsApp cost tables


Prisma Seed Script (seed-pricing.ts)


Database Verification Check


[ PostgreSQL Database Populated ]

🛠️ Injected Seed Models

The seeding pipeline populates the following configuration tables:

1. PricingRegion Table

  • Inserts 50 principal countries mapped to their corresponding billing regions and international calling codes (e.g. IN $\rightarrow$ SOUTH_ASIA, +91).
  • Includes XX (Unknown Country) mapped to OTHER to handle phone numbers without valid country prefixes.

2. PricingRate Table

  • Inserts the complete 2026 Meta WhatsApp per-message cost schedules across all 4 templates (MARKETING, UTILITY, AUTHENTICATION, AUTHENTICATION_INTERNATIONAL) for each region.

3. PricingTier Table

  • Sets up volume discount tiers for UTILITY and AUTHENTICATION template categories:
    • $0 - 9,999$ messages: 0% discount
    • $10,000 - 99,999$ messages: 5% discount
    • $100,000 - 999,999$ messages: 10% discount
    • $1,000,000+$ messages: 15% discount
  • Marketing receives 0% discounts per Meta's standard pricing policy.

4. PlatformFeeRule Table

  • Registers the global default platform fee rule: 25% percentage markup, ₹0.00 flat fee, and isDefault = true.

🔁 Idempotent Execution

The seeding pipeline uses upsert operations to allow the script to be run repeatedly without creating duplicate records or overwriting existing custom settings.

Run Seed Script Command

npx ts-node prisma/seeds/seed-pricing.ts