# Site

## Description

Site represents a physical facility owned or operated by a company — offices, warehouses, stores, factories, and distribution centers. Each site is scoped to a single company and stores a structured address (street, city, state/province, postal code, country), type classification, timezone, and lifecycle state. Sites provide the geographic foundation that downstream modules depend on: inventory uses sites to determine where stock is held, sales and purchasing reference sites for ship-from and ship-to addresses, and tax modules reference sites for jurisdiction determination.

Examples: "Tokyo HQ" (OFFICE), "Osaka Warehouse" (WAREHOUSE), "Shibuya Store" (STORE).

## Domain Model Definitions

### Model type

Stateful

#### State Transitions

```mermaid
stateDiagram-v2
    [*] --> Active: createSite
    Active --> Inactive: deactivateSite
    Inactive --> Active: reactivateSite
```

### Command Definitions

- [createSite](../commands/CreateSite.md) - Create a new site in ACTIVE status
- [updateSite](../commands/UpdateSite.md) - Update site name, address, type, or timezone
- [deactivateSite](../commands/DeactivateSite.md) - Transition site from ACTIVE to INACTIVE
- [reactivateSite](../commands/ReactivateSite.md) - Transition site from INACTIVE to ACTIVE

### Query Definitions

- [getSite](../queries/GetSite.md) - Retrieve a site by ID
- [listSitesByCompany](../queries/ListSitesByCompany.md) - List all sites for a given company

### Models

- Site

### Invariants

- Site name is required, non-empty, and unique within the same company
- Site type is required and must be one of: OFFICE, WAREHOUSE, STORE, FACTORY, DISTRIBUTION_CENTER
- Structured address fields (street, city, postalCode, country) are required at creation
- State/province is optional (not all countries use states or provinces)
- Country must reference a valid country code
- Timezone is required and must be a valid IANA timezone identifier
- companyId is immutable after creation
- The referenced company must exist and be in ACTIVE status at creation time
- Site deletion is not supported; deactivation is used instead to preserve referential integrity with downstream records

### Relationships

- **Belongs To Company**: Each site references exactly one Company via companyId
- **Referenced By Warehouse (future)**: Future warehouse modules will reference sites for storage layout (Warehouse/StorageLocation entities)
- **Referenced By Inventory**: Sites are referenced by inventory for stock-on-hand tracking
- **Referenced By Sales/Purchasing**: Sites are referenced as ship-from and delivery destinations
