Background
Sections
IntroductionRequirements & Problem AnalysisConstraints & AssumptionsEstimation TechniquesFunctional vs Non-Functional RequirementsMoSCoW PrioritizationSystem Design FundamentalsArchitecture DiagramClass DiagramComponent DiagramData Flow Diagram (DFD)ER Diagram (Entity-Relationship Diagram)High Level Design (HLD)Low Level Design (LLD)Sequence DiagramState DiagramUse Case DiagramData StorageDocument StoresFile StorageGraph DatabasesIn-Memory DatabasesKey-Value StoresNewSQLNoSQL DatabasesObject StorageSQL Databases (RDBMS)Time-Series DatabasesWide-Column StoresDatabase ConceptsACID PropertiesCAP TheoremConsistency ModelsIndexingNormalization & DenormalizationReplicationSharding & PartitioningTransactions & Isolation LevelsScalabilityAuto-Scaling & ElasticityConsensus & Leader ElectionLoad BalancingReplication & Read ReplicasSharding & PartitioningVertical vs Horizontal ScalingAvailability & ReliabilityBackup & Data DurabilityCircuit BreakerData ConsistencyDisaster RecoveryFault Tolerance & FailoverGraceful DegradationHigh AvailabilityNetworkingCDNDNSFirewalls & VPNHTTP & HTTPSLoad Balancer & Reverse ProxyTCP/IP & UDPWebSocketsCachingCache InvalidationCache Read/Write PatternsCaching LayersEviction PoliciesRedis vs MemcachedMessaging & CommunicationDead-Letter QueueIdempotencyKafka vs RabbitMQ vs SQSMessage QueuesPub/SubCompute & ServicesAPI GatewayContainers & OrchestrationMonolith vs MicroservicesServerlessService DiscoveryService MeshWeb Server & App ServerAPI DesignAPI Versioning & IdempotencyAuthentication & AuthorizationGraphQLgRPCPaginationRate Limiting & ThrottlingRESTSecurityAuthentication & AuthorizationData PrivacyEncryptionInput Validation & InjectionOAuth2 & JWTSecrets ManagementXSS & CSRFStorage & File SystemsBackup & RetentionBlock vs File vs Object StorageData Lakes & WarehousesDistributed File SystemsEphemeral StorageObservability & MonitoringDistributed TracingHealth ChecksLoggingMetricsSLI, SLO, SLADesign PatternsBulkhead PatternCircuit Breaker PatternCreational PatternsRate Limiter PatternRetry PatternStructural & Behavioral Patterns

Component Diagram

6 min read

In a Nutshell

A component diagram shows module dependencies — which parts of your system depend on which other parts. While an architecture diagram shows infrastructure (servers, databases, caches), a component diagram focuses on the logical building blocks (modules, libraries, services) and the interfaces between them. It answers: "What depends on what, and through which interfaces?" This is essential for understanding coupling, planning deployments, and deciding where to draw service boundaries.

2D minimalistic component diagram showing three rectangular component boxes with ports (small squares on edges) and dependency arrows between them, labeled with interface names

How It Actually Works

Notation

Symbol Meaning Example
Component Rectangle with «component» stereotype or component icon OrderService, PaymentModule, AuthLibrary
Interface (provided) Lollipop (circle on a stick) on the component boundary IPaymentProcessor — this component offers this interface
Interface (required) Socket (half-circle) on the component boundary IPaymentProcessor — this component needs this interface
Dependency Dashed arrow → Component A depends on Component B
Port Small square on the component edge The point where an interface is exposed

What It Reveals

A good component diagram answers:

  • What can be deployed independently? — Components with no cyclic dependencies can be deployed separately
  • Where are the coupling risks? — If Component A depends on 8 other components, it's a deployment bottleneck
  • What is the blast radius of a change? — Changing an interface affects every component that depends on it
  • Where should you draw service boundaries? — Components with heavy internal interaction and light external interaction are natural microservice candidates

