DevOps platform
An online shop: edge, three-zone apps, Postgres with a replica, Redis, Kafka, observability, Git, a vault and staging, with the release pipeline as a flow.
The CityScript
This is all there is to it. Change it in the editor and the city redraws.
%% A production platform for an online shop, designed offline: draw it first, connect it to live data later.
%% Every building binds to a host by name (host=), every floor to a Compose project and every room to a service,
%% so connecting a hub with these hosts lights this same design up with live status.
%% Prices are made up for the example: each host's server is on its first service, and a cost line says what a
%% service costs (vendor, plan, what it is made of). Open the Details tab for the whole city's summary.
city 80x40 theme=architect
%% Requests travel left to right: the edge, the apps, then the data and messaging behind them.
district edge "Edge" 4,4..14,10
district app "Application" 18,4..34,12
district data "Data" 38,4..54,14
district bus "Messaging" 58,4..74,12
%% Tooling and the pre-production copy of the platform.
district ops "Operations" 18,20..34,30
district staging "Staging" 38,20..54,30
%% Edge
building edge-1 tower in edge "edge-1" host=edge-1 owner="Platform"
floor edge-1.ingress "ingress" project=ingress
room edge-1.ingress.traefik proxy "traefik" port=80,443 secret=CF_DNS_API_TOKEN service=traefik
cost 6 "Virtual server" vendor=Hetzner plan=CX22 spec="2 vCPU, 4 GB RAM, 40 GB SSD"
cost 25 "DNS and CDN" vendor=Cloudflare plan=Pro
cost 14 per=year "Domain" vendor=Namecheap
room edge-1.ingress.crowdsec service "crowdsec" secret=BOUNCER_API_KEY service=crowdsec
floor edge-1.cache "cache" project=cache
room edge-1.cache.varnish cache "varnish" port=6081 secret=VARNISH_SECRET service=varnish
building edge-2 tower in edge "edge-2" host=edge-2 owner="Platform"
floor edge-2.ingress "ingress" project=ingress
room edge-2.ingress.traefik proxy "traefik" port=80,443 secret=CF_DNS_API_TOKEN service=traefik
cost 6 "Virtual server" vendor=Hetzner plan=CX22 spec="2 vCPU, 4 GB RAM, 40 GB SSD"
room edge-2.ingress.crowdsec service "crowdsec" secret=BOUNCER_API_KEY service=crowdsec
floor edge-2.cache "cache" project=cache
room edge-2.cache.varnish cache "varnish" port=6081 secret=VARNISH_SECRET service=varnish
%% Application
building app-1 factory in app "app-1" host=app-1 owner="Storefront team"
floor app-1.storefront "storefront" project=storefront
room app-1.storefront.web service "web" port=3000 service=web
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
room app-1.storefront.bff service "bff" port=4000 secret=SESSION_SECRET service=bff
floor app-1.core-api "core-api" project=core-api
room app-1.core-api.gateway proxy "gateway" port=8000 secret=KONG_PG_PASSWORD service=gateway
room app-1.core-api.auth service "auth" port=8081 secret=JWT_PRIVATE_KEY,OIDC_CLIENT_SECRET,DATABASE_URL service=auth
room app-1.core-api.catalog service "catalog" port=8082 service=catalog
room app-1.core-api.orders service "orders" port=8083 secret=DATABASE_URL service=orders
floor app-1.workers "workers" project=workers
room app-1.workers.order-worker worker "order-worker" service=order-worker
room app-1.workers.email-worker worker "email-worker" secret=SMTP_PASSWORD,SENDGRID_API_KEY service=email-worker
cost 19.95 "Transactional email" vendor=SendGrid plan=Essentials
building app-2 factory in app "app-2" host=app-2 owner="Payments team"
floor app-2.storefront "storefront" project=storefront
room app-2.storefront.web service "web" port=3000 service=web
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
room app-2.storefront.bff service "bff" port=4000 secret=SESSION_SECRET service=bff
floor app-2.core-api "core-api" project=core-api
room app-2.core-api.gateway proxy "gateway" port=8000 secret=KONG_PG_PASSWORD service=gateway
room app-2.core-api.payments service "payments" port=8084 secret=STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET service=payments
room app-2.core-api.inventory service "inventory" port=8085 service=inventory
room app-2.core-api.notifications service "notifications" port=8086 service=notifications
floor app-2.workers "workers" project=workers
room app-2.workers.order-worker worker "order-worker" service=order-worker
room app-2.workers.report-worker worker "report-worker" service=report-worker
room app-2.workers.scheduler worker "scheduler" service=scheduler
building app-3 factory in app "app-3" host=app-3 owner="Search team"
floor app-3.search "search" project=search
room app-3.search.search-api service "search-api" port=8087 service=search-api
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
room app-3.search.opensearch database "opensearch" port=9200 secret=OPENSEARCH_INITIAL_ADMIN_PASSWORD service=opensearch
room app-3.search.indexer worker "indexer" service=indexer
floor app-3.media "media" project=media
room app-3.media.imgproxy service "imgproxy" port=8088 secret=IMGPROXY_KEY,IMGPROXY_SALT service=imgproxy
room app-3.media.minio storage "minio" port=9000 secret=MINIO_ROOT_PASSWORD service=minio
%% Data
building db-1 warehouse in data "db-1" host=db-1 owner="Data team"
floor db-1.postgres "postgres" project=postgres
room db-1.postgres.postgres-primary database "postgres-primary" port=5432 secret=POSTGRES_PASSWORD,REPLICATION_PASSWORD service=postgres-primary
cost 32 "Virtual server" vendor=Hetzner plan=CCX23 spec="4 dedicated vCPU, 16 GB RAM, 160 GB SSD"
room db-1.postgres.pgbouncer proxy "pgbouncer" port=6432 secret=PGBOUNCER_AUTH_PASSWORD service=pgbouncer
room db-1.postgres.wal-g worker "wal-g" secret=AWS_SECRET_ACCESS_KEY,WALG_LIBSODIUM_KEY service=wal-g
cost 4.5 "Backup storage" vendor=Backblaze plan=B2 spec="750 GB, 30 days of WAL"
building db-2 warehouse in data "db-2" host=db-2 owner="Data team"
floor db-2.postgres "postgres" project=postgres
room db-2.postgres.postgres-replica database "postgres-replica" port=5432 secret=POSTGRES_PASSWORD,REPLICATION_PASSWORD service=postgres-replica
cost 32 "Virtual server" vendor=Hetzner plan=CCX23 spec="4 dedicated vCPU, 16 GB RAM, 160 GB SSD"
room db-2.postgres.pgbouncer proxy "pgbouncer" port=6432 secret=PGBOUNCER_AUTH_PASSWORD service=pgbouncer
room db-2.postgres.postgres-exporter service "postgres-exporter" service=postgres-exporter
building cache-1 warehouse in data "cache-1" host=cache-1 owner="Data team"
floor cache-1.redis "redis" project=redis
room cache-1.redis.redis-primary cache "redis-primary" port=6379 secret=REDIS_PASSWORD service=redis-primary
cost 8 "Virtual server" vendor=Hetzner plan=CPX21 spec="3 vCPU, 4 GB RAM, 80 GB SSD"
room cache-1.redis.redis-replica cache "redis-replica" port=6380 secret=REDIS_PASSWORD,REDIS_MASTER_PASSWORD service=redis-replica
room cache-1.redis.sentinel service "sentinel" port=26379 service=sentinel
%% Messaging
building bus-1 depot in bus "bus-1" host=bus-1 owner="Platform"
floor bus-1.kafka "kafka" project=kafka
room bus-1.kafka.kafka-broker queue "kafka-broker" port=9092 secret=KAFKA_SASL_PASSWORD service=kafka-broker
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
floor bus-1.schema "schema" project=schema
room bus-1.schema.schema-registry service "schema-registry" port=8081 service=schema-registry
room bus-1.schema.kafka-ui service "kafka-ui" port=8089 service=kafka-ui
building bus-2 depot in bus "bus-2" host=bus-2 owner="Platform"
floor bus-2.kafka "kafka" project=kafka
room bus-2.kafka.kafka-broker queue "kafka-broker" port=9092 secret=KAFKA_SASL_PASSWORD service=kafka-broker
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
floor bus-2.connect "connect" project=connect
room bus-2.connect.kafka-connect worker "kafka-connect" port=8083 secret=CONNECT_DB_PASSWORD service=kafka-connect
building bus-3 depot in bus "bus-3" host=bus-3 owner="Platform"
floor bus-3.kafka "kafka" project=kafka
room bus-3.kafka.kafka-broker queue "kafka-broker" port=9092 secret=KAFKA_SASL_PASSWORD service=kafka-broker
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
%% Operations
building git-1 warehouse in ops "git-1" host=git-1 owner="Platform"
floor git-1.git "git" project=git
room git-1.git.gitea service "gitea" port=3000,22 secret=GITEA__security__SECRET_KEY service=gitea
cost 8 "Virtual server" vendor=Hetzner plan=CX32 spec="4 vCPU, 8 GB RAM, 80 GB SSD"
room git-1.git.gitea-db database "gitea-db" secret=POSTGRES_PASSWORD service=gitea-db
building obs-1 warehouse in ops "obs-1" host=obs-1 owner="SRE"
floor obs-1.metrics "metrics" project=metrics
room obs-1.metrics.prometheus service "prometheus" port=9090 service=prometheus
cost 31 "Virtual server" vendor=Hetzner plan=CPX41 spec="8 vCPU, 16 GB RAM, 240 GB SSD"
room obs-1.metrics.alertmanager service "alertmanager" port=9093 secret=SLACK_WEBHOOK_URL,PAGERDUTY_ROUTING_KEY service=alertmanager
cost 21 "On-call" vendor=PagerDuty plan=Professional
floor obs-1.dashboards "dashboards" project=dashboards
room obs-1.dashboards.grafana service "grafana" port=3000 secret=GF_SECURITY_ADMIN_PASSWORD,GF_AUTH_GITHUB_CLIENT_SECRET service=grafana
floor obs-1.logs "logs" project=logs
room obs-1.logs.loki service "loki" port=3100 service=loki
room obs-1.logs.promtail worker "promtail" service=promtail
floor obs-1.tracing "tracing" project=tracing
room obs-1.tracing.tempo service "tempo" port=3200 service=tempo
room obs-1.tracing.otel-collector service "otel-collector" port=4317,4318 service=otel-collector
building registry-1 warehouse at 29,27 "registry-1" host=registry-1 owner="Platform"
floor registry-1.registry "registry" project=registry
room registry-1.registry.registry storage "registry" port=5000 secret=REGISTRY_HTTP_SECRET service=registry
cost 6 "Virtual server" vendor=Hetzner plan=CX22 spec="2 vCPU, 4 GB RAM, 40 GB SSD"
building vault-1 warehouse in ops "vault-1" host=vault-1 owner="Security"
floor vault-1.vault "vault" project=vault
room vault-1.vault.vault service "vault" port=8200 secret=VAULT_UNSEAL_KEY_SHARE service=vault
cost 6 "Virtual server" vendor=Hetzner plan=CX22 spec="2 vCPU, 4 GB RAM, 40 GB SSD"
%% Staging
building stg-1 warehouse in staging "stg-1" host=stg-1 owner="Storefront team"
floor stg-1.core-api "core-api" project=core-api
room stg-1.core-api.gateway proxy "gateway" port=8000 service=gateway
cost 17 "Virtual server" vendor=Hetzner plan=CPX31 spec="4 vCPU, 8 GB RAM, 160 GB SSD"
room stg-1.core-api.orders service "orders" port=8083 secret=DATABASE_URL service=orders
floor stg-1.storefront "storefront" project=storefront
room stg-1.storefront.web service "web" port=3000 service=web
floor stg-1.postgres "postgres" project=postgres
room stg-1.postgres.postgres database "postgres" port=5432 secret=POSTGRES_PASSWORD service=postgres
building preview-1 warehouse in staging "preview-1" host=preview-1 owner="Storefront team"
floor preview-1.pr-482 "pr-482" project=pr-482
room preview-1.pr-482.web service "web" port=3482 service=web
cost 8 "Virtual server" vendor=Hetzner plan=CX32 spec="4 vCPU, 8 GB RAM, 80 GB SSD"
floor preview-1.pr-488 "pr-488" project=pr-488
room preview-1.pr-488.web service "web" port=3488 service=web
%% Planned, not built yet: a lot with nothing on it.
building dr warehouse at 64,21 "DR site (planned)"
%% Zones of trust: what sits inside one trusts itself, and a link across a boundary is drawn as crossing it.
boundary dmz "DMZ" members=edge-1,edge-2
boundary data-zone "Data zone" members=db-1,db-2,cache-1
boundary production "Production" members=app-1,app-2,app-3,bus-1,bus-2,bus-3,data-zone
boundary operations "Operations" members=git-1,obs-1,registry-1,vault-1
boundary staging-zone "Staging" members=stg-1,preview-1
gate main at 0,16 port=443 "Public HTTPS"
gate git at 0,25 port=22 "Git over SSH"
road main -> 78,16 id=avenue
road git -> 17,25
%% One order's journey through the stack.
link edge-1.ingress.traefik -> app-1.storefront.web "HTTPS" variant=emphasis
link app-1.storefront.web -> app-1.storefront.bff -> app-1.core-api.gateway -> app-1.core-api.orders "REST"
link app-1.core-api.orders -> db-1.postgres.pgbouncer -> db-1.postgres.postgres-primary "SQL" variant=security
link db-1.postgres.postgres-primary -> db-2.postgres.postgres-replica "WAL" variant=dashed
link app-1.core-api.orders -> bus-1.kafka.kafka-broker "events" variant=dashed
link app-2.core-api.payments -> cache-1.redis.redis-primary "cache" variant=security
link app-1.core-api.gateway -> obs-1.metrics.prometheus "scrape" variant=dashed
%% CI/CD is a flow, not a building: from the Git server, through the stages, to where the release ends up.
%% job= names the live pipeline whose runs colour each stage once connected.
pipeline release "Release to production" git-1.git.gitea -> [build] -> [test] -> [scan] -> [push] -> registry-1.registry.registry -> [deploy-staging] -> [smoke] -> staging -> [promote] -> app job=shop-release
run build "docker build -t registry.shop.example/shop:$SHA ."
run test "docker run --rm registry.shop.example/shop:$SHA npm test"
run scan "trivy image --exit-code 1 registry.shop.example/shop:$SHA"
run push "docker push registry.shop.example/shop:$SHA"
run deploy-staging "helm upgrade --install shop ./chart -n staging --set image.tag=$SHA"
run smoke "./scripts/smoke.sh https://staging.shop.example"
run promote "helm upgrade --install shop ./chart -n prod --set image.tag=$SHA"
step git-1.git.gitea "A developer merges a change into the shop's code"
step registry-1.registry.registry "The change is built, tested and stored as a package"
step staging "The package is tried out on a copy of the shop that no customer sees"
step app "The tested package goes live for customers"