Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ToggleMesh Logo

ToggleMesh

Enterprise Feature Flag & Contextual Experimentation Engine

A high-performance, data-private, self-hosted alternative to LaunchDarkly and Statsig. Powered by .NET Core, featuring native SDKs for C#, Python, Go, Node.js, and C++.

Build Status NuGet Package npm JS Package npm Node Package PyPI Package
<30ns Latency 0 Bytes Allocated MIT License

ToggleMesh Admin Dashboard
Manage environments, targeting rules, and A/B tests from a unified, modern interface.


πŸ“– What is ToggleMesh?

ToggleMesh is a self-hosted feature management and experimentation platform designed for teams that require strict data privacy, enterprise-grade RBAC, and ultra-low latency.

Unlike SaaS providers that charge by MAU or require your application to make network calls for flag evaluation, ToggleMesh pushes configurations directly to your servers. Your SDKs evaluate rules locally in memory, ensuring zero network overhead and keeping 100% of your user context within your private infrastructure.

How it compares

Feature ToggleMesh LaunchDarkly Statsig Unleash
Full Self-Hosting βœ… ❌ (Relay only) ❌ βœ…
Data Privacy (No PII leaves network) βœ… ❌ ❌ βœ…
Zero-Allocation Eval (.NET) βœ… ❌ ❌ ❌
Built-in MAB A/B Tests βœ… ❌ βœ… ❌
Real-Time Push βœ… (SSE) βœ… βœ… ⚠️ (Polling)
Pricing Free (MIT) Per-seat Per-MAU Freemium

πŸ—οΈ Architecture

flowchart TD
    classDef ui fill:#18181b,stroke:#3f3f46,stroke-width:2px,color:#f4f4f5;
    classDef api fill:#0f172a,stroke:#6366f1,stroke-width:2px,color:#f4f4f5;
    classDef db fill:#312e81,stroke:#818cf8,stroke-width:2px,color:#f4f4f5;
    classDef cache fill:#7f1d1d,stroke:#f87171,stroke-width:2px,color:#f4f4f5;
    classDef sdk fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#f4f4f5;
    classDef worker fill:#4c1d95,stroke:#a5b4fc,stroke-width:2px,color:#f4f4f5;

    UI[React Admin UI]:::ui -- REST / JWT --> API["ToggleMesh.API<br/>(Management & SSE)"]:::api
    
    API -- Read / Write --> PG[(PostgreSQL)]:::db
    API -- EF Interceptor Publish --> REDIS[(Redis Pub/Sub)]:::cache
    REDIS -. Fan-out Invalidate .-> API
    
    API == SSE Push ==> SDK["Client & Server SDKs<br/>(Zero-Alloc Eval)"]:::sdk

    SDK -- Async Batch Events --> INGEST["ToggleMesh.API<br/>(Ingest Endpoint)"]:::api

    subgraph Analytics Pipeline
        direction LR
        INGEST -- Stream --> KAFKA[(Kafka / Channels)]:::db
        KAFKA -- Consume --> CH[(ClickHouse OLAP)]:::db
        CH -- Bayesian Query --> WORKER[MAB Rollup Worker]:::worker
    end

    WORKER -. Auto-adjust traffic .-> PG
Loading

Control Plane mutates state -> Interceptor triggers Redis Pub/Sub -> API fans out SSE to connected SDKs.


πŸ‘¨β€πŸ’» Quick Start

Prerequisite: A running ToggleMesh server instance. See Self-Hosting & Deployment to spin one up locally in under a minute.

Step 0: Install the Tools

Install the C# SDK and the Global CLI tool:

dotnet add package ToggleMesh.SDK
dotnet tool install --global ToggleMesh.CLI

Step 1: Zero-Config Context Injection

Register the SDK in your DI container. ToggleMesh can automatically hook into your ambient HttpContext to extract user identity, emails, and roles without manual context passing.

// Program.cs
builder.Services.AddToggleMeshClient(options => 
{
    options.BaseUrl = "https://api.togglemesh.dev"; // Your self-hosted Control Plane
    options.ApiKey = "tm_server_xxxxxxxx";
}).AddToggleMeshHttpContext(); 

Step 2: Sync Constants & Evaluate

Sync your flags to generate type-safe constants, then evaluate them in your business logic.

$ togglemesh config
$ togglemesh sync
βœ” Success! Auto-detected C# project. Generated ToggleMeshFlags.g.cs
// CheckoutService.cs
public void ProcessOrder(IToggleMeshClient toggleMesh) 
{
    // Evaluates instantly from in-memory cache. Zero HTTP requests made.
    if (toggleMesh.IsEnabled(Flags.NewCheckoutFlow)) 
    {
        ExecuteNextGenGateway();
    }
}

⚑ Performance & Benchmarks

ToggleMesh is engineered for ultra-low-latency microservices where Garbage Collection (GC) pauses are unacceptable.

By leveraging compiled Expression Trees, pre-computed rule groups, C# Source Generators, and readonly ref struct contexts, the ToggleMesh SDK achieves zero-allocation evaluation.

BenchmarkDotNet Results

We benchmarked various scenarios: from a simple global toggle to a worst-case scenario evaluating 10 nested AND/OR targeting rules.

Method Mean StdDev Max P95 Allocated
Evaluate_NoRules_AOT (Baseline) 6.73 ns 0.02 ns 6.76 ns 6.76 ns -
Evaluate_1Rule_AOT (Typical) 28.13 ns 0.08 ns 28.29 ns 28.24 ns -
Evaluate_ComplexRule_AOT (MAB/Rollout) 92.75 ns 0.35 ns 93.19 ns 93.15 ns -
Evaluate_10Rules_AOT (Worst-case) 120.21 ns 0.37 ns 120.75 ns 120.57 ns -
TrackEvent_10Rules_AOT (Metrics Buffer) 45.52 ns 0.15 ns 45.77 ns 45.77 ns -