When to Use It

  • Microservices boundary decisions — "Should these three modules be one service or three?"
  • Dependency analysis — "If we change the payment module, what else breaks?"
  • Monolith decomposition — Mapping the modules inside a monolith to plan extraction into services
  • Library/SDK design — Showing which packages depend on which, and which interfaces are public

2D minimalistic diagram showing a monolith rectangle containing six internal component boxes with dependency arrows, and dashed lines showing potential service boundaries where coupling is lowest

Seeing It in Action

Scenario: Component diagram for an e-commerce monolith being evaluated for microservice extraction

┌─────────────────────────────────────────────────────────────┐
│                    E-Commerce Monolith                       │
│                                                             │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐  │
│  │   Catalog     │    │    Cart      │    │   Checkout    │  │
│  │   Module      │───▶│   Module     │───▶│   Module     │  │
│  │              │    │              │    │              │  │
│  │ IProductQuery │    │ ICartManager │    │IOrderCreator │  │
│  └──────────────┘    └──────────────┘    └──────┬───────┘  │
│                                                  │          │
│                                           ┌──────▼───────┐  │
│  ┌──────────────┐                         │   Payment    │  │
│  │    User       │                         │   Module     │  │
│  │   Module      │────────────────────────▶│              │  │
│  │              │                         │IPayProcessor │  │
│  │ IUserProfile │                         └──────┬───────┘  │
│  └──────────────┘                                │          │
│                                           ┌──────▼───────┐  │
│                                           │ Notification │  │
│                                           │   Module     │  │
│                                           │              │  │
│                                           │ INotifier    │  │
│                                           └──────────────┘  │
│                                                             │
│  - - - - - - Potential service boundaries - - - - - - - -   │
│  Boundary 1: [Catalog] ← low coupling to rest              │
│  Boundary 2: [Payment + Notification] ← high internal      │
│              coupling, deploy together                       │
└─────────────────────────────────────────────────────────────┘

Insights from this diagram:

  • Catalog Module has no inbound dependencies from other modules → easiest to extract as a microservice
  • Payment and Notification are tightly coupled (payment always triggers notification) → extract together or keep communication internal
  • Cart depends on Catalog (needs product info) → if Catalog becomes a service, Cart needs an API call instead of a direct import
  • User Module is depended on by Payment → consider keeping it as a shared library or extracting it early

Interview Questions

  1. Q: How does a component diagram differ from an architecture diagram? Hint: Architecture diagram shows infrastructure (servers, databases, networks). Component diagram shows logical modules and their dependencies/interfaces. You can have multiple components deployed on the same server — the component diagram doesn't care about infrastructure.

  2. Q: How would you use a component diagram to plan a monolith-to-microservice migration? Hint: Map all modules and their dependencies. Identify clusters with high internal coupling and low external coupling — these are natural service boundaries. Start by extracting the module with the fewest inbound dependencies (lowest risk). The component diagram makes coupling visible and quantifiable.

  3. Q: What does a circular dependency in a component diagram tell you? Hint: It means two components can't be deployed or tested independently — they're effectively one unit despite being in separate modules. Fix by extracting the shared dependency into a third component, using dependency inversion (introduce an interface), or merging the components.

  4. Q: How do provided and required interfaces help in system design? Hint: They make contracts explicit. A provided interface says "here's what I offer." A required interface says "here's what I need." This separation lets you swap implementations (Strategy pattern at the system level), mock dependencies for testing, and evolve components independently as long as the interface is stable.

  5. Q: You're designing a plugin system where third parties can add features. How would a component diagram help? Hint: Show the core system as a component with defined extension interfaces (ports). Each plugin is a separate component that implements those interfaces. The diagram makes clear: plugins depend on the core's interfaces, but the core doesn't depend on any plugin — this is the Dependency Inversion principle at the system level.

References

Dive Deeper

  • Building Evolutionary Architectures by Ford, Parsons & Kua — using component coupling metrics to guide architecture evolution
  • ArchUnit — automated architecture testing that enforces component dependency rules in code
  • Monolith to Microservices by Sam Newman — practical strategies for decomposing monoliths using dependency analysis