# Mermaid C4 context and container diagrams

A context diagram and the containers inside one system show boundaries and labeled relationships, as in an architecture decision record.

Persons, systems, databases, queues and enterprise boundaries with labeled relationships, then the containers inside one system, set in an architecture decision record for a university.

- PDF: https://legivel.com/examples/mermaid-diagrams/c4-diagram.pdf
- Page: https://legivel.com/examples/mermaid-diagrams/c4-diagram
- Open in the editor: https://legivel.com/markdown-to-pdf?sample=mermaid-c4
- More mermaid diagrams in Markdown to PDF: https://legivel.com/examples/mermaid-diagrams

## Markdown source

````markdown
---
title: ADR 12, one student records system for three campuses
author: Information systems office
---

# ADR 12: one student records system for three campuses

| Field | Value |
|:------|:------|
| Status | Accepted |
| Decided | 19 May 2026 |
| Owner | Information systems office |
| Consulted | Registrars of the three campuses, Finance, Library |
| Supersedes | ADR 07, one records system per campus |

## Context

The university teaches 38,000 students on three campuses in two countries. Each campus runs its own student records system, inherited from the mergers of 2014 and 2019. A student who takes a course on another campus exists twice, with two numbers and two transcripts, and the finance office reconciles fees by hand every term.

## Decision

All three campuses record students, enrollments and grades in one system, owned by the information systems office. The campus registrars keep their roles and their approval rights inside it.

## System context

```mermaid
C4Context
title Student records, system context
Person(student, "Student", "Enrolls, pays fees, reads grades")
Person(registrar, "Registrar", "Approves enrollments and issues transcripts")
Enterprise_Boundary(uni, "University") {
  System(records, "Student records", "Students, enrollments, grades, transcripts")
  System(portal, "Student portal", "Where students see and do everything")
  System(lms, "Learning platform", "Course content and assignments")
  SystemDb(archive, "Transcript archive", "Signed transcripts, kept for 80 years")
  SystemQueue(events, "Event bus", "Enrollment and grade events")
}
System_Ext(payments, "Payment provider", "Collects tuition fees")
System_Ext(ministry, "Education ministry", "Receives the annual statistical return")
Rel(student, portal, "Uses", "HTTPS")
Rel(registrar, records, "Approves and issues", "HTTPS")
Rel(portal, records, "Reads and writes")
Rel(records, events, "Publishes changes")
Rel(events, lms, "Creates course rosters")
Rel(records, archive, "Files signed transcripts")
Rel(portal, payments, "Collects fees", "HTTPS")
Rel(records, ministry, "Annual return", "SFTP")
```

## Inside the records system

```mermaid
C4Container
title Student records, containers
Person(registrar, "Registrar")
System_Boundary(records, "Student records") {
  Container(web, "Registrar workspace", "Web application", "Approvals, transcripts, reports")
  Container(api, "Records API", "Service", "Students, enrollments, grades")
  Container(rules, "Progression rules", "Service", "Prerequisites, credit limits, deadlines")
  ContainerDb(db, "Records database", "Relational", "The single source of truth")
  ContainerQueue(outbox, "Outbox", "Queue", "Events for the bus")
}
System_Ext(portal, "Student portal")
Rel(registrar, web, "Uses", "HTTPS")
Rel(web, api, "Calls", "JSON/HTTPS")
Rel(portal, api, "Calls", "JSON/HTTPS")
Rel(api, rules, "Checks every enrollment")
Rel(api, db, "Reads and writes")
Rel(api, outbox, "Writes events")
```

## Options considered

| Option | Cost to build | Risk | Why not |
|:-------|:--------------|:-----|:--------|
| Keep three systems, synchronize nightly | Low | High | The duplicates stay, the reconciliation stays |
| One system, each campus owns a copy | Medium | High | Three owners for one truth |
| One system, one owner | Medium | Medium | Chosen |

## Consequences

- One student number for life, across campuses and countries.
- The finance office stops reconciling fees by hand from the autumn term of 2027.
- Two of the three existing systems are retired. Their data is migrated and then archived read-only for ten years[^retention].
- Grade publication follows one calendar for all campuses. The registrars agreed to this in April.

[^retention]: The retention period follows the records schedule approved by the university council in 2023.

> [!IMPORTANT]
> The records system becomes a single point of failure for enrollment week. The capacity plan and the fallback to paper enrollment are in the operations runbook and are rehearsed every August.

## Next steps

- [x] Agree the decision with the three registrars
- [x] Migrate the smallest campus, 4,100 students, by 1 September 2026
- [ ] Migrate the second campus by 1 February 2027
- [ ] Migrate the main campus by 1 September 2027

*All organizations in the sample documents are invented. Names and figures are illustrative.*
````
