Founding-Stage Engineer
at MagiQ AI

Based in Mumbai
India

01B · July 2025 – Present

BILLING & CREDITS

Frontend subscription & credit UX, admin support endpoints, and architecture study of Stripe webhooks, idempotency guards & dual pools.

Ownership & Role Scope

Shared UI/admin/pricing-PRD contribution alongside CTO-owned core billing-engine infrastructure

Stack & Modules

Node.jsTypeScriptExpressMongoDBStripe SDKReact
01B / Architecture SchematicBilling & Credits
Architecture Schematic (Sanitized)Subscription Checkout, Webhook Idempotency & Credit Waterfall

Architecture inspected read-only in billing-engine (built by CTO Nilesh; Vishank contributed billing UI alignment, admin support endpoints & pricing PRD).

Core billing-engine commits are team/CTO-owned; shown strictly to document verified system boundaries.

Frontend subscription & credit UX, admin support endpoints, and architecture study of Stripe webhooks, idempotency guards & dual pools.

01B.1 / Engineering Deep DiveSubscription Allowances Paired With Persistent Add-On Credits

Subscription Allowances Paired With Persistent Add-On Credits

AI company research and enrichment carry variable per-call compute costs. MagiQ AI separates expiring monthly/annual subscription credits (`creditBalance`) from purchased top-up packs (`addonCreditBalance`), while tracking reserved credits on active in-flight holds (`reservedCredits`).

01B.2 / Engineering Deep DiveWebhook Verification & Multi-Layer Idempotency Guard

Webhook Verification & Multi-Layer Idempotency Guard

To prevent duplicate credit grants during webhook retries, `/webhooks/stripe` mounts raw JSON buffering before body parsing for byte-exact `stripe.webhooks.constructEvent` validation, while payment webhooks verify HMAC-SHA256 signatures with `crypto.timingSafeEqual`.

Processed webhook records, deterministic `boost:<sessionId>` keys, atomic `$setOnInsert` upserts, and unique `CreditHold.idempotencyKey` constraints enforce safe replay handling across retries.

01B.3 / Engineering Deep DiveWaterfall Deduction Order & Pre-Action UX Clarity

Waterfall Deduction Order & Pre-Action UX Clarity

Inside MongoDB transactions guarded by an `$expr` available-credit constraint (`reservedCredits + credits <= creditBalance + addonCreditBalance`), deductions consume expiring subscription `creditBalance` first and persistent `addonCreditBalance` second—backed on the frontend by pre-action credit labels and contextual HTTP `402/403` limit modals.

01B / AttributionVerified Ownership & Collaboration Boundaries

Vishank's Contributions

  • Frontend subscription, plan comparison, billing history, and `UsageLimitModal` / pre-action credit cost clarity UI updates (`frontend-service`).
  • Admin support credit endpoints commit (`billing-engine` `adminController.ts`, `creditsController.ts`) and authoring `PRD-Pricing-and-Billing-Plan_v3.md`.

Team-Owned Core Engine (Nilesh Kanawade)

  • Core `billing-engine` architecture—Stripe Checkout session orchestration, raw-body webhook signature verification, multi-layer idempotency guards, atomic `$expr` dual-pool ledgering, and v3 feature quotas—was built by the CTO; documented here from read-only repository inspection without overclaiming authorship.

Subscription Allowances Paired With Persistent Add-On Credits

AI company research and enrichment carry variable per-call compute costs. MagiQ AI separates expiring monthly/annual subscription credits (`creditBalance`) from purchased top-up packs (`addonCreditBalance`), while tracking reserved credits on active in-flight holds (`reservedCredits`).

Webhook Verification & Multi-Layer Idempotency Guard

To prevent duplicate credit grants during webhook retries, `/webhooks/stripe` mounts raw JSON buffering before body parsing for byte-exact `stripe.webhooks.constructEvent` validation, while payment webhooks verify HMAC-SHA256 signatures with `crypto.timingSafeEqual`.

Processed webhook records, deterministic `boost:<sessionId>` keys, atomic `$setOnInsert` upserts, and unique `CreditHold.idempotencyKey` constraints enforce safe replay handling across retries.

Waterfall Deduction Order & Pre-Action UX Clarity

Inside MongoDB transactions guarded by an `$expr` available-credit constraint (`reservedCredits + credits <= creditBalance + addonCreditBalance`), deductions consume expiring subscription `creditBalance` first and persistent `addonCreditBalance` second—backed on the frontend by pre-action credit labels and contextual HTTP `402/403` limit modals.