# AssignItemToTaxonomy

## Permission Scope

item

## Overview

assignItemToTaxonomy creates a link between an item and a taxonomy node, enabling many-to-many classification. A single item can be assigned to multiple taxonomy nodes simultaneously (e.g., both "Electronics > Smartphones" and "Gift Ideas > Tech Gifts"), allowing flexible multi-dimensional classification.

## Business Rules

- The referenced item must exist in the system
- The referenced taxonomy node must exist in the system
- The combination of item and taxonomy node must be unique — duplicate assignments are rejected
- An item can be assigned to any number of taxonomy nodes
- A taxonomy node can have any number of items assigned
- Assignment does not change the item's status or the node's position in the tree

## Process Flow

```mermaid
flowchart TD
    A[Receive assign request] --> B{Item exists?}
    B -->|No| C[Return error: item not found]
    B -->|Yes| D{Node exists?}
    D -->|No| E[Return error: node not found]
    D -->|Yes| F{Assignment already exists?}
    F -->|Yes| G[Return error: duplicate assignment]
    F -->|No| H[Create assignment record]
    H --> I[Return created assignment]
```

## External Dependencies

- None

## Error Scenarios

- **ITEM_NOT_FOUND**: Specified item ID does not exist
- **NODE_NOT_FOUND**: Specified taxonomy node ID does not exist
- **DUPLICATE_ASSIGNMENT**: Item is already assigned to this taxonomy node

## Test Cases

- returns error when item does not exist
- returns error when node does not exist
- returns error when assignment already exists
- creates assignment successfully
