Skip to content

Support multiple products in a single flash-sale event #3

Description

@piush365

Background

The current system is hardcoded to a single product (IPHONE15). A real flash-sale platform runs many products concurrently — each with its own inventory, rate limit, and possibly different per-user purchase limits.

Proposed Change

Domain model

Remove the hardcoded defaultProductId assumption. Inventory keys already follow the pattern stock:product:{productId}, so Redis is already multi-product — only the initialisation and health indicator need updating.

New endpoint (or extend existing)

Allow admins to seed inventory for any product:

POST /api/v1/admin/products/{productId}/inventory
Body: { "stock": 500 }

Secured separately (admin role, not general API key).

Per-product config

flashsale:
  products:
    IPHONE15: { initial-stock: 100, rate-limit: 3 }
    PS5:      { initial-stock: 50,  rate-limit: 1 }

Acceptance Criteria

  • FlashSaleProperties extended with a products map
  • InventoryConfig seeds all configured products on startup
  • FlashSaleHealthIndicator reports stock for every configured product
  • Integration test verifies two products can be bought independently without interference
  • Admin endpoint is protected and documented in Swagger UI

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions