Launch Rail Logo
Launch Rail
Documentation

Entitlements & Usage Service

A high-performance engine for managing feature flags, subscription tiers, and real-time consumption quotas. Built for complex B2B SaaS monetization.

System Overview

The Entitlements service acts as the central brain for your application's monetization. It decouples feature availability from your business logic, allowing product managers to update plans and limits in YAML without code redeploys.

Feature Flags

Boolean toggles or numeric limits defined globally across tiers.

Plan Bundles

Logical grouping of features into commercial packages (Free, Pro, Ent).

Usage Quotas

Real-time counters tracking consumption (API calls, storage, seats).

Getting Started & Local Dev

# 1. Start Infrastructure (PostgreSQL + Redis + NATS)
docker-compose up -d

# 2. Sync Policies & Run Server
make run

The service will be available at 8080 for ConnectRPC (REST/Web) and 50051 for gRPC.

Using the CLI

launchrail-ctl — zsh
$
CLI SimulationActive

Feature Catalog (features.yaml)

The Feature Dictionary defines the global schema. It describes what a feature is, but not its specific limit (which happens in plans).

version: 1

features:
  - key: "automation.runs"
    namespace: "automations"
    type: "INT"           # Supported: TOGGLE, INT, DECIMAL, STRING, JSON
    scope: "COMPANY"      # COMPANY, TEAM, USER, GLOBAL
    default_aggregation_period: "MONTH"
    display_name: "Monthly Automation Runs"
    metadata:
      unit: "runs"
      ui_group: "Usage Metrics"

  - key: "ai.advanced_model"
    type: "TOGGLE"
    scope: "USER"
    display_name: "Access to Claude 3.5 / GPT-4o"

Supported Types

  • TOGGLE: Boolean (true/false) flags.
  • INT: Whole numbers (seats, projects).
  • DECIMAL: Financial/Weight values (storage GBs).
  • STRING / JSON: Custom config strings.

Scopes

Scopes determine where the counter is stored. COMPANY sums usage for the whole tenant, while USER tracks quotas per individual.

Plan Definitions (plans.yaml)

Plans bundle features from the catalog and assign Monetization Bounds specifically given to specific tiers.

plans:
  - id: "pro-monthly"
    code: "pro"
    name: "Professional"
    default_billing_period: "MONTHLY"
    metadata:
      price_monthly: 29.00
      marketing_label: "Most Popular"

    features:
      - feature_key: "automation.runs"
        value: { int_value: 5000 }
        is_hard_limit: true
        enforcement: "BLOCK"

      - feature_key: "storage.gb"
        value: { decimal_value: 50.0 }
        is_hard_limit: true
        enforcement: "BLOCK"

      - feature_key: "ai.advanced_model"
        value: { bool_value: true }

Value Type Safety

The value sub-field must match the type defined in features.yaml. For example, an INT feature must use int_value.

Enforcement Strategies

  • BLOCKStandard hard limit. If quota is reached, new requests return false or errors.
  • WARNSoft limit. Requests are permitted, but usage threshold events are emitted for notifications.
  • NONEAnalytics only. No functional restriction, typically used for tracking infinite enterprise plans.

Frontend Integration

Use the generated ConnectRPC clients to drive your UI logic based on entitlements.

Fetching Effective Features

Load all permitted capabilities for a company on application boot.

const response = await subClient.getEffectiveFeaturesForSubject({
  subject: { type: SubjectType.COMPANY, id: companyId }
});

// Convert to a lookup map for easy UX logic
const featureMap = new Map(response.features.map(f => [f.featureKey, f]));

Usage & Limit Checks

Perform a dry-run limit check before allowing users to perform costly actions.

const res = await usageClient.checkLimit({
  subject: { type: SubjectType.COMPANY, id: companyId },
  featureKey: "storage.gb_used",
  delta: 1n // Check if can add 1 more unit
});

if (!res.allowed) {
  showUpgradeModal();
}

Building Limit-Aware UI

Avoid "Post-mortems": Never let an API request fail due to a limit before you've warned the user. Use isHardLimit to drive button states and progress bars.

Seats Used18 / 20

⚠️ 90% reached. You will need more seats soon.

Enterprise Grade Usage Tracking

Unlike simple feature flags (LD, GrowthBook), the Launch Rail Entitlements service handles Stateful Counters. It manages high-concurrency increments via Redis Lua scripts ensuring that you never double-bill or miss a limit breach in distributed systems.

View Usage API Reference