Copy an example, or open it in the live editor with this diagram already loaded.
System context
One system, the person who uses it, and the external systems it depends on. This is the diagram to show someone outside the team.
C4Context
title Checkout context
Person(shopper, "Shopper", "Pays for an order")
System(shop, "Shop", "Takes the order and the payment")
System_Ext(pay, "Card processor", "Authorizes charges")
System_Ext(mail, "Email", "Sends receipts")
Rel(shopper, shop, "Places an order")
Rel(shop, pay, "Charges the card", "HTTPS")
Rel(shop, mail, "Sends a receipt", "SMTP")
Containers inside the shop
A container is something you deploy. ContainerDb marks the database. The boundary groups the containers you own.
C4Container
title Shop containers
Person(shopper, "Shopper", "Uses the shop")
Container_Boundary(shop, "Shop") {
Container(web, "Web app", "Next.js", "Renders the cart")
Container(api, "API", "Node", "Creates orders")
ContainerDb(db, "Orders", "Postgres", "Stores orders")
}
Rel(shopper, web, "Uses")
Rel(web, api, "Calls", "JSON")
Rel(api, db, "Reads and writes", "SQL")
Components inside the API
Zoom one level further. Components live inside a single container and are not separately deployed.
C4Component
title API components
Container_Boundary(api, "API") {
Component(auth, "Auth", "TypeScript", "Checks the session")
Component(orders, "Orders", "TypeScript", "Creates the order")
ComponentDb(store, "Order store", "SQL", "Persists rows")
}
Rel(auth, orders, "Allows the call")
Rel(orders, store, "Writes")