A backend service that allows teams to control feature releases using runtime-configurable feature flags and percentage-based rollouts.
This project demonstrates a common production pattern used to safely deploy new features without redeploying code.
- Stores feature flags with rollout configuration
- Determines whether a feature is enabled for a specific user
- Supports gradual rollouts using percentage-based sampling
- Logs feature evaluation results for debugging and observability
- Provides a simple admin interface to manage feature flags
Each feature has:
- A global ON/OFF switch
- A rollout percentage (0–100)
Even when a feature is enabled, only a subset of users may receive it depending on the rollout percentage.
When a request is made to check a feature:
- The feature configuration is loaded from the database
- A rollout decision is calculated
- The result is logged for later inspection
- The enabled/disabled decision is returned
GET /check-feature?user_id=&feature_name=
Returns whether the feature is enabled for the given user.
POST /features GET /features PUT /features/{feature_name}
Allows creation, listing, and modification of feature flags.
A lightweight HTML-based admin UI is included to:
- View all feature flags
- Toggle feature availability
- Adjust rollout percentages
The UI communicates directly with the backend APIs.
http://127.0.0.1:8000/static/admin.html
python3 -m venv venv
source venv/bin/activate
pip install fastapi uvicorn sqlalchemy
uvicorn main:app --reload
Project Structure
feature-flag-service/ */n*
├── main.py # API routes and business logic
├── models.py # Database models
├── schemas.py # Request/response schemas
├── database.py # Database configuration
├── static/ # Admin UI
└── README.md
Design Notes SQLite is used for simplicity and local development Authentication is intentionally omitted The focus is on backend logic and system design Designed to be extended with auth, caching, or persistence layers
MIT