PlantUML Component Diagram: Microservices Architecture
Document microservices architecture with PlantUML component diagrams. Show services, APIs, databases, and communication patterns in a single diagram.
Detailed Explanation
Microservices Architecture with Component Diagrams
Component diagrams show the structural organization of a system in terms of its components and their interfaces. For microservices, each service is a component with defined API boundaries.
Basic Microservices Layout
@startuml
title Microservices Architecture
package "API Layer" {
[API Gateway] as GW
[GraphQL Federation] as GQL
}
package "Core Services" {
[User Service] as US
[Order Service] as OS
[Product Service] as PS
[Payment Service] as PAY
}
package "Supporting Services" {
[Notification Service] as NS
[Search Service] as SS
[File Service] as FS
}
package "Data Stores" {
database "Users DB\n(PostgreSQL)" as UDB
database "Orders DB\n(PostgreSQL)" as ODB
database "Products DB\n(MongoDB)" as PDB
database "Search Index\n(Elasticsearch)" as ES
queue "Message Broker\n(Kafka)" as MQ
database "Object Storage\n(S3)" as S3
}
GW --> US
GW --> OS
GW --> PS
GQL --> US
GQL --> OS
US --> UDB
OS --> ODB
PS --> PDB
PAY --> OS
OS --> MQ : OrderCreated
MQ --> NS : consume
MQ --> SS : consume
SS --> ES
FS --> S3
PS --> ES : sync products
@enduml
Packages and Layers
Use package blocks to group services into architectural layers. Common layers include API Layer, Core Services, Supporting Services, and Data Stores.
Interface Notation
interface "REST API" as REST
interface "gRPC" as GRPC
[User Service] -up- REST
[User Service] -down- GRPC
[API Gateway] --> REST
[Order Service] --> GRPC
Interfaces show the communication protocol. This documents whether services communicate via REST, gRPC, GraphQL, or messaging.
Database Per Service
Each service in the diagram has its own database, which is the defining characteristic of microservices. The diagram makes this architectural decision explicit and visible.
Async Communication
Use queue components for message brokers. Label the arrows with event names to show what triggers each subscription.
Use Case
Creating architecture decision records (ADRs), onboarding new team members to system architecture, presenting technical designs to architecture review boards, and planning service decomposition during monolith-to-microservices migration.
Try It — PlantUML Editor
Related Topics
PlantUML Component Diagram: Layered Architecture
Component Diagrams
PlantUML Deployment Diagram: Cloud Infrastructure
Deployment Diagrams
PlantUML Sequence Diagram: Async Message Queues
Sequence Diagrams
PlantUML Class Diagram: Domain Modeling
Class Diagrams
PlantUML Activity Diagram: CI/CD Pipeline Visualization
Activity Diagrams