Hardware Specs: Intel Core i7-14700K, 20 Physical Cores, Windows 11 x64, .NET 10.0 Release Build.

Extreme High-Throughput (Load Testing)

ToggleMesh decouples heavy I/O operations from the HTTP request-response cycle using bounded in-memory channels (System.Threading.Channels) with DropOldest backpressure.

Local load testing via k6 on a single developer workstation demonstrates the massive throughput capabilities of the Data Plane API.

Endpoint Type Target VUs Max RPS p(99) Tail Latency Error Rate
POST /api/v1/sdk/metrics Fire & Forget (Channel) 2,000 115,248/s 18.59 ms 0.00%
POST /api/v1/sdk/evaluate Synchronous (Compute) 2,000 112,503/s 19.22 ms 0.00%
POST /api/v1/sdk/events Buffered + Livetail (SSE) 2,000 68,301/s 34.58 ms 0.00%
GET /api/v1/sdk/flags Synchronous (I/O Cache) 2,000 68,463/s 36.06 ms 0.00%

Test Environment: Intel Core i7-14700K, k6 running locally against Kestrel (Release mode, HTTP). All tests maintained a flawless 0.00% failure rate under sustained load. Data payload bandwidth maxed out at ~179 MB/s during sync.


πŸ’» Ecosystem & Supported SDKs

ToggleMesh provides native SDKs and tooling for your entire microservice fleet.

Language / Platform SDK Type Real-Time Sync Targeting Evaluation Maturity
.NET (C#) Server βœ… (SSE) Local (Zero-Alloc) Stable
Node.js Server βœ… (SSE) Local Beta
Browser JS / React Client βœ… (SSE) Remote (Secure) Beta
Python Server βœ… (SSE) Local Beta
Go Server βœ… (SSE) Local MVP
Unreal Engine (C++) Game Client πŸ”„ (Polling) Remote MVP

🏒 Enterprise-Grade Features

  • πŸ“‘ Push, Not Pull (SSE + Redis): Real-time cache invalidation using Server-Sent Events. No wasteful HTTP polling.
  • 🎯 Advanced Targeting Engine: Individual user overrides, Contextual Percentage Rollouts, and Semantic Versioning (SemVer) operators synchronized across all supported SDKs.
  • πŸŽ›οΈ Multivariate Flags & Remote Config: Move beyond simple booleans. Serve strongly-typed JSON, strings, or numeric payloads dynamically to your clients, enabling complex UI theming, game balancing, and multi-variant A/B/C testing without deploying new code.
  • 🧠 Contextual Multi-Armed Bandits (MAB): Built-in Bayesian inference engine (Monte Carlo simulations via Beta distributions). Autonomously shifts traffic toward winning variants based on conversion or revenue metrics.
  • πŸ”¬ Sample Ratio Mismatch (SRM) Detection: Automated background statistical checks (Chi-Square) to detect tracking bugs or critical assignment skews in your A/B tests before they ruin your data.
  • πŸ“ˆ High-Throughput Analytics Ingestion: SDKs buffer metrics client-side. The API ingests telemetry into bounded System.Threading.Channels with DropOldest backpressure, flushing to PostgreSQL or horizontally scalable Kafka + ClickHouse clusters.
  • πŸ”Œ Integrations & Webhooks: Native Slack and MS Teams notifications, plus SSRF-Protected outbound webhook dispatcher with Polly-powered exponential backoff and Dead-Letter Queues (DLQ).
  • πŸ” Multi-Tenancy & Security: Organization and Project-level isolation with strict Role-Based Access Control and Two-Factor Authentication.
  • πŸ”’ GDPR-Ready by Design: Identity pseudonymization, automatic data retention, PII property redaction, and one-click user data erasure.
  • πŸ”‘ Personal Access Tokens (PATs): SHA-256 hashed PATs for secure CI/CD and CLI integrations.
  • πŸ“œ Immutable Audit Logs: Every configuration change is captured with deep before/after JSON diffs.
  • πŸ’Ύ Offline Resilience: SDKs persist the latest synchronized state to a local JSON fallback file, ensuring safe boot-ups during complete network partitions.

🐳 Self-Hosting & Deployment

Quick Start (PostgreSQL + Redis)

Deploying the core ToggleMesh stack takes under a minute.

curl -o docker-compose.yml https://raw.githubusercontent.com/sdwck/ToggleMesh/main/docker-compose.yml
curl -o .env https://raw.githubusercontent.com/sdwck/ToggleMesh/main/.env.example
docker compose up -d
  • Admin UI & API: http://localhost:5264
  • API Docs (Scalar): http://localhost:5264/docs

Enterprise Stack (+ Kafka & ClickHouse)

For production deployments requiring high-throughput analytics and horizontal OLAP scaling, boot the stack using the enterprise override:

curl -o docker-compose.enterprise.yml https://raw.githubusercontent.com/sdwck/ToggleMesh/main/docker-compose.enterprise.yml
docker compose -f docker-compose.yml -f docker-compose.enterprise.yml up -d

🀝 Contributing & License

ToggleMesh is released under the MIT License.
Contributions are welcome β€” please read our Contributing Guidelines before opening a PR.


⭐ If ToggleMesh looks useful, star this repo β€” it helps others discover it.
Report a Bug Β· Request a Feature

About

Enterprise-grade, zero-allocation feature flag and A/B testing engine. Built in .NET for ultimate performance, designed for polyglot distributed systems.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages