agentsclimarketplace

C4 level2 container

Skill kinhluan/skills/.agent-skills/c4-level2-container

πŸš€ Professional Multi-Agent Skills

Install
npx -y skills add kinhluan/skills --skill c4-level2-container

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Specialized in Container diagrams (Level 2) with Infrastructure mapping. Use this skill when the user requests decomposing systems into separately deployable units, identifying the tech stack, and mapping infrastructure components (Docker, K8s).

SKILL.md

13.5 KB, as published. Nobody here has run it

C4 Level 2: Container Diagram & Infrastructure Mapping

The Container diagram represents the high-level technical architecture β€” web apps, mobile apps, databases, background jobs, message brokers. In C4, "Container" means a separately deployable/runnable unit, NOT Docker (though Docker containers often map 1:1).

"A container is something that needs to be running in order for the overall software system to work." β€” Simon Brown


🎯 Stakeholder Focus

StakeholderWhat they need from L2Questions they ask
ArchitectsTech decisions, API boundaries"Why Go for API and React for frontend?"
DevelopersSystem structure, cross-app communication"How do services talk to each other?"
Ops/DevOpsDeployment strategy, infrastructure"How many containers? What needs monitoring?"
SecurityTrust boundaries, data flow"What protocols encrypt data in transit?"

πŸ—οΈ Container Types & Mapping

Container TypeDescriptionMaps ToExample Tech
Web ApplicationBrowser-based UIBuild artifact (SPA bundle)React, Vue, Angular
Mobile AppNative or cross-platform mobileApp store binaryiOS (Swift), Android (Kotlin), Flutter
API ApplicationHTTP/gRPC API serverDocker container, K8s deploymentGo, Python/FastAPI, Node.js/Express, Java/Spring
DatabasePersistent data storeManaged DB, persistent volumePostgreSQL, MySQL, MongoDB, Redis
Message BrokerAsync messagingK8s StatefulSet, managed serviceKafka, RabbitMQ, AWS SQS, NATS
File StoreObject/blob storageCloud bucket, NFSS3, GCS, Azure Blob
Background WorkerAsync job processorK8s CronJob, queue consumerCelery, Sidekiq, Go worker
CacheIn-memory dataRedis/Memcached instanceRedis, Memcached

Infrastructure Mapping Rules

L2 Container          β†’   Infrastructure Artifact
─────────────────────────────────────────────────────
Web App               β†’   Docker image + Nginx/CDN
API Service           β†’   Docker container + K8s Deployment
Database              β†’   Cloud SQL / RDS / Persistent Volume
Message Broker        β†’   K8s StatefulSet / Managed Service
Background Worker     β†’   K8s CronJob / Queue Consumer
Cache                 β†’   Redis Cluster / ElastiCache

🚫 Anti-Patterns to Guard (Level 2)

Anti-PatternSymptomFix
Flowchart ConfusionBusiness logic steps in diagramUse sequence diagram for flows. L2 shows structure, not process
Library as Container"Shared Utils", "Common Library" as boxesLibraries are code (L3/L4), not deployable units
Diagram Overload>10 containers in one viewSplit: "Customer View", "Admin View", "Data Pipeline View"
Missing ProtocolsArrows without labelsEvery arrow needs protocol: "JSON/HTTPS", "gRPC/TCP", "SQL/TCP"
Shared DatabaseMultiple containers β†’ one DB without ownershipEach container should own its data. Shared DB = tight coupling
Missing BoundariesContainers floating without system boundaryWrap in System_Boundary to show scope

πŸ” Codebase Scanning (L2 Synthesis)

To identify containers in an existing codebase, scan for:

Build Manifests (Tech Stack)

# JavaScript/TypeScript
package.json β†’ frontend framework, backend runtime

# Go
go.mod β†’ modules, HTTP framework (gin, echo, chi)

# Java
pom.xml / build.gradle β†’ Spring Boot, dependencies

# Python
requirements.txt / pyproject.toml β†’ FastAPI, Django, Flask

