README
ΒΆ
β‘ Flagura β Sub-Microsecond Feature Flagging & Release Engine
Feature flags that disappear from your critical path.
Sub-microsecond deterministic in-memory evaluation, OpenFeature native provider, gradual rollouts, and instant kill-switch circuit breakers.
Live Demo & Console β’ Architecture β’ OpenFeature β’ API Reference β’ SDK Integration β’ Deployment β’ Runbooks
π Overview
Flagura is a modern, high-performance feature flag and release management engine engineered for zero-latency in-process flag evaluation. Traditional SaaS feature flagging services introduce remote HTTP network hops (~20β80ms) that slow down user interactions and degrade Core Web Vitals.
Flagura solves this by evaluating rules and percentage rollouts locally in-memory using deterministic 64-bit FNV-1a hashing and atomic rule bitmaps, executing in sub-microsecond time (< 80 nanoseconds) with zero database roundtrips on evaluation hot paths.
β‘ Key Highlights
- β‘ Sub-Microsecond Resolution: In-memory deterministic rule engine resolving flags in 80ns β 4Β΅s without blocking the main event loop.
- π Native OpenFeature Provider: Drop-in vendor-neutral
open-feature/go-sdkintegrationβswitch or adopt Flagura with zero code lock-in. - π‘οΈ Resilient Offline Snapshot Mode: SDK caches rules to disk and boots seamlessly during server outages with zero request failures.
- π― Deterministic Sticky Percentage Bucketing: Pure mathematical FNV-1a 64-bit hashing ensures users consistently land in the exact same rollout bucket across all sessions and platforms.
- π¨ Instant Master Kill-Switch: 1-click edge circuit breaker to instantly shut down buggy features in production with zero code redeployments.
- π Production Observability: Built-in Prometheus
/metricsendpoint and Kubernetes/healthz,/livez,/readyzprobes. - π Clean, Stripe-Grade UI/UX: Docked developer console, interactive switchboard playground, live evaluation sandbox, latency benchmark suite, and immutable audit trails.
βοΈ How Flagura Compares
| Feature / Metric | β‘ Flagura | LaunchDarkly | Unleash | Flagsmith | GrowthBook |
|---|---|---|---|---|---|
| Core Architecture | Go (Native Binary) | Cloud SaaS / Daemon | Node.js / TypeScript | Python (Django) | TypeScript / Next.js |
| P50 Evaluation Latency | 123 nanoseconds |
~25 Β΅s (SDK) / ~35ms | ~25 Β΅s | ~50 Β΅s | ~30 Β΅s |
| Memory Footprint | ~35 MB |
High (Relay Daemon) | ~450 MB β 800 MB |
~400 MB β 1 GB |
~350 MB β 600 MB |
| Pricing Model | 100% Free & Open Source | $500 β $5,000+/mo | Freemium ($80+/mo) | Freemium ($45+/mo) | Freemium ($20+/mo) |
| Zero DB I/O on Evaluation | β Yes (In-Memory) | β οΈ Requires Proxy | β οΈ Requires Redis/Proxy | β Queries DB/Cache | β οΈ Requires Cache |
| Data Privacy (Self-Hostable) | β 100% (Your DB) | β 3rd-Party SaaS | β Yes | β Yes | β Yes |
| Deployment Model | Single Binary / Docker / Vercel | Cloud SaaS Only | Multi-tier (Node + Redis + DB) | Multi-tier (Django + DB) | Multi-tier (Next + DB) |
π Read full architectural comparison in documentation
ποΈ Architecture
Flagura is engineered for maximum execution speed, zero runtime overhead, and simple deployment:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FLAGURA ENGINE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ Go 1.22+ Core ββ High-concurrency engine & FNV-1a hashing β
β β’ Direct SQL Store ββ Pure database/sql + lib/pq for Supabase β
β β’ API-First Design ββ Ultra-fast batch & single evaluation API β
β β’ Compiled Views ββ Type-safe compiled HTML views & CSS β
β β’ Reactive UI Components ββ Fast, zero-page-reload console components β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββ
β Client Application / SDK β
βββββββββββββββ¬βββββββββββββ
β (In-Memory / HTTP)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Flagura Evaluation Engine β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. Check Environment Master Kill-Switch β
β 2. Evaluate Specific Attribute Rules (Email/Tier) β
β 3. Compute FNV-1a 64-bit Sticky Hash Bucket (0-99) β
β 4. Resolve Treatment vs Control Group β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β (< 80ns execution)
βΌ
ββββββββββββββββββββββββββββ
β Boolean / Variant Value β
ββββββββββββββββββββββββββββ
π Quickstart
1. Run Locally (In-Memory Edge Mode)
No database installation required to get started. Flagura includes a built-in in-memory edge store pre-seeded with sample flags:
# Clone the repository
git clone https://github.com/dhawalhost/flagura.git
cd flagura
# Run the Go server
go run main.go
Open your browser to:
- Storytelling Landing Page: http://localhost:3000
- Developer Console: http://localhost:3000/dashboard
2. Connect to Supabase PostgreSQL
-
Open your Supabase Dashboard -> SQL Editor.
-
Run the migration script in
supabase/schema.sql:CREATE TABLE IF NOT EXISTS feature_flags ( id TEXT PRIMARY KEY, key TEXT UNIQUE NOT NULL, name TEXT NOT NULL, description TEXT, type TEXT NOT NULL DEFAULT 'boolean', tags TEXT[] DEFAULT '{}', variants JSONB DEFAULT '[]'::jsonb, environments JSONB NOT NULL DEFAULT '{}'::jsonb, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE TABLE IF NOT EXISTS audit_logs ( id TEXT PRIMARY KEY, flag_key TEXT NOT NULL, action TEXT NOT NULL, environment TEXT NOT NULL, actor TEXT NOT NULL, details TEXT, timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW() ); -
Set your connection string and launch:
export DATABASE_URL="postgres://postgres.[PROJECT_REF]:[PASSWORD]@aws-0-[REGION].pooler.supabase.com:6543/postgres?sslmode=require" go run main.go
π REST API Reference
1. Batch / Single Flag Evaluation
Endpoint: POST /api/v1/evaluate
Evaluates requested feature flags against a user context in sub-millisecond time.
Request:
curl -X POST http://localhost:3000/api/v1/evaluate \
-H "Content-Type: application/json" \
-d '{
"flags": ["ai-smart-search", "new-checkout-flow"],
"context": {
"user_id": "usr_dhawal_01",
"email": "dhawal@flagship.dev",
"country": "US",
"role": "admin",
"tier": "enterprise",
"environment": "production"
}
}'
Response:
{
"results": {
"ai-smart-search": {
"flag_key": "ai-smart-search",
"enabled": true,
"variant": "treatment",
"value": true,
"reason": "TARGETING_RULE_MATCH",
"matched_rule_id": "rule_staff_whitelist",
"bucket_val": 42,
"evaluation_latency_ns": 4820,
"evaluation_latency_us": 4.82
},
"new-checkout-flow": {
"flag_key": "new-checkout-flow",
"enabled": true,
"variant": "true",
"value": true,
"reason": "PERCENTAGE_ROLLOUT",
"bucket_val": 35,
"evaluation_latency_ns": 120,
"evaluation_latency_us": 0.12
}
},
"total_flags": 2,
"environment": "production",
"total_duration_us": 22.4
}
2. Flag Management Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET |
/healthz / /livez |
Kubernetes liveness health probe |
GET |
/readyz |
Kubernetes readiness probe (checks storage) |
GET |
/metrics |
Standard Prometheus metrics exposition |
GET |
/api/v1/flags |
List all feature flags across environments |
GET |
/api/v1/flags/:key |
Retrieve details for a specific flag |
POST |
/api/v1/flags |
Create or update a feature flag configuration |
PATCH |
/api/v1/flags/:key/toggle |
Instant 1-click toggle for master kill-switch |
PATCH |
/api/v1/flags/:key/rollout |
Dynamically update percentage rollout (0β100%) |
DELETE |
/api/v1/flags/:key |
Permanently remove a feature flag |
POST |
/api/v1/benchmark |
Execute live in-process latency stress test |
GET |
/api/v1/audit-logs |
Fetch immutable audit trail history |
π OpenFeature Go Provider
Flagura includes a first-class, official OpenFeature Provider implementing the CNCF vendor-neutral specification:
go get github.com/dhawalhost/flagura/pkg/openfeature
go get github.com/open-feature/go-sdk
package main
import (
"context"
"log"
"time"
"github.com/dhawalhost/flagura/pkg/client"
flaguraOF "github.com/dhawalhost/flagura/pkg/openfeature"
of "github.com/open-feature/go-sdk/openfeature"
)
func main() {
// 1. Initialize Flagura in-memory client
flaguraClient := client.New("https://flagura.dhawalhost.com",
client.WithLocalEvaluation(30*time.Second),
client.WithSnapshotFile("/tmp/flagura-cache.json"), // offline resilience
)
defer flaguraClient.Close()
// 2. Register Flagura as your global OpenFeature Provider
_ = of.SetProviderAndWait(flaguraOF.NewProvider(flaguraClient))
// 3. Evaluate flags using standard OpenFeature APIs
ofClient := of.NewClient("checkout-service")
evalCtx := of.NewEvaluationContext("usr_alex_42", map[string]interface{}{
"email": "alex@company.com",
"tier": "enterprise",
})
enabled, _ := ofClient.BooleanValue(context.Background(), "ai-smart-search", false, evalCtx)
log.Printf("Flag Status: %v", enabled)
}
π» Polyglot SDK Quickstart
1. Official Go Native SDK (pkg/client)
The built-in Go client supports sub-microsecond in-memory evaluations (cached in-process) and remote evaluations:
go get github.com/dhawalhost/flagura/pkg/client
package main
import (
"context"
"fmt"
"time"
"github.com/dhawalhost/flagura/pkg/client"
)
func main() {
// Initialize Flagura client with in-memory caching and offline snapshot
c := client.New("https://flagura.dhawalhost.com",
client.WithLocalEvaluation(30*time.Second),
client.WithSnapshotFile("/tmp/flagura-cache.json"),
)
defer c.Close()
// Evaluate flag locally in < 80 nanoseconds
result, err := c.Evaluate(context.Background(), "ai-smart-search", client.Context{
UserID: "usr_dhawal_01",
Email: "dhawal@flagura.dev",
Country: "US",
Role: "admin",
})
if err != nil {
panic(err)
}
fmt.Printf("Flag: %s | Enabled: %v | Variant: %s (in %d ns)\n",
result.FlagKey, result.Enabled, result.Variant, result.EvaluationLatencyNs)
}
2. TypeScript / JavaScript (Node.js, Next.js, Browser)
Zero-dependency standard fetch helper for full-stack JavaScript:
interface FlagEvaluation {
flag_key: string;
enabled: boolean;
variant: string;
value: any;
reason: string;
}
export async function evaluateFlag(
flagKey: string,
context: { userId: string; email?: string; country?: string; role?: string; environment?: string },
endpoint = "https://flagura.dhawalhost.com"
): Promise<FlagEvaluation> {
const res = await fetch(`${endpoint}/api/v1/evaluate`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
flags: [flagKey],
context: {
user_id: context.userId,
email: context.email,
country: context.country,
role: context.role,
environment: context.environment || "production",
},
}),
});
if (!res.ok) throw new Error(`Flagura API error: ${res.statusText}`);
const data = await res.json();
return data.results[flagKey];
}
// Example Usage
const flag = await evaluateFlag("ai-smart-search", {
userId: "usr_123",
email: "user@flagura.dev",
});
if (flag.enabled) {
console.log("Feature active! Variant:", flag.variant);
}
3. Python (FastAPI, Django, AI Agents)
import requests
def evaluate_flag(flag_key: str, user_id: str, email: str = "", endpoint: str = "https://flagura.dhawalhost.com") -> bool:
try:
response = requests.post(f"{endpoint}/api/v1/evaluate", json={
"flags": [flag_key],
"context": {
"user_id": user_id,
"email": email,
"environment": "production"
}
}, timeout=2.0)
response.raise_for_status()
data = response.json()
return data.get("results", {}).get(flag_key, {}).get("enabled", False)
except Exception as e:
print(f"[WARN] Flag evaluation fallback to false: {e}")
return False
# Example Usage
if evaluate_flag("ai-smart-search", user_id="usr_dhawal_01", email="dhawal@flagura.dev"):
print("AI Smart Search is enabled!")
4. cURL / REST API
curl -X POST https://flagura.dhawalhost.com/api/v1/evaluate \
-H "Content-Type: application/json" \
-d '{
"flags": ["ai-smart-search"],
"context": {
"user_id": "usr_dhawal_01",
"email": "dhawal@flagura.dev",
"environment": "production"
}
}'
π’ Deployment Options
Option A: Vercel Serverless (Zero Config)
- Push your code to GitHub.
- Import the project into Vercel.
- Under Settings -> Environment Variables, add:
DATABASE_URL:postgres://...(Your Supabase connection string)
- Click Deploy. Vercel compiles the serverless handler via
api/index.goandvercel.json.
Option B: Docker Container
# Build Docker image
docker build -t flagura:latest .
# Run container
docker run -p 3000:3000 -e DATABASE_URL="postgres://..." flagura:latest
π§ͺ Testing & Verification
Run the comprehensive unit and integration test suite:
# Run all Go tests
go test -v ./...
# Recompile Templ components
templ generate
# Build production binary
go build -o bin/flagura main.go
π Operations & Runbooks
Comprehensive SRE, emergency response, and operational runbooks are available in the docs/runbooks/ directory:
- π Deployment & Release Management: Standalone binary, Docker, Vercel serverless, and rollback procedures.
- π Supabase & Vercel Integration Guide: Step-by-step cloud setup, connection pooling, and continuous deployment.
- π¨ Incident Response & Emergency Operations: 1-click kill switch, database outage fallback, latency debugging, and audit forensics.
- ποΈ Database Operations & Disaster Recovery: Supabase PostgreSQL schema, connection pool tuning, and PITR backup/recovery.
- π‘οΈ Security & Access Management: RBAC provisioning, credential rotation, and automated vulnerability triage.
π License
This project is licensed under the MIT License.
Documentation
ΒΆ
There is no documentation for this package.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
client
Package client provides the official Go SDK for Flagura.
|
Package client provides the official Go SDK for Flagura. |
|
openfeature
Package openfeature provides an official OpenFeature Go SDK provider for Flagura.
|
Package openfeature provides an official OpenFeature Go SDK provider for Flagura. |
|
sdks
|
|
|
go
module
|
|
|
views
templ: version: v0.3.1020
|
templ: version: v0.3.1020 |