Skip to main content

Quick Start Guide

Run Superposition

The quickest way to get started with superposition is to run the container image. This will run and expose superposition on port 8080.

docker run -p 8080:8080 ghcr.io/juspay/superposition-demo:latest

Once the container image has started - you can play around with superposition at http://localhost:8080.

warning

The image ghcr.io/juspay/superposition-demo:latest is a demo image that contains a pre-populated set of organisations, workspaces and configurations. It is not meant for production use. To deploy Superposition in production, use the image ghcr.io/juspay/superposition:latest.

Openfeature Provider

Superposition supports OpenFeature, a standard for feature flagging. To use Superposition as an OpenFeature provider, you need to install the OpenFeature SDK for your language of choice and configure it to use Superposition as the provider.

Setup

Install the provider for your language of choice. The provider will allow you to read feature flags and configurations from Superposition.

app/build.gradle
implementation "dev.openfeature:sdk:1.15.1"
implementation "io.juspay.superposition:openfeature-provider:0.87.0"

Initialize and configure the Provider

App.java
import dev.openfeature.sdk.*;
import io.juspay.superposition.openfeature.*;
import io.juspay.superposition.openfeature.options.RefreshStrategy;

import java.util.List;
import java.util.Map;

public class Example {
public static void main(String[] args) {
// Configure experimentation options
SuperpositionProviderOptions.ExperimentationOptions expOptions =
SuperpositionProviderOptions.ExperimentationOptions.builder()
.refreshStrategy(RefreshStrategy.Polling.of(5000, 2000)) // 5s timeout, 2s interval
.build();

// Configure provider options
SuperpositionProviderOptions options =
SuperpositionProviderOptions.builder()
.orgId("localorg")
.workspaceId("test")
.endpoint("http://localhost:8080")
.token("api-token")
.refreshStrategy(RefreshStrategy.Polling.of(10000, 5000)) // 10s timeout, 5s interval
.experimentationOptions(expOptions)
.build();

// Initialize provider
SuperpositionOpenFeatureProvider provider =
new SuperpositionOpenFeatureProvider(options);
EvaluationContext initCtx =
new ImmutableContext(Map.of("foo", new Value("bar")));
provider.initialize(initCtx);
}
}

Evaluate Feature Flags

Once the provider is initialized, you can evaluate feature flags and configurations using the OpenFeature client.

App.java
Client client = OpenFeatureAPI.getInstance().getClient();

// Create evaluation context (optional)
EvaluationContext ctx =
new ImmutableContext(Map.of("userId", new Value("123")));

// Evaluate a boolean flag
boolean enabled = client.getBooleanValue("my-feature-flag", false, ctx);
System.out.println("Feature enabled: " + enabled);

// Evaluate & get the entire configuration
System.out.println("Full config: " + provider.evaluateConfig(ctx));

Setup the SDK (Optional)

If you want to do more than just read configs, Superposition provides SDKs for various languages to interact with the platform. Any operation that can be performed via the UI can also be performed via the SDKs. Install the SDK for your language of choice to get started.

app/build.gradle.kts
implementation("io.juspay.superposition:sdk:<version>")