Add Archify | New Model… with three C4 examples and Open Model in the Explorer menu

- templates/models: C4 - Standard Web App, C4 - E-Shop, C4 - Event-Based
  Integration; each a complete model (main.archify, registry, context,
  containers, components) that validates
- archify.newModel: pick an example and a folder name, copy it, name the
  model after the folder, open the model page
- Explorer menu: New Model… on folders, Open Model on .archify and
  .archify-registry files; File → New File… lists New Model…
- unit test validates every example end to end; integration test runs the
  command; README, CHANGELOG, docs/model.md
This commit is contained in:
2026-10-19 12:12:49 +03:00
parent 7a2b661afe
commit 57914d435c
29 changed files with 874 additions and 8 deletions
@@ -0,0 +1,26 @@
schema_version: 1
diagram_type: architecture
meta:
title: System context
output: context.html
components:
- ref: customer
pos: [40, 60]
size: [130, 60]
- ref: support
pos: [40, 260]
size: [130, 60]
- ref: shop
pos: [280, 160]
size: [150, 60]
- ref: psp
pos: [520, 60]
size: [150, 60]
- ref: email
pos: [520, 260]
size: [150, 60]
connections:
- { from: customer, to: shop, label: buys, variant: emphasis }
- { from: support, to: shop, label: manages orders }
- { from: shop, to: psp, label: charges, variant: security }
- { from: shop, to: email, label: sends mail }
@@ -0,0 +1,39 @@
schema_version: 1
diagram_type: architecture
meta:
title: Containers
output: containers.html
components:
- ref: customer
pos: [40, 160]
size: [130, 60]
- ref: web
pos: [250, 160]
size: [130, 60]
- ref: api
pos: [460, 160]
size: [130, 60]
- ref: cache
pos: [670, 60]
size: [130, 60]
- ref: db
pos: [670, 260]
size: [130, 60]
- ref: queue
pos: [460, 360]
size: [130, 60]
- ref: worker
pos: [670, 460]
size: [130, 60]
boundaries:
- kind: region
label: Online Shop
wraps: [web, api, cache, db, queue, worker]
connections:
- { from: customer, to: web, label: HTTPS, variant: emphasis }
- { from: web, to: api, label: JSON }
- { from: api, to: cache, label: read }
- { from: api, to: db, label: SQL }
- { from: api, to: queue, label: enqueue, labelAt: [560, 290] }
- { from: queue, to: worker, label: poll }
- { from: worker, to: db, label: SQL, labelAt: [735, 420] }
@@ -0,0 +1,42 @@
schema_version: 1
diagram_type: architecture
meta:
title: API components
output: api.html
components:
- ref: web
pos: [40, 160]
size: [130, 60]
- id: auth
type: security
label: Auth
sublabel: sessions, OIDC
pos: [250, 60]
size: [130, 60]
- id: orders
type: backend
label: Orders
pos: [250, 160]
size: [130, 60]
- id: catalogue
type: backend
label: Catalogue
pos: [250, 260]
size: [130, 60]
- ref: db
pos: [460, 160]
size: [130, 60]
- ref: queue
pos: [460, 310]
size: [130, 60]
boundaries:
- kind: region
label: API
wraps: [auth, orders, catalogue]
connections:
- { from: web, to: auth, label: sign in, variant: security }
- { from: web, to: orders, label: place order }
- { from: web, to: catalogue, label: browse }
- { from: orders, to: db, label: SQL }
- { from: catalogue, to: db, label: SQL }
- { from: orders, to: queue, label: enqueue }
+24
View File
@@ -0,0 +1,24 @@
schema_version: 1
model:
id: e-shop
name: E-Shop
description: >
The web shop, its API and workers, and the stores behind them.
Context, containers and components, C4 style.
diagram_type: architecture
meta:
title: E-Shop — overview
output: main.html
components:
- ref: customer
pos: [40, 160]
size: [130, 60]
- ref: shop
pos: [250, 160]
size: [150, 60]
- ref: psp
pos: [480, 160]
size: [150, 60]
connections:
- { from: customer, to: shop, label: buys, variant: emphasis }
- { from: shop, to: psp, label: charges }
@@ -0,0 +1,37 @@
schema_version: 1
elements:
web:
type: frontend
label: Web App
sublabel: React
brand: react
description: The shop as customers see it; talks only to the API.
api:
type: backend
label: API
sublabel: Node.js
brand: node-js
description: Owns authentication, orders and the catalogue.
diagram: 0300-components/api.archify
worker:
type: backend
label: Worker
sublabel: async jobs
description: Picks jobs from the queue; emails, invoices, exports.
queue:
type: messagebus
label: Queue
sublabel: SQS
description: Job queue between the API and the workers.
db:
type: database
label: Database
sublabel: PostgreSQL
brand: postgresql
description: Orders, customers and catalogue; the source of truth.
cache:
type: database
label: Cache
sublabel: Redis
brand: redis
description: Sessions and catalogue cache; nothing here is the source of truth.
@@ -0,0 +1,12 @@
schema_version: 1
elements:
customer:
type: external
label: Customer
sublabel: web and mobile
description: Buys products; signs in with email or a social account.
support:
type: external
label: Support agent
sublabel: back office
description: Handles refunds and order problems in the admin console.
@@ -0,0 +1,19 @@
schema_version: 1
elements:
shop:
type: cloud
label: Online Shop
sublabel: the system
description: Everything we build and run; web app, API, workers and stores.
diagram: 0200-containers/online-shop.archify
psp:
type: external
label: Payment provider
sublabel: Stripe
brand: stripe
description: Charges cards and pays out; we never see card numbers.
email:
type: external
label: Email service
sublabel: transactional mail
description: Sends order confirmations and password resets.
@@ -0,0 +1,26 @@
schema_version: 1
diagram_type: architecture
meta:
title: System context
output: context.html
components:
- ref: crm
pos: [40, 60]
size: [130, 60]
- ref: erp
pos: [40, 260]
size: [130, 60]
- ref: platform
pos: [280, 160]
size: [170, 60]
- ref: warehouse
pos: [540, 60]
size: [150, 60]
- ref: ops
pos: [540, 260]
size: [150, 60]
connections:
- { from: crm, to: platform, label: customer events, variant: emphasis }
- { from: erp, to: platform, label: order events, variant: emphasis }
- { from: platform, to: warehouse, label: pick lists }
- { from: ops, to: platform, label: replays, variant: dashed }
@@ -0,0 +1,46 @@
schema_version: 1
diagram_type: architecture
meta:
title: Containers
output: containers.html
components:
- ref: crm
pos: [40, 60]
size: [130, 60]
- ref: erp
pos: [40, 260]
size: [130, 60]
- ref: ingest
pos: [250, 160]
size: [140, 60]
- ref: bus
pos: [470, 160]
size: [140, 60]
- ref: router
pos: [690, 160]
size: [150, 60]
- ref: dlq
pos: [690, 320]
size: [150, 60]
- ref: store
pos: [920, 60]
size: [140, 60]
- ref: notifier
pos: [920, 160]
size: [140, 60]
- ref: analytics
pos: [920, 260]
size: [140, 60]
boundaries:
- kind: region
label: Integration platform
wraps: [ingest, bus, router, dlq, store, notifier, analytics]
connections:
- { from: crm, to: ingest, label: HTTPS, variant: emphasis }
- { from: erp, to: ingest, label: HTTPS, variant: emphasis }
- { from: ingest, to: bus, label: publish }
- { from: bus, to: router, label: consume }
- { from: router, to: store, label: append }
- { from: router, to: notifier, label: notify }
- { from: router, to: analytics, label: flatten }
- { from: router, to: dlq, label: failed, variant: dashed, labelDy: 24 }
@@ -0,0 +1,46 @@
schema_version: 1
diagram_type: architecture
meta:
title: Event router components
output: router.html
components:
- ref: bus
pos: [40, 160]
size: [140, 60]
- id: validate
type: security
label: Validate
sublabel: schema check
pos: [270, 160]
size: [130, 60]
- id: enrich
type: backend
label: Enrich
sublabel: reference data
pos: [480, 160]
size: [130, 60]
- id: dispatch
type: backend
label: Dispatch
pos: [690, 160]
size: [130, 60]
- ref: store
pos: [920, 60]
size: [140, 60]
- ref: notifier
pos: [920, 160]
size: [140, 60]
- ref: dlq
pos: [270, 320]
size: [150, 60]
boundaries:
- kind: region
label: Event router
wraps: [validate, enrich, dispatch]
connections:
- { from: bus, to: validate, label: event }
- { from: validate, to: enrich, label: valid }
- { from: enrich, to: dispatch, label: enriched }
- { from: dispatch, to: store, label: append }
- { from: dispatch, to: notifier, label: notify }
- { from: validate, to: dlq, label: invalid, variant: dashed, labelDy: 24 }
@@ -0,0 +1,29 @@
schema_version: 1
model:
id: event-based-integration
name: Event-Based Integration
description: >
Systems that never call each other directly; events go through a bus,
a router validates and enriches them, consumers react. Context,
containers, the router's components and one flow, C4 style.
diagram_type: architecture
meta:
title: Event-Based Integration — overview
output: main.html
components:
- ref: crm
pos: [40, 60]
size: [130, 60]
- ref: erp
pos: [40, 260]
size: [130, 60]
- ref: platform
pos: [280, 160]
size: [170, 60]
- ref: warehouse
pos: [540, 160]
size: [150, 60]
connections:
- { from: crm, to: platform, label: customer events, variant: emphasis }
- { from: erp, to: platform, label: order events, variant: emphasis }
- { from: platform, to: warehouse, label: pick lists }
@@ -0,0 +1,40 @@
schema_version: 1
elements:
ingest:
type: backend
label: Ingest API
sublabel: HTTPS in, events out
description: Accepts events from systems that cannot publish to the bus themselves.
bus:
type: messagebus
label: Event bus
sublabel: Kafka
brand: apache-kafka
description: One topic per event type; retained for seven days.
router:
type: backend
label: Event router
sublabel: validate, enrich, dispatch
description: Checks each event against its schema, adds reference data, hands it to the consumers.
diagram: 0300-components/router.archify
dlq:
type: messagebus
label: Dead-letter queue
sublabel: failed events
description: Events the router could not process; replayed by operations.
store:
type: database
label: Event store
sublabel: PostgreSQL
brand: postgresql
description: Every accepted event, for audit and replay.
notifier:
type: backend
label: Notifier
sublabel: email, chat
description: Turns selected events into messages to people.
analytics:
type: database
label: Analytics
sublabel: warehouse tables
description: Flattened events for reporting.
@@ -0,0 +1,7 @@
schema_version: 1
elements:
ops:
type: external
label: Operations
sublabel: on-call
description: Watches the dead-letter queue and replays failed events.
@@ -0,0 +1,23 @@
schema_version: 1
elements:
platform:
type: cloud
label: Integration platform
sublabel: the system
description: Receives events from the business systems, routes them, keeps a record.
diagram: 0200-containers/platform.archify
crm:
type: external
label: CRM
sublabel: customers
description: Source of customer events; created, updated, merged.
erp:
type: external
label: ERP
sublabel: orders and stock
description: Source of order events and the target of stock updates.
warehouse:
type: external
label: Warehouse system
sublabel: fulfilment
description: Receives pick lists; reports shipments back as events.
@@ -0,0 +1,26 @@
schema_version: 1
diagram_type: architecture
meta:
title: System context
output: context.html
components:
- ref: user
pos: [40, 60]
size: [130, 60]
- ref: admin
pos: [40, 260]
size: [130, 60]
- ref: webapp
pos: [280, 160]
size: [160, 60]
- ref: idp
pos: [530, 60]
size: [150, 60]
- ref: email
pos: [530, 260]
size: [150, 60]
connections:
- { from: user, to: webapp, label: uses, variant: emphasis }
- { from: admin, to: webapp, label: administers }
- { from: webapp, to: idp, label: signs in via, variant: security }
- { from: webapp, to: email, label: sends mail }
@@ -0,0 +1,38 @@
schema_version: 1
diagram_type: architecture
meta:
title: Containers
output: containers.html
components:
- ref: user
pos: [40, 160]
size: [130, 60]
- ref: spa
pos: [250, 160]
size: [150, 60]
- ref: api
pos: [480, 160]
size: [130, 60]
- ref: idp
pos: [480, 20]
size: [130, 60]
- ref: cache
pos: [690, 60]
size: [130, 60]
- ref: db
pos: [690, 160]
size: [130, 60]
- ref: storage
pos: [690, 260]
size: [130, 60]
boundaries:
- kind: region
label: Web Application
wraps: [spa, api, cache, db, storage]
connections:
- { from: user, to: spa, label: HTTPS, variant: emphasis }
- { from: spa, to: api, label: JSON }
- { from: api, to: idp, label: verify token, variant: security, labelAt: [531, 110] }
- { from: api, to: cache, label: read }
- { from: api, to: db, label: SQL }
- { from: api, to: storage, label: files }
@@ -0,0 +1,42 @@
schema_version: 1
diagram_type: architecture
meta:
title: API components
output: api.html
components:
- ref: spa
pos: [40, 160]
size: [150, 60]
- id: auth
type: security
label: Auth
sublabel: token check
pos: [270, 40]
size: [130, 60]
- id: accounts
type: backend
label: Accounts
pos: [270, 160]
size: [130, 60]
- id: content
type: backend
label: Content
pos: [270, 280]
size: [130, 60]
- ref: db
pos: [500, 160]
size: [130, 60]
- ref: storage
pos: [500, 280]
size: [130, 60]
boundaries:
- kind: region
label: API
wraps: [auth, accounts, content]
connections:
- { from: spa, to: auth, label: token, variant: security }
- { from: spa, to: accounts, label: profile }
- { from: spa, to: content, label: pages }
- { from: accounts, to: db, label: SQL }
- { from: content, to: db, label: SQL }
- { from: content, to: storage, label: files }
@@ -0,0 +1,29 @@
schema_version: 1
model:
id: standard-web-app
name: Standard Web App
description: >
A classic web application; a single-page app, an API, a database,
a cache and file storage, with sign-in through an identity provider.
Context, containers and the API's components, C4 style.
diagram_type: architecture
meta:
title: Standard Web App — overview
output: main.html
components:
- ref: user
pos: [40, 160]
size: [130, 60]
- ref: webapp
pos: [250, 160]
size: [160, 60]
- ref: idp
pos: [490, 60]
size: [150, 60]
- ref: email
pos: [490, 260]
size: [150, 60]
connections:
- { from: user, to: webapp, label: uses, variant: emphasis }
- { from: webapp, to: idp, label: signs in via, variant: security }
- { from: webapp, to: email, label: sends mail }
@@ -0,0 +1,32 @@
schema_version: 1
elements:
spa:
type: frontend
label: Single-page app
sublabel: React
brand: react
description: The user interface; talks only to the API.
api:
type: backend
label: API
sublabel: Node.js
brand: node-js
description: Owns accounts, content and files; checks tokens from the identity provider.
diagram: 0300-components/api.archify
db:
type: database
label: Database
sublabel: PostgreSQL
brand: postgresql
description: Accounts and content; the source of truth.
cache:
type: database
label: Cache
sublabel: Redis
brand: redis
description: Sessions and hot content; safe to lose.
storage:
type: cloud
label: Object storage
sublabel: uploaded files
description: User uploads and generated exports.
@@ -0,0 +1,12 @@
schema_version: 1
elements:
user:
type: external
label: User
sublabel: browser
description: Anyone with an account; uses the application from a browser.
admin:
type: external
label: Administrator
sublabel: back office
description: Manages users and content from the same application with extra rights.
@@ -0,0 +1,18 @@
schema_version: 1
elements:
webapp:
type: cloud
label: Web Application
sublabel: the system
description: Everything we build and run; the single-page app, the API and its stores.
diagram: 0200-containers/web-app.archify
idp:
type: external
label: Identity provider
sublabel: OpenID Connect
description: Signs users in and issues tokens; we never store passwords.
email:
type: external
label: Email service
sublabel: transactional mail
description: Sends sign-up confirmations and notifications.