# product-lifecycle

## Overview

Manages the full lifecycle of products. Product managers create products in DRAFT status, edit product information, activate products for operational use, deactivate to archive, reactivate as needed, and delete DRAFT products. Viewers can browse and view product details.

## Actors Involved

- [product-manager](../../actor/product-manager.md)
- [viewer](../../actor/viewer.md)

## Flow Diagram

```mermaid
sequenceDiagram
    actor PM as product-manager
    actor V as viewer
    participant System

    PM->>System: Create Product (DRAFT)
    alt Valid
        System-->>PM: Product created in DRAFT
    else Duplicate code
        System-->>PM: Error: Product code already exists
    end
    PM->>System: Edit Product
    alt Valid
        System-->>PM: Product updated
    else UoM change on non-DRAFT
        System-->>PM: Error: UoM locked after activation
    end
    PM->>System: Activate Product (DRAFT → ACTIVE)
    System-->>PM: Product activated
    PM->>System: Browse Product List
    System-->>PM: Paginated product list
    PM->>System: View Product Detail
    System-->>PM: Product details with attributes and categories
    V->>System: Browse Product List
    System-->>V: Paginated product list
    V->>System: View Product Detail
    System-->>V: Product details
    alt Deactivate
        PM->>System: Deactivate Product (ACTIVE → ARCHIVED)
        System-->>PM: Product archived
    end
    alt Reactivate
        PM->>System: Reactivate Product (ARCHIVED → ACTIVE)
        System-->>PM: Product reactivated
    end
    alt Delete (DRAFT only)
        PM->>System: Delete Product
        alt DRAFT
            System-->>PM: Product deleted
        else Not DRAFT
            System-->>PM: Error: Only DRAFT products can be deleted
        end
    end
```

## Stories

- [Create Product](./story/product-manager--create-product.md)
- [Edit Product](./story/product-manager--edit-product.md)
- [Activate Product](./story/product-manager--activate-product.md)
- [Deactivate Product](./story/product-manager--deactivate-product.md)
- [Reactivate Product](./story/product-manager--reactivate-product.md)
- [Delete Product](./story/product-manager--delete-product.md)
- [Browse Product List (Product Manager)](./story/product-manager--browse-product-list.md)
- [View Product Detail (Product Manager)](./story/product-manager--view-product-detail.md)
- [Browse Product List (Viewer)](./story/viewer--browse-product-list.md)
- [View Product Detail (Viewer)](./story/viewer--view-product-detail.md)