Deployment Artifacts

Dockerfile          β†’ Container definition
docker-compose.yml  β†’ Multi-container setup
k8s/                β†’ Kubernetes manifests
terraform/          β†’ Infrastructure as Code
serverless.yml      β†’ Serverless functions (Lambda, etc.)

Service Boundaries

# Look for separate entry points
src/main.go         β†’ API service
cmd/worker/main.go  β†’ Background worker
web/                β†’ Frontend application

πŸ“ Mermaid Templates

Template A: Monolith with Frontend

C4Container
    title Container Diagram for E-Commerce Platform

    Person(customer, "Customer", "Registered user browsing products.")

    System_Boundary(ecommerce, "E-Commerce Platform") {
        Container(web_app, "Web Application", "React/TypeScript", "Customer-facing SPA.")
        Container(api, "API Service", "Go/gRPC", "Business logic, authentication, order processing.")
        ContainerDb(db, "Primary Database", "PostgreSQL", "Users, products, orders, inventory.")
        Container(cache, "Cache", "Redis", "Session store, product catalog cache.")
        Container(worker, "Order Processor", "Go", "Processes payment confirmation, sends emails.")
        ContainerQueue(queue, "Message Queue", "RabbitMQ", "Async order events.")
    }

    System_Ext(payment, "Payment Gateway", "Stripe/PayPal")
    System_Ext(email, "Email Service", "SendGrid")

    Rel(customer, web_app, "Browses, purchases", "HTTPS")
    Rel(web_app, api, "Calls API", "JSON/HTTPS")
    Rel(api, db, "Reads/Writes", "SQL/TCP")
    Rel(api, cache, "Caches data", "Redis Protocol")
    Rel(api, queue, "Publishes events", "AMQP")
    Rel(worker, queue, "Consumes events", "AMQP")
    Rel(worker, email, "Sends emails", "REST API/HTTPS")
    Rel(api, payment, "Processes payments", "REST API/HTTPS")

Template B: Microservices Architecture

C4Container
    title Container Diagram for Microservices Platform

    Person(customer, "Customer", "End user of the platform.")

    Container(api_gateway, "API Gateway", "Kong/AWS API Gateway", "Routing, rate limiting, auth.")
    Container(web_app, "Web App", "Next.js", "Customer-facing UI.")

    System_Boundary(platform, "Platform Services") {
        Container(user_svc, "User Service", "Go/gRPC", "User profiles, authentication.")
        Container(order_svc, "Order Service", "Go/gRPC", "Order creation, status tracking.")
        Container(product_svc, "Product Service", "Python/FastAPI", "Product catalog, search.")
        Container(inventory_svc, "Inventory Service", "Go/gRPC", "Stock levels, reservations.")
        Container(notification_svc, "Notification Service", "Node.js", "Email, SMS, push notifications.")

        ContainerDb(user_db, "User DB", "PostgreSQL", "User data.")
        ContainerDb(order_db, "Order DB", "PostgreSQL", "Order data.")
        ContainerDb(product_db, "Product DB", "MongoDB", "Product documents.")
        ContainerDb(inventory_db, "Inventory DB", "PostgreSQL", "Stock data.")

        ContainerQueue(event_bus, "Event Bus", "Kafka", "Domain events between services.")
    }

    System_Ext(payment, "Payment Gateway", "Stripe")
    System_Ext(search, "Search Engine", "Elasticsearch")

    Rel(customer, web_app, "Uses", "HTTPS")
    Rel(web_app, api_gateway, "Calls APIs", "JSON/HTTPS")
    Rel(api_gateway, user_svc, "Routes to", "gRPC/TLS")
    Rel(api_gateway, order_svc, "Routes to", "gRPC/TLS")
    Rel(api_gateway, product_svc, "Routes to", "gRPC/TLS")

    Rel(user_svc, user_db, "Reads/Writes", "SQL/TCP")
    Rel(order_svc, order_db, "Reads/Writes", "SQL/TCP")
    Rel(product_svc, product_db, "Reads/Writes", "MongoDB Protocol")
    Rel(inventory_svc, inventory_db, "Reads/Writes", "SQL/TCP")

    Rel(order_svc, event_bus, "Publishes OrderPlaced", "Kafka Protocol")
    Rel(inventory_svc, event_bus, "Consumes OrderPlaced", "Kafka Protocol")
    Rel(notification_svc, event_bus, "Consumes OrderPlaced", "Kafka Protocol")

    Rel(order_svc, payment, "Processes payment", "REST API/HTTPS")
    Rel(product_svc, search, "Indexes products", "REST API/HTTPS")

