| name | c4model-c2 |
| description | C4 Model Level 2 (Container) methodology for identifying deployable units, technology stacks, and runtime environments. Use when analyzing software architecture at the container abstraction level, identifying what deployable/runnable units exist, what technologies they use, and how they communicate. Keywords - container level, C2 level, container identification, deployable units, technology stack, runtime environment, application server, web server, database container, technology detection, framework analysis, deployment model, containerization, docker, kubernetes, microservices containers, spa container, api server, message broker, cache container, infrastructure as code. |
C4 Model - Level 2: Container Methodology
Navigation
- Technology Detection Patterns - Comprehensive guide to detecting frameworks, languages, and tooling
- Container Types Reference - Complete reference for all 10 container types with examples
- Communication Patterns - How containers communicate (HTTP, gRPC, queues, databases)
- Common Container Patterns - Reusable architecture patterns (SPA+API+DB, microservices, serverless)
- Observation Categories - 8 observation categories with examples
- Troubleshooting Guide - Solutions to common problems
Overview
You are an expert in the C4 Model's Level 2 (Container) methodology. This skill provides comprehensive knowledge for identifying and documenting containers (deployable/runnable units) at the second level of architectural abstraction.
Your Mission: Help identify WHAT deployable units exist within each system, WHAT technologies they use, and HOW they communicate - focusing on the building blocks that get deployed to production.
C2 Container Level Definition: A container represents an application or data store that executes code or stores data. It's something that needs to be running for the overall system to work. Think: web servers, application servers, standalone applications, databases, file systems, message brokers.
Relationship to Other Levels:
- C1 (System Context) - Identified high-level systems → Now we decompose each system into containers
- C2 (Container) - YOU ARE HERE - Identify deployable/runnable units within each system
- C3 (Component) - Will identify code modules within each container (next level)
C2 Level Definition
What is a Container (C2)?
A container at C2 level is a deployable/runnable unit:
- Deployable Unit - Can be deployed independently (even if part of a larger system)
- Runs Code or Stores Data - Executes application logic or persists information
- Has Technology Stack - Built with specific languages, frameworks, libraries
- Has Runtime Environment - Runs in browser, server, cloud, mobile device
- Communicates via Protocols - HTTP, gRPC, database connections, message queues
Important: Container in C4 Model ≠ Docker container
- C4 "container" = deployable/runnable unit (broader concept)
- Docker container is one possible deployment technology
Abstraction Level
┌─────────────────────────────────────────────┐
│ C1: System Context │
│ "What systems exist?" │
├─────────────────────────────────────────────┤
│ C2: Container Level │ ← YOU ARE HERE
│ "What are the deployable units?" │
├─────────────────────────────────────────────┤
│ C3: Component Level │
│ "What are the code modules?" │
├─────────────────────────────────────────────┤
│ C4: Code Level │
│ "What are the classes/functions?" │
└─────────────────────────────────────────────┘
At C2, we focus on:
- ✅ Deployable/runnable units (what gets deployed)
- ✅ Technology stack (languages, frameworks, versions)
- ✅ Runtime environment (browser, server, cloud, mobile)
- ✅ Communication protocols (HTTP, gRPC, database, messaging)
- ✅ Deployment model (containerized, serverless, standalone)
At C2, we do NOT focus on:
- ❌ Code structure (that's C3 Component level)
- ❌ Classes and functions (that's C4 Code level)
- ❌ System boundaries (that was C1 System level)
- ❌ Line-by-line code analysis
Container Identification Methodology
Step 1: Understand System Decomposition
Start by reviewing the systems identified at C1 level in c1-systems.json:
Questions to ask:
- What systems were identified at C1?
- What repositories belong to each system?
- What is the system type (web-application, api-service, etc.)?
- What technologies were mentioned in system observations?
System-to-Container Mapping Examples:
Simple Web Application System →
- Frontend SPA container (React/Vue/Angular in browser)
- Backend API container (Express/Django/Spring on server)
- Database container (PostgreSQL/MongoDB)
- Cache container (Redis) - optional
Microservice System →
- API Server container (main service logic)
- Database container (service-specific database)
- Worker container (background processing) - optional
- Message broker container (RabbitMQ/Kafka) - if async
Mobile App System →
- Mobile Application container (React Native/Flutter on mobile)
- Backend API container (supporting backend)
- Database container
- Push notification service container - optional
See Common Container Patterns for 6 reusable architecture patterns.
Step 2: Apply Container Identification Rules
✅ A Container IS:
- Deployable independently - Has own build/deployment process and artifact
- Executes code OR stores data - Runs application logic or persists data
- Has distinct technology stack - Built with specific language/framework
- Has runtime environment - Runs in specific environment (browser, server, mobile, cloud)
- Communicates via defined protocols - HTTP, database connections, message queues
- Infrastructure component - Databases, caches, message brokers required for system operation
❌ A Container is NOT:
Code modules within an application (these are C3 components)
- ❌ "Authentication Module" in React app → C3 Component
- ✅ "Express API Application" → C2 Container
Configuration files or static assets - package.json, CSS files, images
Development tools - Webpack, Babel, ESLint, Jest test runner
Generic names without technology
- ❌ "Frontend Container" → ✅ "React SPA Container"
- ❌ "Backend Container" → ✅ "Express API Server Container"
Over-granular decomposition
- ❌ "Login API" + "Register API" → ✅ "User Management API"
See Troubleshooting Guide for detailed guidance.
Step 3: Analyze Repository Structure
For each system, examine its repositories to identify containers:
Look for deployment indicators:
# Check for containerization
find . -name "Dockerfile" -o -name "docker-compose.yml"
# Check for build outputs
ls -la dist/ build/ target/ out/
# Check for deployment configs
ls -la .kubernetes/ .aws/ .azure/ vercel.json netlify.toml
Common patterns:
- Frontend SPA:
public/index.html,src/App.tsx,package.jsonwith React/Vue/Angular - Backend API:
src/server.js,app.py,Main.javawith Express/Django/Spring - Database:
docker-compose.ymldefining database service, migration files - Worker: Queue consumer code,
worker.js,worker.py
Step 4: Detect Technology Stack
For each container, identify:
Primary Language
JavaScript, TypeScript, Python, Java, Go, Ruby, PHP, C#, Rust
Detection methods:
# Check package manifests
cat package.json | jq '.dependencies'
cat requirements.txt
cat pom.xml
# Count file extensions
find src -name "*.ts" | wc -l
find src -name "*.py" | wc -l
# Check Dockerfile
cat Dockerfile | grep "FROM"
Framework/Platform
React, Vue, Angular (frontend) | Express, NestJS, FastAPI, Django, Spring Boot (backend)
Detection methods:
- Check dependencies in package manifests
- Look for framework-specific files (
angular.json,vue.config.js) - Analyze import statements
See Technology Detection Patterns for complete detection guide.
Step 5: Identify Runtime Environment
For each container, determine:
Environment
- browser - Runs in web browser (SPAs)
- server - Runs on server (APIs, web servers)
- mobile - Runs on mobile device (iOS/Android)
- cloud - Runs in cloud (Lambda, Cloud Functions)
- edge - Runs at edge (Cloudflare Workers)
Platform
- Browser: Chrome, Firefox, Safari, Edge
- Server: Linux, Node.js 18, Python 3.11, JVM 17
- Mobile: iOS 14+, Android 11+
Containerization
- Containerized: true/false
- Container Technology: Docker, Kubernetes, ECS
- Container Image:
node:18-alpine,python:3.11-slim
Container Types Quick Reference
10 Container Types:
- spa - Single-Page Application (browser)
- mobile-app - iOS/Android application
- desktop-app - Desktop application
- api / app-server - Backend API server
- web-server - Web server, reverse proxy
- database - Relational or NoSQL database
- cache - In-memory cache (Redis, Memcached)
- message-broker - Message queue/event streaming
- worker - Background job processor
- file-storage - Object storage, file system
See Container Types Reference for detailed examples of all 10 types.
Communication Pattern Identification
Identify Relationships Between Containers
Document how containers communicate using these patterns:
Synchronous:
- http-rest - RESTful HTTP API
- http-graphql - GraphQL API
- grpc - gRPC remote procedure calls
- websocket - WebSocket bidirectional communication
Asynchronous:
- message-publish - Publish to queue/topic
- message-subscribe - Subscribe to queue/topic
Data Access:
- database-query - Database read/write
- cache-read-write - Cache read and write
- file-storage-access - File upload/download
See Communication Patterns for complete patterns guide.
Detection Commands
# Find HTTP clients
grep -r "axios\|fetch\|requests" src/
# Find database connections
grep -r "DATABASE_URL\|DB_HOST" .env
# Find message brokers
grep -r "amqplib\|kafkajs\|redis.*publish" src/
Observation Categories
When documenting containers, capture these 8 observation categories:
- technology - Technology stack, frameworks, libraries, versions
- runtime - Runtime environment, platform, deployment model
- communication - How container communicates with others
- data-storage - Data persistence, caching, storage patterns
- authentication - Authentication and authorization mechanisms
- configuration - Configuration management, environment variables
- monitoring - Logging, monitoring, observability
- dependencies - External dependencies, third-party services
Severity Levels:
- info - Informational observation (neutral)
- warning - Potential issue requiring attention
- critical - Critical issue requiring immediate action
See Observation Categories for detailed guidelines and examples.
Workflow Integration
When This Skill is Used
This skill is activated during:
Phase 3: C2 Container Identification (
/melly-c2-containers)- Primary usage phase
- Container identification per system
- Technology stack detection
Manual Container Analysis
- User asks "what containers exist?"
- User asks "what is the technology stack?"
- User mentions keywords: "deployable units", "runtime environment", "containerization"
Input Requirements
Required Files:
c1-systems.json- Must exist with identified systems- Repository access - Must be able to read system repositories
Required Information:
- System ID to analyze
- Repository paths
- System type and technologies (from C1)
Output Format
Generate c2-containers.json with:
{
"metadata": {
"version": "1.0.0",
"timestamp": "2025-11-17T20:20:00.000Z",
"generated_by": "c2-abstractor",
"parent": {
"file": "c1-systems.json",
"timestamp": "2025-11-17T10:00:00.000Z"
}
},
"containers": [
{
"id": "ecommerce-spa",
"name": "E-Commerce Customer Portal",
"type": "spa",
"system_id": "ecommerce-system",
"technology": {
"primary_language": "TypeScript",
"framework": "React 18.2.0",
"libraries": [
{"name": "React Router", "version": "6.14.0", "purpose": "Client-side routing"},
{"name": "Redux Toolkit", "version": "1.9.5", "purpose": "State management"}
]
},
"runtime": {
"environment": "browser",
"platform": "Modern browsers (Chrome 90+, Firefox 88+, Safari 14+)",
"containerized": false
},
"relations": [
{
"target": "ecommerce-api",
"type": "http-rest",
"direction": "outbound",
"description": "Fetches product data and submits orders"
}
],
"observations": [],
"metadata": {
"repository": "frontend/",
"discovered_at": "2025-11-17T20:15:00.000Z"
}
}
]
}
Validation
After generating c2-containers.json:
# Validate JSON structure
python plugins/melly-validation/scripts/validate-c2-containers.py c2-containers.json
# Verify timestamps
python plugins/melly-validation/scripts/check-timestamp.sh c2-containers.json c1-systems.json
Best Practices
DO:
- Start with C1 understanding - Review c1-systems.json first
- Focus on deployment boundary - What can be deployed separately?
- Be specific with technology - Include versions (React 18, not just React)
- Document runtime precisely - Exact platform and containerization details
- Capture all communication - Document how containers interact
- Use proper container types - Choose from 10 defined types
- Provide evidence - Link observations to files/commands
- Validate early - Run validation scripts frequently
DON'T:
- Don't confuse C2 with C3 - Components are code modules, not containers
- Don't be too granular - 20+ containers likely means you're at C3 level
- Don't use generic names - "Frontend" → "React SPA"
- Don't skip infrastructure - Document databases, caches, brokers
- Don't guess - Only document what you can verify
- Don't ignore validation - Always validate before proceeding
Quick Reference Checklist
Container Identification Checklist
- Review C1 systems from c1-systems.json
- Identify deployable units per system
- Verify deployment boundary (can it be deployed separately?)
- Detect primary language and framework
- Identify runtime environment and platform
- Document communication patterns
- Capture observations (8 categories)
- Validate with melly-validation scripts
Required Fields Checklist
-
id- Unique container identifier -
name- Descriptive container name -
type- One of 10 container types -
system_id- Reference to C1 system -
technology.primary_language- JavaScript, Python, etc. -
technology.framework- React, Express, Django, etc. -
runtime.environment- browser, server, mobile, cloud -
runtime.platform- Exact platform details -
runtime.containerized- true/false -
relations[]- Communication with other containers
Summary
C2 Container Level focuses on:
- WHAT deployable units exist - Identify containers within each system
- WHAT technologies are used - Detect languages, frameworks, versions
- WHERE containers run - Identify runtime environments and platforms
- HOW containers communicate - Document protocols and patterns
Key Outputs:
c2-containers.json- Complete container inventory- Observations per container (8 categories)
- Communication patterns documented
- Technology stack validated
Next Steps: After completing C2 analysis:
- Validate with
validate-c2-containers.py - Review observations for warnings/critical issues
- Proceed to C3 (Component) level analysis
- Generate documentation with
/melly-doc-c4model
For detailed guidance, see the supporting documentation: