Feature flag documentation - Real-Dev-Squad/feature-flag-backend GitHub Wiki

Feature Flag Service Documentation

📚 Introduction

  • What is a Feature Flag?
  • Why this service exists (e.g., "Control feature rollout, A/B testing, kill switches").
  • Brief on how it works conceptually (toggle on/off for users or all).
  • Having a centralised place to control all feature flags, instead of managing their rollout in service configs / ENVs.

⚙️ Architecture Overview

Include a diagram if possible.

a. AWS Services Used:

  • AWS API gateway -> (for routing requests to different lambdas)
  • AWS Systems manager -> to store the public key safely
  • AWS lambda
  • AWS DynamoDb
  • Cloudwatch -> for monitoring + APM (if enabled X-ray tracing)

🛠️ Using the Feature Flag API

1. ➕ Create a feature flag

API Endpoint

POST `/feature-flags`

Request object

{
    "name": "Test-flag-via-postman",
    "description": "Feature flag created via postman",
    "userId":"vikhyat"
}

Sucess Response object

{
    "data": {
        "id": "0cffec18-518a-41b2-b5e5-86604c06c38c",
        "name": "Test-flag-via-postman",
        "description": "Feature flag created via postman",
        "createdAt": 1745424103,
        "createdBy": "vikhyat",
        "updatedAt": 1745424103,
        "updatedBy": "vikhyat",
        "status": "ENABLED"
    },
    "message": "Created feature flag successfully"
}

Error Response object

{
   "message": "Internal server error"
}

2. 🔍 Get a feature flag

API Endpoint

GET `/feature-flags/{flagId}`

Request object

Empty

Path param

<flagId> - uuid for identifying the feature flags

Sucess Response object

{
    "id": "0cffec18-518a-41b2-b5e5-86604c06c38c",
    "name": "Test-flag-via-postman",
    "description": "Feature flag created via postman",
    "status": "ENABLED",
    "createdAt": 1745424103,
    "createdBy": "vikhyat",
    "updatedAt": 1745424103,
    "updatedBy": "vikhyat"
}

Error Response object

Currently this is passed in the body, we need to change this to pass it in JSON format

404 Feature Flag not found 

3. 🔄 Update a feature flag

API Endpoint

PATCH `/feature-flags/{flagId}`

Path param

 <flagId> passing uuid of the feature flag

Request object

{
    "status": "DISABLED",
    "userId": "vikhyat187"
}

Sucess Response object

{
    "id": "22d400ca-8736-4c11-8a48-c74ff7d66f09",
    "name": "Test-flag-via-postman",
    "description": "Feature flag created via postman",
    "status": "DISABLED",
    "createdAt": 1744734096,
    "createdBy": "vikhyat",
    "updatedAt": 1745425567,
    "updatedBy": "vikhyat187"
}

Error Response object

{
   "message": "Internal server error"
}

4. 👤 Create user-specific override

API Endpoint

POST `/users/{userId}/feature-flags/{flagId}`

Path param

<userId>  -> user for which feature flag has to be enabled
<flagId> -> feature flag which has to be enabled

Request object

{
    "status": "DISABLED",
    "userId": "vikhyat187" -> this is the user Id to store in the `createdBy` / `updatedBy` column
}

Sucess Response object

{
    "userId": "vikhyat",
    "flagId": "22d400ca-8736-4c11-8a48-c74ff7d66f09",
    "status": "DISABLED",
    "createdAt": 1745425825,
    "createdBy": "vikhyat187",
    "updatedAt": 1745425825,
    "updatedBy": "vikhyat187"
}

Error Response object

{
   "message": "Internal server error"
}

5. 🔍 Fetch User-Specific Feature Flag Details

API Endpoint

GET `/users/{userId}/feature-flags/{flagId}`

Path param

<userId>  -> user for which feature flag has to be enabled
<flagId> -> feature flag which has to be enabled

Request object

Empty

Sucess Response object

{
    "userId": "1234",
    "flagId": "22d400ca-8736-4c11-8a48-c74ff7d66f09",
    "status": "DISABLED",
    "createdAt": 1744735629,
    "createdBy": "vikhyat187",
    "updatedAt": 1745425794,
    "updatedBy": "vikhyat187"
}

Error Response object

{
   "message": "Internal server error"
}

6. 🔍 Fetch All Feature Flags for a User

API Endpoint

GET `/users/{userId}/feature-flags/

Path param

<userId>  -> user for which feature flag has to be enabled

Request object

Empty

Sucess Response object

[
    {
        "userId": "1234",
        "flagId": "22d400ca-8736-4c11-8a48-c74ff7d66f09",
        "status": "DISABLED",
        "createdAt": 1744735629,
        "createdBy": "vikhyat187",
        "updatedAt": 1745425794,
        "updatedBy": "vikhyat187"
    }
]

Error Response object

{
   "message": "Internal server error"
}

7. 🌐 Get All Feature Flags (Global)

API Endpoint

GET `/feature-flags`

Request object

Empty

Sucess Response object

[
    {
        "id": "0cffec18-518a-41b2-b5e5-86604c06c38c",
        "name": "Test-flag-via-postman",
        "description": "Feature flag created via postman",
        "status": "ENABLED",
        "createdAt": 1745424103,
        "createdBy": "vikhyat",
        "updatedAt": 1745424103,
        "updatedBy": "vikhyat"
    },
    {
        "id": "22d400ca-8736-4c11-8a48-c74ff7d66f09",
        "name": "Test-flag-via-postman",
        "description": "Feature flag created via postman",
        "status": "DISABLED",
        "createdAt": 1744734096,
        "createdBy": "vikhyat",
        "updatedAt": 1745425567,
        "updatedBy": "vikhyat187"
    },
    {
        "id": "aaf474b1-0b0f-44d3-a648-82ac6754d7ba",
        "name": "Test-flag-via-postman",
        "description": "Feature flag created via postman",
        "status": "ENABLED",
        "createdAt": 1744733459,
        "createdBy": "vikhyat",
        "updatedAt": 1744733459,
        "updatedBy": "vikhyat"
    }
]

Error Response object

{
   "message": "Internal server error"
}

8. 🔄 Update Concurrency

API Endpoint

POST `/reset-limit

Request object

{
    "pendingLimit": 20
}

Sucess Response object

Successfully updated concurrency limit

Error Response object

{
   "message": "Internal server error"
}

9. ♻️ Reset Lambda Concurrency to Zero

API Endpoint

PATCH `/mark-concurrency-zero`

Request object

Empty

Sucess Response object

Changed the reserved concurrency of the lambda function GetFeatureFlagFunction

Error Response object

{
   "message": "Internal server error"
}

📎 Appendix Glossary for beginners (SSM, IAM, Lambda, Dynamodb, Cloudwatch, API gateway.)

⚠️ **GitHub.com Fallback** ⚠️