Documentation

Developer Documentation & API Reference

A developer-facing reference for the ScaleSystems autonomous AI workforce platform: the execution environment, the dual-rail billing architecture, plan-tier quota enforcement, and the tooling used to verify every integration.

Core Architecture

ScaleSystems runs on the Next.js 15 App Router execution environment, colocating server-rendered marketing surfaces, the client control dashboard, and Route Handler APIs inside a single deployable runtime. Identity is managed by Auth.js v5 using stateless JWT sessions. Each session token is enriched with the caller's plan tier and their Stripe Customer ID, so every server action and Route Handler can resolve billing context and enforce quotas without an extra database round-trip.

Execution Environment

App Router server components handle rendering and data access on the edge-adjacent runtime, while Route Handlers expose the authenticated JSON API consumed by deployed agents.

Session Claims

The Auth.js v5 JWT carries the signed plan tier and stripeCustomerId claims, giving every request a self-describing billing and entitlement context.

The Billing Rails

Billing is a dual-rail design that lets customers settle in either fiat or crypto without changing the entitlement model. Both rails resolve to the same plan tier applied to the caller's Auth.js session.

Rail 1 — Stripe Checkout

Traditional card processing runs through the Stripe Checkout loop. The app creates a Checkout Session tied to the session's Stripe Customer ID, redirects the customer to Stripe's hosted page, and reconciles the resulting subscription state back onto the JWT plan claim via webhook events forwarded during development with npm run stripe:listen.

Rail 2 — BVNK Crypto Gateway

Crypto settlement is handled by the BVNK payment gateway. Requests are signed with Hawk authentication signatures and quotes are retrieved by issuing a POST /api/v1/pay/summary request. A confirmed crypto payment upgrades the same plan tier used by the Stripe rail, keeping entitlements identical across both settlement paths.

Tier & Quota Guards

The PlanTier value on the session drives runtime quota enforcement for agent deployments and token throughput. Requests that exceed the active tier are rejected before the agent runtime is invoked.

Plan TierActive Agent LimitToken Limit
FREE1 active agent deployment50,000 tokens / month
STARTER5 active agent deployments500,000 tokens / month
PREMIUMUnlimited deploymentsUnlimited tokens

DevOps Utility Scripts

A quick reference for the custom integration-testing commands used to keep the billing and data rails verified during development.

  • npm run integrations:verify

    Runs the end-to-end integration harness against Stripe, BVNK, and the database rails to confirm every external connection is healthy.

  • npm run stripe:listen

    Starts the local Stripe CLI webhook forwarder so Checkout and subscription events reach the app during development.

  • npm run db:verify

    Validates the Prisma schema against the live PostgreSQL connection and confirms the plan-tier tables are reachable.