Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
Menu
Feature Flags - Enable Functionality from the BackEnd

Feature Flags – Enable Functionality from the BackEnd

Posted on November 16, 2025November 16, 2025 by Toma Velev

Feature Flags let you turn features on/off dynamically from the BackEnd, without redeploying your app. They’re perfect when you want features to depend on server load, user profile, A/B tests, or any other dynamic condition.

Below is a clean mental model you can directly apply (Flutter, Java backend, etc.).

✅ What Feature Flags Solve

Feature flags allow you to:

✔ Gradually roll out features

Enable for 5% of users → 20% → 100%.

✔ Disable features when resources are low

Example: turn off expensive AI calls when GPU load is high.

✔ Personalize based on user

Premium users get a feature; free users don’t.

✔ Hotfix without deployment

If something breaks, switch it off instantly from the backend.

✔ Run experiments (A/B testing)

Try multiple versions of the same feature.


🧠 How It Works Conceptually

Your backend exposes something like:

GET /api/feature-flags
Headers: userId=123

Response example:

{
  "newUi": true,
  "voiceAssistant": false,
  "gpuHeavyProcessing": false,
  "betaFeatures": ["emotionTracker"]
}

Your frontend checks these flags before showing or enabling things.


🔧 Where Do Flags Come From?

You can base them on anything:

1. Server Resource Availability

Monitor metrics:

  • CPU usage
  • Memory
  • GPU availability
  • Queue backlog
  • API rate limits

And return flags accordingly:

boolean gpuAvailable = gpuLoad < 70;
flags.put("gpuHeavyProcessing", gpuAvailable);

2. User Data / Permissions

    • user role
    • subscription plan
    • geo location
    • age
    • beta-testing group
    • parental control

Example:

flags.put("newUi", user.isPremium());
flags.put("kidsMode", user.getAge() < 13);

3. Traffic / Scaling Strategy

Use flags to control load:

if (totalActiveUsers > MAX_SAFE_USERS) {
    flags.put("backgroundSync", false);
}

4. App Version

Ensure only updated clients get a new feature.


🌐 Backend Example: Java + Spring Boot

@RestController
public class FeatureFlagController {

    @GetMapping("/flags")
    public Map<String, Object> getFlags(@RequestParam long userId) {

        User user = userService.find(userId);

        Map<String, Object> flags = new HashMap<>();

        // User-based flags
        flags.put("premiumDashboard", user.isPremium());
        flags.put("kidMode", user.getAge() < 13);

        // Resource-based flags
        double cpu = monitoringService.getCpuUsage();
        flags.put("heavyProcessing", cpu < 70);

        // AB testing flag
        flags.put("newOnboarding", userId % 2 == 0);

        // Geo-based
        flags.put("voiceAssistant", user.getCountry().equals("BG"));

        return flags;
    }
}

📱 Frontend Example: Flutter

Fetch at startup:

final response = await http.get(Uri.parse("$baseUrl/flags?userId=$userId"));
final flags = jsonDecode(response.body);

Use in UI:

if (flags["newUi"] == true) {
  return NewHomeScreen();
} else {
  return OldHomeScreen();
}

Use in logic:

if (flags["heavyProcessing"] == true) {
  startHeavyAI();
} else {
  showSnackBar("Server is busy, try later");
}

🎯 Possible Feature Flags You Can Add (ideas)

Server-based:

  • "enableAvatarGeneration" → disabled when GPU busy
  • "batchJobs" → disabled when queue grows
  • "speechToText" → based on API usage per hour

User-based:

  • "betaChatMode"
  • "emotionTracker" (you mentioned this app idea!)
  • "calorieCounterAI" → premium users
  • "darkModeV2" based on app version

Environment-based:

  • "showDebugMenu"
  • "forceUpdate"

💡 Tips for Production

  • Cache flags (TTL 15–60 seconds or an hour-two or days or weeks (for the appropiate cases))
  • Combine your server + remote config (Firebase, LaunchDarkly, ConfigCat)
  • Add logs for each flag decision
  • Jenkins SCP File Upload to Remote Server
  • Essential Programming Books – Principles & Flutter
  • Social Media Platforms 🌍
  • Strategies to prevent review regressions
  • How to set Google Map Theme in a Flutter App

Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (269)
  • Graphical User Interface (14)
  • Marketing (117)
  • Software Development (286)
  • Spring (45)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (15)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (84)
    • Flutter Apps (24)
    • GPT (4)
    • Java (38)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (35)
    • Utils (15)
    • Vaadin 24+ (27)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • Jenkins SCP File Upload to Remote Server
  • Essential Programming Books – Principles & Flutter
  • Social Media Platforms 🌍
  • Strategies to prevent review regressions
  • How to set Google Map Theme in a Flutter App

Post Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (269)
  • Graphical User Interface (14)
  • Marketing (117)
  • Software Development (286)
  • Spring (45)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (15)