@startuml uc-07-trade-at-shop autonumber title UC-07 Trade at Shop (design sequence) actor Player participant "ShopBoundary\n«/api/characters/{id}/shop»" as boundary <> participant "ShopService\nsb-api::routes::{shop_action,buy,sell}" as control <> participant "ShopStock\nAppState.shop_stock" as entity <> == View == Player -> boundary : GET shop boundary --> Player : always-stocked + rotating stock, inventory == Buy == Player -> boundary : POST buy + item id boundary -> control : buy_item(character, item) control -> entity : check stock (non-permanent: decrement) alt stock exhausted entity --> control : 0 remaining control --> boundary : 410 GONE else gold < price control --> boundary : 422 else ok control -> entity : stock -1, gold -price, inventory +item control --> boundary : {success, message, gold} boundary --> Player : {success, message, gold} end == Sell == Player -> boundary : POST sell + item id boundary -> control : sell_item(character, item) alt item not owned / unknown action control --> boundary : 400 else ok control -> entity : inventory -item, gold +value/2, stock +1 (non-permanent) boundary --> Player : {success, message, gold} end @enduml