Template C: Serverless / Event-Driven

C4Container
    title Container Diagram for Serverless Data Pipeline

    Person(analyst, "Data Analyst", "Consumes processed data.")

    System_Boundary(pipeline, "Data Pipeline") {
        Container(ingestion, "Ingestion Function", "AWS Lambda / Python", "Receives and validates incoming data.")
        Container(transform, "Transform Function", "AWS Lambda / Python", "Cleans and enriches data.")
        Container(store, "Data Store", "S3", "Raw and processed data files.")
        Container(warehouse, "Data Warehouse", "Snowflake", "Structured data for analytics.")
        Container(scheduler, "Scheduler", "AWS EventBridge", "Triggers pipeline runs.")
    }

    System_Ext(source, "Data Source", "External API / SFTP")
    System_Ext(dashboard, "BI Dashboard", "Tableau / Looker")

    Rel(source, ingestion, "Pushes data", "HTTPS / SFTP")
    Rel(scheduler, ingestion, "Triggers", "EventBridge")
    Rel(ingestion, store, "Stores raw", "S3 API")
    Rel(ingestion, transform, "Invokes", "Lambda Invoke")
    Rel(transform, warehouse, "Loads processed", "Snowflake SQL")
    Rel(analyst, dashboard, "Views reports", "HTTPS")
    Rel(dashboard, warehouse, "Queries", "SQL/JDBC")

πŸ—οΈ Deployment Patterns

Pattern 1: Single Monolith

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Load Balancer              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Monolithic App   β”‚
    β”‚  (Web + API +     β”‚
    β”‚   Background)     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  Database         β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When to use: Small team (<5), simple domain, rapid prototyping.

Pattern 2: Frontend + Backend Split

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CDN/Web    │────▢│  API        β”‚
β”‚  (React)    β”‚     β”‚  (Go/Java)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό            β–Ό            β–Ό
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚  DB    β”‚  β”‚ Cache  β”‚  β”‚ Queue  β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When to use: Separate frontend/backend teams, different deployment cadences.

Pattern 3: Microservices with API Gateway

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  API Gateway β”‚
                    β”‚  (Kong/AWS)  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                  β–Ό                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Service β”‚      β”‚ Service β”‚      β”‚ Service β”‚
   β”‚   A     β”‚      β”‚   B     β”‚      β”‚   C     β”‚
   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
        β”‚                β”‚                β”‚
        β–Ό                β–Ό                β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  DB A   β”‚      β”‚  DB B   β”‚      β”‚  DB C   β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When to use: Multiple teams, independent deployability, complex domain.


βœ… Level 2 Success Criteria

  • Are all containers separately deployable/runnable units?
  • Are all cross-container protocols (JSON, SQL, gRPC) specified?
  • Is the diagram readable (≀10 containers per view)?
  • SMART: Do containers match build/deployment artifacts in the code?
  • SMART: Does each container own its data (no shared DB)?
  • Are external systems clearly marked?
  • Is there a system boundary around owned containers?

πŸ”„ From L2 to L3

When you're ready to zoom into a container:

L2 SignalL3 Action
"This container has 5+ responsibilities"Split into components
"Developers don't understand internal structure"Draw component diagram
"We have circular imports"L3 reveals dependency cycles
"This is our Core Domain"Deep dive with ddd-tactical

Next: Use c4-level3-component to design internal architecture.


πŸ“š References

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.