# System architecture diagram

> An architecture diagram in four layers, clients, edge, services and data, with the requests and events between them.

- The design, as a .vd file: https://getv.design/library/system-architecture-diagram.vd
- Its page: https://getv.design/library/system-architecture-diagram

## How it was made

Drafted from this prompt:

> An architecture diagram of the order platform at Kestrel Outdoor, in four layers: clients (web app, mobile app, partner API), edge (API gateway, CDN), services (orders, payments, inventory, notifications) and data (Postgres, a ledger database, Redis, an event queue). Dark, monospace, one colour per layer.

Then refined:

- Moved the web app above the CDN so no arrow lands in a gap.
- Routed order events between the layers instead of across the services.
- Notifications now reads the event queue rather than being called by the gateway.

## Make it yours

- "Add a search service that reads from the event queue."
- "Replace Postgres with our own database and rename the services."
- "Make a light version for the handbook."

## The source

```vd
version 5
kind design
title "System architecture diagram"
$bg = #0d1117
$panel = #161b22
$text = #e6edf3
$dim = #8b949e
$wire = #6e7681

font mono = "JetBrains Mono"
  fallback "ui-monospace, monospace"
  face asset=jetbrains-mono-400 weight=400
  face asset=jetbrains-mono-700 weight=700

asset jetbrains-mono-400 = font/woff2 hash=sha256-14425ba9c695763c1547f48a206b7aa60350a33ae23de09f0407877f3fcd89eb bytes=21168 license=OFL
asset jetbrains-mono-700 = font/woff2 hash=sha256-d0d4e818808f2a0ba39b2b09d1989366f63494e295f003c7ef436697378507e8 bytes=21908 license=OFL

frame arch w=1600 h=960 background=bg
  text arch.title x=64 y=52 w=1000 h=44 font=mono size=34 weight=700 fill=text
    "Order platform, how the parts fit"
  text arch.sub x=64 y=102 w=1000 h=26 font=mono size=17 fill=dim
    "Kestrel Outdoor · version 3 · November 2026"
  rect clients x=190 y=170 w=1380 h=150 fill=none stroke=#58a6ff strokeWidth=1 radius=10 dash="4 6" opacity=0.7
  text clients.name x=64 y=170 w=120 h=150 font=mono size=18 weight=700 valign=middle fill=#58a6ff
    "Clients"
  rect partner x=220 y=205 w=270 h=80 fill=panel stroke=#58a6ff strokeWidth=2 radius=8
  text partner.t x=240 y=219 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Partner API"
  text partner.d x=240 y=249 w=230 h=22 font=mono size=14 fill=dim
    "Keys per partner"
  rect mobile x=570 y=205 w=270 h=80 fill=panel stroke=#58a6ff strokeWidth=2 radius=8
  text mobile.t x=590 y=219 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Mobile app"
  text mobile.d x=590 y=249 w=230 h=22 font=mono size=14 fill=dim
    "iOS and Android"
  rect web x=1270 y=205 w=270 h=80 fill=panel stroke=#58a6ff strokeWidth=2 radius=8
  text web.t x=1290 y=219 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Web app"
  text web.d x=1290 y=249 w=230 h=22 font=mono size=14 fill=dim
    "React, served from the CDN"
  rect edge x=190 y=360 w=1380 h=150 fill=none stroke=#bc8cff strokeWidth=1 radius=10 dash="4 6" opacity=0.7
  text edge.name x=64 y=360 w=120 h=150 font=mono size=18 weight=700 valign=middle fill=#bc8cff
    "Edge"
  rect gate x=220 y=395 w=970 h=80 fill=panel stroke=#bc8cff strokeWidth=2 radius=8
  text gate.t x=240 y=409 w=930 h=26 font=mono size=19 weight=700 fill=text
    "API gateway"
  text gate.d x=240 y=439 w=930 h=22 font=mono size=14 fill=dim
    "Sign-in, rate limits, routing"
  rect cdn x=1270 y=395 w=270 h=80 fill=panel stroke=#bc8cff strokeWidth=2 radius=8
  text cdn.t x=1290 y=409 w=230 h=26 font=mono size=19 weight=700 fill=text
    "CDN"
  text cdn.d x=1290 y=439 w=230 h=22 font=mono size=14 fill=dim
    "Static files and images"
  rect services x=190 y=550 w=1380 h=150 fill=none stroke=#3fb950 strokeWidth=1 radius=10 dash="4 6" opacity=0.7
  text services.name x=64 y=550 w=120 h=150 font=mono size=18 weight=700 valign=middle fill=#3fb950
    "Services"
  rect orders x=220 y=585 w=270 h=80 fill=panel stroke=#3fb950 strokeWidth=2 radius=8
  text orders.t x=240 y=599 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Orders"
  text orders.d x=240 y=629 w=230 h=22 font=mono size=14 fill=dim
    "Carts and checkouts"
  rect pay x=570 y=585 w=270 h=80 fill=panel stroke=#3fb950 strokeWidth=2 radius=8
  text pay.t x=590 y=599 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Payments"
  text pay.d x=590 y=629 w=230 h=22 font=mono size=14 fill=dim
    "Card and bank transfers"
  rect stock x=920 y=585 w=270 h=80 fill=panel stroke=#3fb950 strokeWidth=2 radius=8
  text stock.t x=940 y=599 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Inventory"
  text stock.d x=940 y=629 w=230 h=22 font=mono size=14 fill=dim
    "Stock by warehouse"
  rect notify x=1270 y=585 w=270 h=80 fill=panel stroke=#3fb950 strokeWidth=2 radius=8
  text notify.t x=1290 y=599 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Notifications"
  text notify.d x=1290 y=629 w=230 h=22 font=mono size=14 fill=dim
    "Email, SMS and push"
  rect data x=190 y=740 w=1380 h=150 fill=none stroke=#d29922 strokeWidth=1 radius=10 dash="4 6" opacity=0.7
  text data.name x=64 y=740 w=120 h=150 font=mono size=18 weight=700 valign=middle fill=#d29922
    "Data"
  rect pg x=220 y=775 w=270 h=80 fill=panel stroke=#d29922 strokeWidth=2 radius=8
  text pg.t x=240 y=789 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Postgres"
  text pg.d x=240 y=819 w=230 h=22 font=mono size=14 fill=dim
    "Orders and customers"
  rect ledger x=570 y=775 w=270 h=80 fill=panel stroke=#d29922 strokeWidth=2 radius=8
  text ledger.t x=590 y=789 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Ledger database"
  text ledger.d x=590 y=819 w=230 h=22 font=mono size=14 fill=dim
    "Payments, append only"
  rect redis x=920 y=775 w=270 h=80 fill=panel stroke=#d29922 strokeWidth=2 radius=8
  text redis.t x=940 y=789 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Redis"
  text redis.d x=940 y=819 w=230 h=22 font=mono size=14 fill=dim
    "Stock counts, cached"
  rect queue x=1270 y=775 w=270 h=80 fill=panel stroke=#d29922 strokeWidth=2 radius=8
  text queue.t x=1290 y=789 w=230 h=26 font=mono size=19 weight=700 fill=text
    "Event queue"
  text queue.d x=1290 y=819 w=230 h=22 font=mono size=14 fill=dim
    "Order events, 7 days kept"
  connector w1 x1=@web.cx y1=@web.bottom x2=@web.cx y2=@cdn.top stroke=wire strokeWidth=2 end=arrow
  connector w2 x1=@mobile.cx y1=@mobile.bottom x2=@mobile.cx y2=@gate.top stroke=wire strokeWidth=2 end=arrow
  connector w3 x1=@partner.cx y1=@partner.bottom x2=@partner.cx y2=@gate.top stroke=wire strokeWidth=2 end=arrow
  connector w4 x1=@orders.cx y1=@gate.bottom x2=@orders.cx y2=@orders.top stroke=wire strokeWidth=2 end=arrow
  connector w5 x1=@pay.cx y1=@gate.bottom x2=@pay.cx y2=@pay.top stroke=wire strokeWidth=2 end=arrow
  connector w6 x1=@stock.cx y1=@gate.bottom x2=@stock.cx y2=@stock.top stroke=wire strokeWidth=2 end=arrow
  connector w7 x1=@orders.cx y1=@orders.bottom x2=@orders.cx y2=@pg.top stroke=wire strokeWidth=2 end=arrow
  connector w8 x1=@pay.cx y1=@pay.bottom x2=@pay.cx y2=@ledger.top stroke=wire strokeWidth=2 end=arrow
  connector w9 x1=@stock.cx y1=@stock.bottom x2=@stock.cx y2=@redis.top stroke=wire strokeWidth=2 end=arrow
  connector w10 x1=@web.left y1=@web.cy x2=1100 y2=@web.cy stroke=wire strokeWidth=2
  connector w11 x1=1100 y1=@web.cy x2=1100 y2=@gate.top stroke=wire strokeWidth=2 end=arrow
  connector ev.1 x1=(@orders.x + 50) y1=@orders.bottom x2=(@orders.x + 50) y2=720 stroke=wire strokeWidth=2 dash="6 5"
  connector ev.2 x1=(@orders.x + 50) y1=720 x2=(@queue.x + 70) y2=720 stroke=wire strokeWidth=2 dash="6 5"
  connector ev.3 x1=(@queue.x + 70) y1=720 x2=(@queue.x + 70) y2=@queue.top stroke=wire strokeWidth=2 dash="6 5" end=arrow
  connector ev.4 x1=(@queue.right - 70) y1=@queue.top x2=(@notify.right - 70) y2=@notify.bottom stroke=wire strokeWidth=2 dash="6 5" end=arrow
  rect ev.tag x=1010 y=708 w=150 h=24 fill=bg
  text ev.tag.t x=1010 y=708 w=150 h=24 font=mono size=14 align=center valign=middle fill=dim
    "order events"
  text arch.note x=64 y=(100% - 50) w=1400 h=22 font=mono size=14 fill=dim
    "Solid arrows are requests. Dashed arrows are events: written once, read by whoever subscribes."
```
