Introduction to Flaggy¶
Flaggy is a simple, fast, and modular feature flag library for .NET that helps you manage feature toggles with ease. It provides a clean API for creating, managing, and evaluating feature flags in your applications.
What are Feature Flags?¶
Feature flags (also known as feature toggles) are a software development technique that allows you to enable or disable features in your application without deploying new code. This approach provides several benefits:
- Continuous Delivery: Deploy code to production but keep features disabled until ready
- Risk Mitigation: Quickly disable problematic features without rollback
- A/B Testing: Test different versions of features with different user groups
- Gradual Rollouts: Roll out features to a percentage of users gradually
- Configuration Management: Manage application behavior dynamically
Why Flaggy?¶
Simple and Intuitive¶
Flaggy provides a clean, simple API that makes working with feature flags straightforward:
// Check if a feature is enabled
if (await flagService.IsFlagEnabledAsync("new-feature"))
{
// Use new feature
}
Multiple Storage Options¶
Choose the storage provider that fits your needs:
- InMemory: Perfect for development and testing (with JSON persistence)
- MySQL: Production-ready with automatic migrations
- PostgreSQL: Robust relational database support
- MS SQL Server: Enterprise-grade database support
Built-in Caching¶
Flaggy includes intelligent caching to minimize database calls:
- MemoryCache: Fast in-memory caching (default)
- Redis: Distributed caching for multi-server deployments
- Automatic Invalidation: Cache is automatically cleared when flags change
Rich Dashboard UI¶
Manage your feature flags through a beautiful web interface:
- Flag Management: Create, edit, and delete flags
- User Management: Control who can access the dashboard
- Real-time Updates: See changes immediately
- Secure Authentication: BCrypt password hashing and secure sessions
Programmatic API¶
Full CRUD operations without the UI:
// Create a flag
await flagService.CreateFlagAsync(new FeatureFlag
{
Key = "new-feature",
IsEnabled = true,
Description = "My new feature"
});
// Update a flag
await flagService.EnableFlagAsync("new-feature");
// Delete a flag
await flagService.DeleteFlagAsync("new-feature");
Flag Values¶
Store not just boolean states, but actual values:
// Store a string value
await flagService.UpsertFlagAsync("theme", true, value: "dark");
// Retrieve typed values
var theme = await flagService.GetValueAsync<string>("theme", "light");
// Store numeric values
await flagService.UpsertFlagAsync("max-users", true, value: "1000");
var maxUsers = await flagService.GetValueAsync<int>("max-users", 100);
Key Concepts¶
Feature Flag¶
A feature flag consists of:
- Key: Unique identifier for the flag (e.g., "new-checkout-flow")
- IsEnabled: Whether the flag is active
- Value: Optional value associated with the flag
- Description: Human-readable description
Provider¶
A provider is responsible for storing and retrieving feature flags. Flaggy supports multiple providers:
InMemoryFeatureFlagProviderMySqlFeatureFlagProviderPostgreSqlFeatureFlagProviderMsSqlFeatureFlagProvider
Service¶
The IFeatureFlagService is the main interface for interacting with feature flags. It provides methods for:
- Checking if a flag is enabled
- Getting flag values
- Creating, updating, and deleting flags
- Listing all flags
Cache¶
Caching improves performance by reducing database calls. Flaggy supports:
- Memory Cache: Uses
IMemoryCachefor fast in-process caching - Redis Cache: Uses Redis for distributed caching across servers
Architecture¶
┌─────────────────┐
│ Your App │
└────────┬────────┘
│
▼
┌─────────────────┐
│ FeatureFlagService│
└────────┬────────┘
│
┌────┴────┐
│ │
▼ ▼
┌───────┐ ┌─────────┐
│ Cache │ │Provider │
└───────┘ └─────────┘
│
▼
┌─────────┐
│Database │
└─────────┘
Next Steps¶
Ready to get started? Follow these guides:
- Installation - Install and configure Flaggy
- Basic Usage - Create your first feature flag
- Features - Explore all features
Learn More¶
- Examples - See Flaggy in action
- API Reference - Complete API documentation
- Best Practices - Production-ready patterns