Feature: Introduce TenantContext and Tenant Detection #1

Closed
opened 2026-06-25 19:30:20 +00:00 by psycodepath · 0 comments
Owner

Motivation

To support multi-tenancy, the application needs a robust, abstract way to represent and detect the currently active tenant from incoming HTTP requests.

Description

Create a TenantContext domain model and a TenantDetectorInterface port, along with a concrete SubdomainTenantDetector adapter that determines the active tenant using the request's hostname.

User Story

As a host, I want the system to detect which family is accessing the application based on the subdomain so that the application can serve their specific data.

Gherkin Feature

Feature: Tenant Detection
  As the HRP application
  I want to detect the current tenant from the host name
  So that I can load tenant-specific data

  Scenario: Valid tenant subdomain
    Given the request host is "family1.localhost"
    When the tenant detector runs
    Then the active tenant ID should be "family1"

  Scenario: Missing tenant subdomain
    Given the request host is "localhost"
    When the tenant detector runs
    Then the active tenant ID should be empty or resolve to default

Acceptance Criteria

  • TenantContext value object created under Kernel\Domain.
  • TenantDetectorInterface created under Kernel\Domain.
  • SubdomainTenantDetector implemented under Kernel\Infrastructure resolving tenant from host.
  • Unit tests for subdomain extraction and fallback handling.
### Motivation To support multi-tenancy, the application needs a robust, abstract way to represent and detect the currently active tenant from incoming HTTP requests. ### Description Create a `TenantContext` domain model and a `TenantDetectorInterface` port, along with a concrete `SubdomainTenantDetector` adapter that determines the active tenant using the request's hostname. ### User Story As a host, I want the system to detect which family is accessing the application based on the subdomain so that the application can serve their specific data. ### Gherkin Feature ```gherkin Feature: Tenant Detection As the HRP application I want to detect the current tenant from the host name So that I can load tenant-specific data Scenario: Valid tenant subdomain Given the request host is "family1.localhost" When the tenant detector runs Then the active tenant ID should be "family1" Scenario: Missing tenant subdomain Given the request host is "localhost" When the tenant detector runs Then the active tenant ID should be empty or resolve to default ``` ### Acceptance Criteria - [ ] `TenantContext` value object created under `Kernel\Domain`. - [ ] `TenantDetectorInterface` created under `Kernel\Domain`. - [ ] `SubdomainTenantDetector` implemented under `Kernel\Infrastructure` resolving tenant from host. - [ ] Unit tests for subdomain extraction and fallback handling.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
psycodepath/hrp#1
No description provided.