> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vinmake.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Product Library

> The reusable catalog — styles, materials, BOM/BOL, and SKUs that feed costing

# Product Library

The Product Library is the reusable catalog behind every order. A **style** carries its tech packs and photos; **materials** define what it's made of; the **BOM** (bill of materials) and **BOL** (bill of labor) list quantities and operations; and **SKUs** enumerate the color/size variants. Together they feed **costing** — nothing is priced without a BOM.

## The flow

```mermaid theme={null}
flowchart LR
    Style[Style] --> Files[Tech Pack / Photos]
    Style --> BOM[BOM · materials]
    Style --> BOL[BOL · labor]
    BOM --> Approve{Approved?}
    Approve -->|reject| BOM
    Approve -->|approve| SKUs[Generate SKUs]
    BOM --> Costing[Costing]
    BOL --> Costing
    SKUs --> Costing
```

```mermaid theme={null}
sequenceDiagram
    actor Staff
    participant API
    participant Style
    participant BOM
    participant Material
    participant SKU

    Staff->>API: POST /api/v1/styles
    API->>Style: create style
    Staff->>API: POST /api/v1/styles/{id}/tech-packs
    Staff->>API: POST /api/v1/bom (for style)
    API->>BOM: create BOM + version
    Staff->>API: POST /api/v1/bom/versions/{vid}/line-items
    Staff->>API: POST /api/v1/bom/line-items/{lid}/assign-material
    API->>Material: link material to line item
    Staff->>API: POST /api/v1/styles/{id}/skus/generate
    API->>SKU: bulk-generate color/size SKUs
    Staff->>API: POST /api/v1/bom/{id}/submit
    Staff->>API: POST /api/v1/bom/{id}/approve
```

## Styles

A style is the master record for a garment design. It anchors the tech packs, BOM, and SKUs.

```bash theme={null}
GET /api/v1/styles
POST /api/v1/styles
GET /api/v1/styles/{sid}
PATCH /api/v1/styles/{sid}
Authorization: Bearer <access_token>
```

### Create a style

<ParamField body="name" type="string" required>
  Style name.
</ParamField>

<ParamField body="ref" type="string">
  Style reference code. Auto-generated if omitted.
</ParamField>

```bash theme={null}
POST /api/v1/styles
Authorization: Bearer <access_token>

{
  "name": "Heavyweight Crew Tee",
  "ref": "ST-CREW-001",
  "category": "tops"
}
```

**Response (201):**

```json theme={null}
{
  "id": "uuid",
  "ref": "ST-CREW-001",
  "name": "Heavyweight Crew Tee"
}
```

Look up by reference with `GET /api/v1/styles/by-ref/{ref}`.

## Styles Files — tech packs & photos

Each style carries its construction documents and reference imagery.

```bash theme={null}
GET  /api/v1/styles/{style_id}/tech-packs
POST /api/v1/styles/{style_id}/tech-packs
POST /api/v1/styles/{style_id}/tech-packs/links
GET  /api/v1/styles/{style_id}/photos
POST /api/v1/styles/{style_id}/photos
PATCH /api/v1/styles/{style_id}/photos/{photo_id}/set-primary
Authorization: Bearer <access_token>
```

## Materials

Materials are the fabrics, trims, and accessories the BOM consumes. They are versioned and run through a draft → verify → submit workflow.

```bash theme={null}
GET /api/v1/materials
POST /api/v1/materials
GET /api/v1/materials/{material_id}/detail
PATCH /api/v1/materials/{material_id}
Authorization: Bearer <access_token>
```

Get the next reference code with `GET /api/v1/materials/next-ref`. Material versions and verification run through `POST /materials/{document_id}/verify` and `POST /materials/{document_id}/version`.

## BOM — Bill of Materials

The BOM lists every material a style consumes, with quantities and wastage. BOMs are **versioned** and gated by an approval workflow before they can drive costing or material requests.

```bash theme={null}
GET /api/v1/bom
POST /api/v1/bom
GET /api/v1/bom/{bom_id}
PATCH /api/v1/bom/{bom_id}
Authorization: Bearer <access_token>
```

### Add and assign line items

Line items live on a BOM **version**. Each line item is then linked to a concrete material.

```bash theme={null}
POST /api/v1/bom/versions/{version_id}/line-items
PATCH /api/v1/bom/line-items/{line_item_id}
POST /api/v1/bom/line-items/{line_item_id}/assign-material
```

<ParamField body="material_id" type="string" required>
  The material to assign to this BOM line item.
</ParamField>

```bash theme={null}
POST /api/v1/bom/line-items/{line_item_id}/assign-material
Authorization: Bearer <access_token>

{
  "material_id": "uuid"
}
```

### Versioning & approval

```bash theme={null}
POST /api/v1/bom/{bom_id}/submit
POST /api/v1/bom/{bom_id}/approve
POST /api/v1/bom/{bom_id}/reject
POST /api/v1/bom/{bom_id}/withdraw
POST /api/v1/bom/{bom_id}/versions
GET  /api/v1/bom/{bom_id}/versions/{version_a}/compare/{version_b}
GET  /api/v1/bom/{bom_id}/usage
```

<Info>
  `GET /api/v1/bom/{bom_id}/usage` shows which orders and cost sheets reference a BOM — check it before withdrawing or revising an approved BOM.
</Info>

## BOL — Bill of Labor

The BOL is the labor counterpart to the BOM: it lists the sewing operations and their times. Like the BOM, it is versioned and approved, and it can estimate labor cost directly.

```bash theme={null}
GET  /bol
POST /bol
POST /bol/{bol_id}/estimate-labor
POST /bol/{bol_id}/submit-review
POST /bol/{bol_id}/approve
POST /bol/{bol_id}/reject
POST /bol/{bol_id}/create-version
GET  /bol/{bol_id}/compare
Authorization: Bearer <access_token>
```

<Tip>
  `POST /bol/{bol_id}/estimate-labor` produces the labor figure that flows into the cost sheet — see Labor Cost in the **Order Lifecycle** page.
</Tip>

## SKUs

SKUs enumerate the color/size variants of a style (and of materials). They are typically bulk-generated from the style's option matrix rather than entered by hand.

```bash theme={null}
GET  /api/v1/styles/{style_id}/skus
POST /api/v1/styles/{style_id}/skus
POST /api/v1/styles/{style_id}/skus/generate
GET  /api/v1/materials/{material_id}/skus
POST /api/v1/materials/{material_id}/skus/generate
Authorization: Bearer <access_token>
```

### Bulk-generate style SKUs

```bash theme={null}
POST /api/v1/styles/{style_id}/skus/generate
Authorization: Bearer <access_token>

{
  "colors": ["Black", "White"],
  "sizes": ["S", "M", "L", "XL"]
}
```

**Response (201):**

```json theme={null}
{
  "created": 8,
  "skus": [
    { "id": "uuid", "code": "ST-CREW-001-BLK-S" }
  ]
}
```

### SKU Management

A separate SKU management surface handles label generation:

```bash theme={null}
GET  /skus
POST /skus
POST /skus/pdf
POST /skus/qr_code
PUT  /skus/{row_id}
Authorization: Bearer <access_token>
```

See the **API Reference** tab for the full endpoint list.

## Feeds into

<CardGroup cols={2}>
  <Card title="Order Lifecycle" icon="file-invoice" href="/cutmake/plm/order-lifecycle">
    Approved BOM/BOL drive costing.
  </Card>

  <Card title="Procurement" icon="truck" href="/cutmake/plm/procurement">
    BOM demand drives material requests.
  </Card>
</CardGroup>
