{
 "$schema": "../../lib/umlimator.schema.json",
 "schemaVersion": 2,
 "title": "C4 diagram",
 "root": "containers",
 "nodes": [
  {"id": "shopper", "type": "c4.Person", "label": "Shopper", "props": {"description": "Browses the catalogue, buys books and tracks orders."}},
  {"id": "staff", "type": "c4.Person", "label": "Shop staff", "props": {"description": "Keep the catalogue up to date and refund orders."}},
  {"id": "bookshop", "type": "c4.SoftwareSystem", "label": "Bookshop", "opensView": "containers", "props": {"description": "Sells books online: catalogue, basket, checkout and order tracking."}},
  {"id": "payments", "type": "c4.SoftwareSystem", "label": "Payment provider", "props": {"description": "Takes card payments and makes refunds.", "external": true}},
  {"id": "mail", "type": "c4.SoftwareSystem", "label": "Email service", "props": {"description": "Delivers the shop's emails.", "external": true}},
  {"id": "courier", "type": "c4.SoftwareSystem", "label": "Courier", "props": {"description": "Collects parcels and delivers them to shoppers.", "external": true}},
  {"id": "bookkeeping", "type": "c4.SoftwareSystem", "label": "Bookkeeping", "props": {"description": "The shop's accounts: sales, refunds and VAT returns.", "shape": "window"}},
  {"id": "storefront", "type": "c4.Container", "label": "Storefront", "parent": "bookshop", "props": {"technology": "TypeScript, React", "description": "The shop in the browser: catalogue, basket and checkout, and the admin pages for staff.", "shape": "browser"}},
  {"id": "mobile", "type": "c4.Container", "label": "Mobile app", "parent": "bookshop", "props": {"technology": "Kotlin, Swift", "description": "Tracks a shopper's orders and tells them when a parcel is on its way.", "shape": "mobile"}},
  {"id": "api", "type": "c4.Container", "label": "Shop API", "parent": "bookshop", "opensView": "components", "props": {"technology": "Python, FastAPI", "description": "Catalogue, basket, checkout and accounts as a JSON API."}},
  {"id": "worker", "type": "c4.Container", "label": "Order worker", "parent": "bookshop", "props": {"technology": "Python", "description": "Fulfils paid orders: books the delivery and sends the confirmation.", "shape": "robot"}},
  {"id": "db", "type": "c4.Container", "label": "Database", "parent": "bookshop", "props": {"technology": "PostgreSQL", "description": "Books, baskets, orders and accounts.", "shape": "cylinder"}},
  {"id": "queue", "type": "c4.Container", "label": "Order queue", "parent": "bookshop", "props": {"technology": "PostgreSQL table", "description": "Paid orders waiting to be fulfilled, oldest first.", "shape": "pipe"}},
  {"id": "covers", "type": "c4.Container", "label": "Cover images", "parent": "bookshop", "props": {"technology": "Object storage", "description": "A picture of every book's cover, served to the browser.", "shape": "folder"}},
  {"id": "stock-import", "type": "c4.Container", "label": "Stock import", "parent": "bookshop", "props": {"technology": "Python command line", "description": "Loads the wholesalers' price lists into the catalogue each week.", "shape": "terminal"}},
  {"id": "catalogue", "type": "c4.Component", "label": "Catalogue", "parent": "api", "props": {"technology": "FastAPI router", "description": "Lists and searches books."}},
  {"id": "checkout", "type": "c4.Component", "label": "Checkout", "parent": "api", "props": {"technology": "FastAPI router", "description": "Turns a basket into a paid order."}},
  {"id": "accounts", "type": "c4.Component", "label": "Accounts and sign-in", "parent": "api", "props": {"technology": "FastAPI router", "description": "Signs shoppers and staff in; keeps hashed passwords and sessions."}},
  {"id": "payment-client", "type": "c4.Component", "label": "Payment client", "parent": "api", "props": {"technology": "Python, httpx", "description": "Starts card payments and reads their result."}},
  {"id": "order-store", "type": "c4.Component", "label": "Order store", "parent": "api", "props": {"technology": "SQLAlchemy", "description": "Saves orders and puts the paid ones on the order queue."}},
  {"id": "device", "type": "c4.DeploymentNode", "label": "User's device", "props": {"technology": "Laptop, tablet or phone", "description": "A shopper's or a staff member's own device."}},
  {"id": "browser", "type": "c4.DeploymentNode", "label": "Web browser", "parent": "device", "props": {"technology": "Chrome, Firefox, Safari or Edge"}},
  {"id": "storefront-1", "type": "c4.ContainerInstance", "label": "Storefront", "parent": "browser", "props": {"container": "storefront"}},
  {"id": "web-host", "type": "c4.DeploymentNode", "label": "Web server", "props": {"technology": "Ubuntu 24.04 LTS", "description": "The web tier's server."}},
  {"id": "docker", "type": "c4.DeploymentNode", "label": "Docker Compose", "parent": "web-host", "props": {"technology": "Docker Engine 27"}},
  {"id": "api-1", "type": "c4.ContainerInstance", "label": "Shop API", "parent": "docker", "props": {"container": "api"}},
  {"id": "worker-1", "type": "c4.ContainerInstance", "label": "Order worker", "parent": "docker", "props": {"container": "worker"}},
  {"id": "db-host", "type": "c4.DeploymentNode", "label": "Database server", "props": {"technology": "Ubuntu 24.04 LTS", "description": "Backed up every night."}},
  {"id": "postgres", "type": "c4.DeploymentNode", "label": "PostgreSQL", "parent": "db-host", "props": {"technology": "PostgreSQL 16"}},
  {"id": "db-1", "type": "c4.ContainerInstance", "label": "Database", "parent": "postgres", "props": {"container": "db"}},
  {"id": "queue-1", "type": "c4.ContainerInstance", "label": "Order queue", "parent": "postgres", "props": {"container": "queue"}},
  {"id": "worker-note", "type": "uml.Comment", "label": "claims the oldest paid order every ten seconds"}
 ],
 "edges": [
  {"id": "shopper-bookshop", "type": "c4.Relationship", "from": "shopper", "to": "bookshop", "label": "Browses and buys books with"},
  {"id": "staff-bookshop", "type": "c4.Relationship", "from": "staff", "to": "bookshop", "label": "Keep the catalogue and refund orders with"},
  {"id": "bookshop-payments", "type": "c4.Relationship", "from": "bookshop", "to": "payments", "label": "Takes card payments with", "props": {"technology": "HTTPS"}},
  {"id": "bookshop-mail", "type": "c4.Relationship", "from": "bookshop", "to": "mail", "label": "Sends order confirmations with", "props": {"technology": "HTTPS"}},
  {"id": "bookshop-courier", "type": "c4.Relationship", "from": "bookshop", "to": "courier", "label": "Books deliveries with", "props": {"technology": "HTTPS"}},
  {"id": "mail-shopper", "type": "c4.Relationship", "from": "mail", "to": "shopper", "label": "Delivers confirmations to", "props": {"technology": "Email"}},
  {"id": "shopper-storefront", "type": "c4.Relationship", "from": "shopper", "to": "storefront", "label": "Fills a basket and checks out in", "props": {"technology": "HTTPS"}},
  {"id": "staff-storefront", "type": "c4.Relationship", "from": "staff", "to": "storefront", "label": "Edit the catalogue and refund orders in", "props": {"technology": "HTTPS"}},
  {"id": "storefront-api", "type": "c4.Relationship", "from": "storefront", "to": "api", "label": "Reads the catalogue and places orders through", "props": {"technology": "JSON over HTTPS"}},
  {"id": "api-payments", "type": "c4.Relationship", "from": "api", "to": "payments", "label": "Charges cards with", "props": {"technology": "HTTPS"}},
  {"id": "api-db", "type": "c4.Relationship", "from": "api", "to": "db", "label": "Reads and writes books, baskets and orders in", "props": {"technology": "SQL"}},
  {"id": "api-queue", "type": "c4.Relationship", "from": "api", "to": "queue", "label": "Puts paid orders on", "props": {"technology": "SQL"}},
  {"id": "worker-queue", "type": "c4.Relationship", "from": "worker", "to": "queue", "label": "Claims paid orders from", "props": {"technology": "SQL"}},
  {"id": "worker-courier", "type": "c4.Relationship", "from": "worker", "to": "courier", "label": "Books deliveries with", "props": {"technology": "HTTPS"}},
  {"id": "worker-mail", "type": "c4.Relationship", "from": "worker", "to": "mail", "label": "Sends confirmations with", "props": {"technology": "HTTPS"}},
  {"id": "worker-db", "type": "c4.Relationship", "from": "worker", "to": "db", "label": "Marks orders as fulfilled in", "props": {"technology": "SQL"}},
  {"id": "storefront-catalogue", "type": "c4.Relationship", "from": "storefront", "to": "catalogue", "label": "Lists and searches books through", "props": {"technology": "JSON over HTTPS"}},
  {"id": "storefront-checkout", "type": "c4.Relationship", "from": "storefront", "to": "checkout", "label": "Places orders through", "props": {"technology": "JSON over HTTPS"}},
  {"id": "storefront-accounts", "type": "c4.Relationship", "from": "storefront", "to": "accounts", "label": "Signs in through", "props": {"technology": "JSON over HTTPS"}},
  {"id": "checkout-payment-client", "type": "c4.Relationship", "from": "checkout", "to": "payment-client", "label": "Charges the card through"},
  {"id": "payment-client-payments", "type": "c4.Relationship", "from": "payment-client", "to": "payments", "label": "Starts a card payment with", "props": {"technology": "HTTPS"}},
  {"id": "checkout-order-store", "type": "c4.Relationship", "from": "checkout", "to": "order-store", "label": "Saves the paid order with"},
  {"id": "order-store-db", "type": "c4.Relationship", "from": "order-store", "to": "db", "label": "Reads and writes orders in", "props": {"technology": "SQL"}},
  {"id": "order-store-queue", "type": "c4.Relationship", "from": "order-store", "to": "queue", "label": "Puts paid orders on", "props": {"technology": "SQL"}},
  {"id": "catalogue-db", "type": "c4.Relationship", "from": "catalogue", "to": "db", "label": "Reads books from", "props": {"technology": "SQL"}},
  {"id": "accounts-db", "type": "c4.Relationship", "from": "accounts", "to": "db", "label": "Reads and writes accounts and sessions in", "props": {"technology": "SQL"}},
  {"id": "storefront-1-api-1", "type": "c4.Relationship", "from": "storefront-1", "to": "api-1", "label": "Calls", "props": {"technology": "JSON over HTTPS, port 443"}},
  {"id": "api-1-db-1", "type": "c4.Relationship", "from": "api-1", "to": "db-1", "label": "Reads from and writes to", "props": {"technology": "SQL, port 5432, private network"}},
  {"id": "api-1-queue-1", "type": "c4.Relationship", "from": "api-1", "to": "queue-1", "label": "Puts paid orders on", "props": {"technology": "SQL, port 5432, private network"}},
  {"id": "worker-1-queue-1", "type": "c4.Relationship", "from": "worker-1", "to": "queue-1", "label": "Claims paid orders from", "props": {"technology": "SQL, port 5432, private network"}},
  {"id": "worker-1-db-1", "type": "c4.Relationship", "from": "worker-1", "to": "db-1", "label": "Marks orders as fulfilled in", "props": {"technology": "SQL, port 5432, private network"}},
  {"id": "shopper-mobile", "type": "c4.Relationship", "from": "shopper", "to": "mobile", "label": "Tracks orders with", "props": {"technology": "HTTPS"}},
  {"id": "mobile-api", "type": "c4.Relationship", "from": "mobile", "to": "api", "label": "Reads order status from", "props": {"technology": "JSON over HTTPS"}},
  {"id": "storefront-covers", "type": "c4.Relationship", "from": "storefront", "to": "covers", "label": "Shows cover images from", "props": {"technology": "HTTPS"}},
  {"id": "staff-stock-import", "type": "c4.Relationship", "from": "staff", "to": "stock-import", "label": "Load price lists with"},
  {"id": "stock-import-db", "type": "c4.Relationship", "from": "stock-import", "to": "db", "label": "Writes new books and prices to", "props": {"technology": "SQL"}},
  {"id": "accounts-mail", "type": "c4.Relationship", "from": "accounts", "to": "mail", "label": "Sends password reset emails with", "props": {"technology": "HTTPS"}},
  {"id": "bookshop-bookkeeping", "type": "c4.Relationship", "from": "bookshop", "to": "bookkeeping", "label": "Sends each day's sales to", "props": {"technology": "CSV over SFTP"}},
  {"id": "staff-bookkeeping", "type": "c4.Relationship", "from": "staff", "to": "bookkeeping", "label": "Keep the accounts in"},
  {"id": "worker-note-link", "type": "uml.CommentLink", "from": "worker-note", "to": "worker"}
 ],
 "views": [
  {"id": "containers", "diagram": "c4.container", "title": "Bookshop: containers", "parent": null, "subject": "bookshop", "nodeIds": ["bookshop", "shopper", "staff", "storefront", "mobile", "api", "worker", "db", "queue", "covers", "stock-import", "payments", "mail", "courier", "worker-note"], "edges": ["shopper-storefront", "shopper-mobile", "staff-storefront", "staff-stock-import", "storefront-api", "mobile-api", "storefront-covers", "api-payments", "api-db", "api-queue", "worker-queue", "worker-courier", "worker-mail", "stock-import-db", "worker-note-link"], "layout": {"api": [3, 0], "mail": [4, 2]}},
  {"id": "context", "diagram": "c4.context", "title": "Bookshop: system context", "parent": "containers", "subject": "bookshop", "nodeIds": ["shopper", "staff", "bookshop", "payments", "mail", "courier"]},
  {"id": "landscape", "diagram": "c4.landscape", "title": "The bookshop's systems: landscape", "parent": "containers", "nodeIds": ["shopper", "staff", "bookshop", "bookkeeping", "payments", "mail", "courier"]},
  {"id": "components", "diagram": "c4.component", "title": "Shop API: components", "parent": "containers", "subject": "api", "nodeIds": ["api", "storefront", "catalogue", "checkout", "accounts", "payment-client", "order-store", "db", "queue", "payments", "mail"], "layout": {"accounts": [4, 3]}},
  {"id": "placing-an-order", "diagram": "c4.dynamic", "title": "Placing an order", "parent": "containers", "subject": "bookshop", "nodeIds": ["shopper", "storefront", "api", "payments", "db", "queue", "worker", "courier", "mail"], "edges": ["shopper-storefront", "storefront-api", "api-payments", "api-db", "api-queue", "worker-queue", "worker-courier", "worker-mail", "mail-shopper", "worker-db"], "layout": {"db": [0, 0]}},
  {"id": "deployment", "diagram": "c4.deployment", "title": "Bookshop: production deployment", "parent": "containers", "nodeIds": ["device", "browser", "storefront-1", "web-host", "docker", "api-1", "worker-1", "db-host", "postgres", "db-1", "queue-1"], "layout": {"api-1": [0, 0]}}
 ]
}
