Architecture Mapper
Generate multi-level architectural views (C4 model) from codebase analysis, revealing system context, containers, components, and their relationships.
Guiding Principle
"Architecture is the decisions you wish you could get right early. Visibility is how you verify them."
Procedure
Step 1 — System Context Discovery
- Identify all external systems the codebase integrates with (APIs, databases, message brokers, third-party services).
- Grep for HTTP client configurations, connection strings, and SDK initializations.
- Map user-facing interfaces: web apps, mobile APIs, CLI tools.
- Document each external boundary with protocol and data flow direction.
- Produce a C4 Level 1 (System Context) Mermaid diagram.
Step 2 — Container Identification
- Identify deployable units: web servers, API services, workers, databases, caches, queues.
- Map inter-container communication: REST, gRPC, message queues, shared databases.
- Detect container boundaries from Docker configs, deployment manifests, or module structure.
- Classify each container by technology and runtime.
- Produce a C4 Level 2 (Container) Mermaid diagram.
Step 3 — Component Analysis
- Within each container, identify major components (modules, packages, bounded contexts).
- Trace dependency injection, imports, and interface boundaries.
- Map component responsibilities using naming conventions and code organization.
- Identify architectural patterns: layered, hexagonal, CQRS, event-driven, microkernel.
- Produce C4 Level 3 (Component) Mermaid diagrams per container.
Step 4 — Relationship & Pattern Synthesis
- Build a dependency graph across all levels.
- Identify circular dependencies and tight coupling.
- Classify the dominant architectural style with evidence.
- Flag architectural drift: where implementation diverges from apparent intent
[INFERENCIA].
Quality Criteria
- Each diagram level follows C4 model conventions
- All relationships backed by code evidence
[HECHO]
- Architectural pattern classification includes supporting evidence
- External system boundaries clearly identified
Anti-Patterns
- Drawing diagrams from README descriptions instead of actual code
- Conflating logical architecture with physical deployment
- Missing async/event-driven relationships (only mapping synchronous calls)
- Producing a single flat diagram instead of layered C4 views