Skip to content

Backend: Add per-tenant feature flag service for staged rollout of new endpoints #1191

Description

@Baskarayelu

Description

QuickLendX rolls out new endpoints (KYC tiers, dispute composer, bid ranking changes) but has no per-tenant flag. Today every API key sees the same routes regardless of stage. A simple sqlite-backed feature-flag service keyed by (api_key_id, flag) lets us roll out endpoints to a subset of customers without separate deployments. Distinct from the static OpenAPI versioning in #836.

Requirements and context

  • Add backend/src/services/featureFlagService.ts reading from a feature_flags table.
  • Add middleware backend/src/middleware/feature-flag.ts that 404s when a flag is off for the current API key.
  • Provide admin endpoints to toggle flags.
  • Document in backend/docs/admin-monitoring.md.

Suggested execution

Create branch feature/per-tenant-feature-flags:

  • Add migration backend/src/migrations/v006_feature_flags.ts.
  • Add backend/src/services/featureFlagService.ts and backend/src/middleware/feature-flag.ts.
  • Add admin route in backend/src/routes/v1/admin.ts.
  • Add backend/src/tests/feature-flag.test.ts.
  • Update backend/docs/admin-monitoring.md.

Test and commit

Run npm test -- feature-flag. Cover: flag-on tenant sees endpoint, flag-off tenant 404s, default (no row) treats flag as off, admin toggle audited, cache invalidates on toggle. Confirm the flag check adds <1ms overhead.

Example commit message

feat: add per-tenant feature flag service for staged rollouts

Guidelines

  • Minimum 95% test coverage
  • Document flag administration in backend/docs/admin-monitoring.md
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox OSS campaignMAYBE REWARDEDGrantFox OSS campaignOFFICIAL CAMPAIGNGrantFox OSS campaignStellar WaveIssues in the Stellar wave programapiAPI surfacebackendBackend services and APIsenhancementFeature enhancement

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions