Title: Lab 3 — Draw Your System: C4 Context and Container Diagrams as Code
Course: AIINFRA 303: Capstone Project > Section: Week 03 — System Architecture and Full-Stack Infrastructure Design

🛠️ Lab 3 — Draw Your System: C4 Context and Container Diagrams as Code (50 pts)

Goal: Produce a diagrams-as-code architecture document for your capstone — a Mermaid C4 Context diagram, a Mermaid C4 Container diagram, and a companion Docker Compose sketch — all committed to your project repo, so your system's architecture is versioned alongside your code and renders natively on GitHub. Steps:

1. In your capstone repo, create a new folder docs/architecture/ and a file inside it named architecture.md.
2. Pull up your Week 2 requirements/SLO document side by side. For every requirement or SLO, identify which system component will satisfy it — you'll need this mapping in step 5.
3. Write a C4 Context diagram using Mermaid's C4Context syntax. Show your system as a single box, plus every human actor (e.g., end user, admin) and every external system it talks to (e.g., a third-party API, an auth provider, a model API you call rather than host). Test-render it for free at mermaid.live before committing, or preview it directly in VS Code with a Mermaid preview extension.
4. Write a C4 Container diagram using C4Container syntax that opens your system box into its deployable units. At minimum, name: the API/application container, the database, the cache (if any), the model-serving container, and any preprocessing/feature pipeline component. Label every arrow between containers with the protocol or interface it uses (e.g., "HTTPS/REST", "SQL", "gRPC").
5. Directly under each diagram, add a Markdown table with three columns: Component, Week 2 Requirement/SLO it satisfies, Where its state lives (and what happens on restart). Every container from step 4 needs a row.
6. Sketch a docker-compose.yml in the same docs/architecture/ folder (this is a design sketch, not a working build yet — that comes in Week 5) with service stubs for at minimum: api, db, cache, and model-server. Use placeholder images/build contexts where you don't have a real one yet, but get the service names, ports, and dependency order (depends_on) right — this sketch is the direct blueprint for Week 5.
7. Add a short "Scope justification" paragraph (150–250 words) at the bottom of architecture.md explaining, in plain language, why this is a modular monolith (or, if you have a specific documented reason for more than one deployable service, what that reason is) rather than a microservices split.
8. Commit architecture.md and docker-compose.yml to your repo with a clear commit message (e.g., docs: add C4 context/container diagrams and compose sketch).

Deliverables: Submit the URL to your committed docs/architecture/architecture.md file (with both rendered-visible Mermaid diagrams, the two component tables, and the scope justification) plus your docker-compose.yml sketch — either as a second file link pasted in the text-entry box or uploaded directly.