Skip to content
D2 templates

Three-tier web app

Browser → Load balancer → API pool → Database / Cache.

Template previewD2
G browser browser lb lb browser->lb HTTPS api1 api1 lb->api1 api2 api2 lb->api2 api3 api3 lb->api3 db db api1->db reads/writes cache cache api1->cache api2->db api2->cache api3->db api3->cache

What this template contains

Source
12 lines

When to use it

Choose this for a compact diagram-as-code view of a browser, load balancer, API pool, database and cache. It is useful when you want readable text and labelled connections without a large cloud-specific vocabulary. Compare it in software architecture diagram templates

The D2 template shows a browser, load balancer, three API instances, a database and a cache. Use it as a starting view, then replace its identifiers and relationships with those in your actual source. Read the guide: Architecture diagrams linked to code

Make it your own.

browser -> lb: HTTPS
lb -> api1
lb -> api2
lb -> api3

api1 -> db: reads/writes
api2 -> db
api3 -> db

api1 -> cache
api2 -> cache
api3 -> cache

db.shape: cylinder
cache.shape: cylinder