PlantUML Component Diagram: Free Guide with C4 Examples (2026)

PlantUML component diagram guide — syntax, C4 model, microservices examples and architecture best practices

PlantUML Component Diagram: Free Guide with C4 Examples (2026)

UML Standard Diagram Type
C4 Architecture Model Support
12+ Container Group Types
Free No Java Install Needed

A plantuml component diagram shows the static structure of a software system — the independent components (modules, services, subsystems), the interfaces they expose, and the dependencies between them. It is the UML diagram most commonly used for software architecture documentation and system design reviews.

This guide covers the full plantuml component diagram syntax, interface notation, package grouping, the difference between component and deployment diagrams, microservices mapping, C4 model integration, and real-world examples for e-commerce and CRM architectures.

Every code example in this guide works in our free PlantUML generator online — no Java needed, no install. Generate, preview, and export directly in the browser in under 30 seconds.

Generate your component diagram free — no install, no Java
Paste any code example from this guide into our free PlantUML generator and render it instantly in your browser. Export to PNG or SVG in one click.
Try Free Generator →
component-architecture.puml@startuml !theme cerulean package “Frontend” { [Web App] [Mobile App] } package “Backend” { [API Gateway] [User Service] [Order Service] } [Web App] –> [API Gateway] [API Gateway] –> [User Service] @enduml «package» Frontend Web App Mobile App «package» Backend API Gateway User Service Order Service User DB Order DB PlantUML Component Diagram — Code Rendered Architecture View

What Is a PlantUML Component Diagram and When Do You Use It?

A plantuml component diagram represents the static structure of a software system at the module or service level. It answers the question: “what are the major building blocks of this system and how do they connect?” Components are independent, replaceable units — a REST API, a frontend app, a caching layer, or a message queue.

Use this diagram type when you need to document system boundaries, explain how services communicate to new team members, review an architecture before building, plan a migration to microservices, or create the C3 level of a C4 model diagram set.

It differs from sequence diagrams (runtime interaction) and deployment diagrams (physical infrastructure). Component diagrams focus on logical software structure, not execution order or hardware placement. You can test examples immediately in our free PlantUML diagram generator.

💡 Component vs Deployment — the key distinction A component diagram answers “what software exists and how does it connect?” A deployment diagram answers “where does the software run?” Both are essential for complete architecture documentation. This guide focuses on the component level — see our deployment diagram guide for the infrastructure view.

PlantUML Component Diagram Syntax: Core Elements and Keywords

PlantUML component diagrams support two notations: square bracket shorthand ([Component]) and the explicit component keyword. Full syntax is documented at the official PlantUML component diagram reference. Both produce the same output. Choose square brackets for quick diagrams; use explicit declarations for named aliases and stereotypes.

Component Declaration Syntax

ElementSyntaxNotes
Component (shorthand)[Component Name]Quickest way to declare
Component (explicit)component "Name" as ALIASUse for aliases and stereotypes
Interface (circle)() "Interface Name" as IBall notation (provided)
Interface (explicit)interface "Name" as ISame as () notation
Port[C] - [I]Attach interface to component
Dependency arrow[A] --> [B]Solid dependency
Usage (dashed)[A] ..> [B]Dashed usage / realization
Required interface[C] -( [I]Socket notation (requires)
Arrow with label[A] --> [B] : HTTP/RESTLabel the connection
Stereotypecomponent "Name" <<service>>Adds stereotype label
Notenote right of [A] : textAnnotation on component
Hidden link (layout)[A] -[hidden]-> [B]Forces layout without visible arrow

Basic Component Diagram Example

@startuml
[Frontend] --> [Backend API] : HTTPS
[Backend API] --> [Database] : JDBC
[Backend API] --> [Cache] : Redis
[Backend API] --> [Message Queue] : AMQP
@enduml

Named Components with Aliases

@startuml
component "User Service" as US
component "Auth Service" as AS
component "Email Service" as ES

interface "UserAPI" as UAPI
interface "AuthAPI" as AAPI

US - UAPI
AS - AAPI

US --> AS : verifies via
AS --> ES : sends confirmation via
@enduml

PlantUML Component Diagram Interfaces: Required and Provided

PlantUML supports two interface notations from UML 2: provided interfaces (ball / circle notation — what a component offers) and required interfaces (socket notation — what a component needs). Together they describe the exact contract between components.

Interface TypeSyntaxUML SymbolMeaning
Provided interface[C] - () "API"Ball (filled circle)C provides this API to consumers
Required interface[C] -( "API"Socket (half-circle)C requires this API to function
Explicit interfaceinterface "API" as I
[C] - I
Named interface nodeReusable across multiple connections
Interface with label[A] - () "API" : RESTBall with labelLabel describes protocol or type
@startuml
component "Order Service" as OS
component "Payment Service" as PS
component "Inventory Service" as IS

interface "OrderAPI"
interface "PaymentAPI"
interface "StockAPI"

OS - OrderAPI
PS - PaymentAPI
IS - StockAPI

' Order Service requires Payment and Inventory
OS -( PaymentAPI : processes payment via
OS -( StockAPI : checks stock via
@enduml
💡 When to use interface notation Use explicit interface notation when your component diagram is part of a formal API contract document or when multiple components share the same interface. For informal architecture reviews, simple --> arrows with labels are cleaner and faster to write.

PlantUML Component Diagram with Packages, Groups and Frames

PlantUML component diagrams support 12+ grouping constructs for organizing components into layers, domains, or infrastructure zones. Each grouping type has a different visual border style, making it easy to distinguish frontend, backend, and data layers at a glance.

Grouping TypeSyntaxTypical Use
Packagepackage "Name" { ... }Software layer or domain
Nodenode "Name" { ... }Physical or virtual machine
Frameframe "Name" { ... }System or subsystem boundary
Cloudcloud "Name" { ... }Cloud provider grouping
Databasedatabase "Name" { ... }Data store boundary
Rectanglerectangle "Name" { ... }Generic labelled boundary
Folderfolder "Name" { ... }Module or directory grouping
Queuequeue "Name" { ... }Message queue boundary
Stackstack "Name" { ... }Technology stack grouping
Boundaryboundary "Name" { ... }Security or trust boundary
@startuml
!theme cerulean

package "Presentation Layer" {
  [Web Application]
  [Admin Dashboard]
}

package "Business Logic Layer" {
  [User Service]
  [Product Service]
  [Order Service]
}

package "Data Layer" {
  database "Primary DB"
  database "Cache"
}

cloud "Third-Party" {
  [Payment Gateway]
  [Email Provider]
}

[Web Application] --> [User Service]
[Web Application] --> [Product Service]
[Admin Dashboard] --> [Order Service]
[User Service] --> "Primary DB"
[Product Service] --> "Cache"
[Order Service] --> [Payment Gateway]
[Order Service] --> [Email Provider]
@enduml

PlantUML Component Diagram vs Deployment Diagram: Key Differences

Component and deployment diagrams are often confused because both show system structure. The core difference is their focus level: component diagrams are about logical software modules, while deployment diagrams are about physical infrastructure — servers, containers, VMs, and network zones.

💻 Component Diagram
  • Shows software modules, services, and subsystems
  • Focuses on what the software is and how modules connect
  • Elements: [Component], () Interface, package
  • Ignores where software is deployed
  • Maps to C4 model level C3 (Component)
  • Used for: design reviews, onboarding docs, API contracts
☁️ Deployment Diagram
  • Shows servers, VMs, containers, and network zones
  • Focuses on where software runs and how it is distributed
  • Elements: node, artifact, cloud
  • Ignores internal software module structure
  • Maps to C4 model level C2 (Container) and infrastructure
  • Used for: ops documentation, cloud architecture, DevOps planning
💡 Which to draw first? Draw the component diagram first to agree on software module boundaries, then draw the deployment diagram to show where those modules will run. The component diagram answers “what are we building?” — the deployment diagram answers “where will it live?”

PlantUML Component Diagram for Microservices Architecture

The plantuml component diagram is well-suited to microservices documentation. Each microservice becomes a component, API gateways become routing components, and databases follow the database-per-service pattern. Message queues and event buses appear as component nodes between producers and consumers.

The key principle is one component per independently deployable service. Avoid grouping multiple microservices into a single component — the diagram should reflect actual deployment boundaries so architecture reviews can identify coupling issues.

@startuml
!theme materia

package "Client Layer" {
  [Web Client]
  [Mobile Client]
}

package "API Gateway" {
  [Gateway / Load Balancer]
}

package "Core Microservices" {
  [User Service]
  [Product Service]
  [Order Service]
  [Notification Service]
}

package "Data Stores" {
  database "User DB"
  database "Product DB"
  database "Order DB"
}

queue "Event Bus" as EB

[Web Client]    --> [Gateway / Load Balancer]
[Mobile Client] --> [Gateway / Load Balancer]
[Gateway / Load Balancer] --> [User Service]
[Gateway / Load Balancer] --> [Product Service]
[Gateway / Load Balancer] --> [Order Service]
[User Service]    --> "User DB"
[Product Service] --> "Product DB"
[Order Service]   --> "Order DB"
[Order Service]   --> EB : publishes OrderPlaced
EB --> [Notification Service] : subscribes
@enduml
⚠️ Avoid over-specifying in component diagrams Keep microservices component diagrams at the service level. Do not add internal classes or methods — those belong in class diagrams. A good component diagram fits on one page and shows 5–15 components maximum. Split larger systems into multiple domain-scoped diagrams.
Render your microservices diagram free — no setup needed
Copy any code example from this page into our free PlantUML generator. It supports component, deployment, sequence, class and 7+ other diagram types — all in the browser.
Open Free Generator →

Using the C4 Model with PlantUML Component Diagrams

The C4 model by Simon Brown defines four levels of software architecture documentation: System Context (C1), Containers (C2), Components (C3), and Code (C4). The PlantUML component diagram maps directly to C3 — the component level inside a single container.

The C4-PlantUML library on GitHub provides official macros that wrap standard PlantUML syntax in C4-specific element types with consistent styling. Include it with a single !include directive.

C4 Component Diagram with C4-PlantUML Macros

@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml

LAYOUT_WITH_LEGEND()

Container(webApp, "Web Application", "React SPA", "Delivers the UI to users")
Container_Db(db, "Database", "PostgreSQL", "Stores user and order data")

Container_Boundary(api, "API Application (Spring Boot)") {
    Component(authC,  "Auth Component",  "Spring Security", "Handles login and token validation")
    Component(userC,  "User Component",  "Spring MVC",      "User profile management")
    Component(orderC, "Order Component", "Spring MVC",      "Order creation and tracking")
}

Rel(webApp, authC,  "Authenticates via",  "HTTPS/JSON")
Rel(webApp, userC,  "Manages profile via", "HTTPS/JSON")
Rel(webApp, orderC, "Places orders via",   "HTTPS/JSON")
Rel(authC,  db,     "Reads/writes",        "JDBC")
Rel(userC,  db,     "Reads/writes",        "JDBC")
Rel(orderC, db,     "Reads/writes",        "JDBC")
@enduml
C4 LevelWhat It ShowsPlantUML Diagram Type
C1 — System ContextYour system + external systems + usersC4_Context.puml
C2 — ContainersApplications, databases, microservicesC4_Container.puml
C3 — ComponentsModules inside a single containerC4_Component.puml
C4 — CodeClasses and relationshipsStandard class diagram
💡 Do you need the C4-PlantUML library? Not always — the library adds consistent styling. Structurizr is the original C4 tool by the model’s creator if you want a dedicated C4 editor. and legend support, but standard PlantUML component diagram syntax with packages and --> arrows produces the same logical content. Use the library when your team follows the formal C4 model documentation standard; use plain syntax for internal architecture notes.

Styling Your Component Diagram: Skinparam and Themes

Component diagrams support the full PlantUML skinparam system and all 40+ built-in themes. Applying a theme is the fastest way to change the visual style of your architecture diagram — add !theme NAME after @startuml. For precise color and font control, use the skinparam properties below.

Skinparam PropertyExample ValueEffect
skinparam ComponentBackgroundColor#dbeafeComponent box fill
skinparam ComponentBorderColor#1a56dbComponent box border
skinparam ComponentFontColor#0c1f4aComponent label text
skinparam InterfaceBackgroundColor#1a56dbInterface circle fill
skinparam ArrowColor#374151All arrow colors
skinparam ArrowFontColor#64748bArrow label text
skinparam PackageBackgroundColor#f1f5f9Package fill
skinparam PackageBorderColor#94a3b8Package border
skinparam ShadowingfalseRemove drop shadows
skinparam RoundCorner8Rounded component corners

Recommended themes for component diagrams: cerulean (professional blue), materia (clean material design), plain (minimal, good for print), and blueprint (dark technical style). See the full theme list in our PlantUML cheat sheet.

Real-World Examples: E-Commerce and CRM Architectures

These plantuml component diagram examples show production-grade system architectures you can adapt directly. For community-contributed architecture examples across many frameworks, real-world-plantuml.com has a large gallery. Each example uses packages for layer grouping, named aliases for readability, and arrow labels for protocol documentation.

E-Commerce Platform Component Diagram

@startuml
!theme cerulean
left to right direction

package "Customer Facing" {
  [Web Store]
  [Mobile App]
}

package "Core Services" {
  [API Gateway]
  [Product Catalog]
  [Shopping Cart]
  [Order Management]
  [Payment Service]
  [Inventory Service]
}

package "Data Stores" {
  database "Product DB"
  database "Order DB"
  database "Session Cache"
}

cloud "External Providers" {
  [Payment Gateway]
  [Email / SMS]
  [Shipping API]
}

[Web Store]   --> [API Gateway]
[Mobile App]  --> [API Gateway]
[API Gateway] --> [Product Catalog]
[API Gateway] --> [Shopping Cart]
[API Gateway] --> [Order Management]
[Shopping Cart]    --> "Session Cache"
[Product Catalog]  --> "Product DB"
[Order Management] --> [Payment Service]
[Order Management] --> [Inventory Service]
[Order Management] --> "Order DB"
[Payment Service]  --> [Payment Gateway]
[Order Management] --> [Email / SMS]
[Order Management] --> [Shipping API]
@enduml

SaaS CRM Component Diagram

@startuml
!theme materia

package "Web Layer" {
  [React SPA]
}

package "API Layer" {
  [Auth Service]
  [Contact Service]
  [Pipeline Service]
  [Reporting Service]
}

package "Integration Layer" {
  [Email Integration]
  [Calendar Sync]
  [Webhook Dispatcher]
}

package "Data Layer" {
  database "CRM Database"
  database "Analytics Store"
  database "File Storage"
}

[React SPA] --> [Auth Service]
[React SPA] --> [Contact Service]
[React SPA] --> [Pipeline Service]
[React SPA] --> [Reporting Service]
[Contact Service]  --> "CRM Database"
[Pipeline Service] --> "CRM Database"
[Reporting Service] --> "Analytics Store"
[Contact Service]  --> [Email Integration]
[Pipeline Service] --> [Webhook Dispatcher]
[Auth Service]     --> "File Storage"
@enduml

Best Practices for Software Architecture Teams

A well-drawn plantuml component diagram helps teams agree on system boundaries and reduces architecture drift. Follow these practices to keep your diagrams accurate and useful over time.

  • 1
    One component per independently deployable unit

    Map each independently deployable service to exactly one component. Avoid merging two services into one component — this hides real coupling and makes future migration discussions harder.

  • 2
    Keep diagrams to 15 components or fewer

    Diagrams with more than 15–20 components become hard to read. If your system is larger, split by domain: draw a top-level context diagram plus one component diagram per bounded context or microservice domain.

  • 3
    Label all arrows with protocol or relationship type

    Always label dependency arrows with the protocol or relationship type — HTTPS/REST, gRPC, AMQP, JDBC. Unlabeled arrows hide important architectural decisions that matter for security reviews and performance analysis.

  • 4
    Store .puml files in your repository

    Treat your component diagram source files as first-class code. Store .puml files in a /docs/architecture/ folder, review changes in pull requests, and generate PNG exports in CI/CD so the rendered diagram is always current.

  • 5
    Apply a consistent theme across your diagram set

    Use the same !theme across all component, deployment, and sequence diagrams in your project. Consistent visual language makes it easier for stakeholders to navigate between diagram types without re-learning visual conventions.

Start your component diagram now — free, instant, no install
Copy any example from this guide into our free PlantUML generator and render it in seconds. Export to PNG for docs or SVG for Confluence — no account required.
Generate Free →

PlantUML Component Diagram — Frequently Asked Questions

What is a PlantUML component diagram used for?

A plantuml component diagram is used to document the static software architecture of a system — showing which modules, services, and subsystems exist and how they depend on each other. Common use cases include onboarding new developers, documenting microservices boundaries, creating C4 model C3 diagrams, planning API contracts, and reviewing architecture before and after refactoring.

What is the difference between [Component] and () Interface notation in PlantUML?

Square brackets [Component] declare a software component — an independent module or service. Parentheses () Interface declare an interface contract. Use [C] - () "API" for a provided interface (ball notation) and [C] -( "API" for a required interface (socket notation).

These map to UML 2 lollipop and socket symbols respectively — provided interfaces show what a component offers, required interfaces show what it needs to function.

What is the difference between a component diagram and a deployment diagram in PlantUML?

A component diagram shows logical software modules and their connections — what the software is. A deployment diagram shows physical infrastructure — servers, containers, and where software runs. Component diagrams use [Component] elements and package groupings. Deployment diagrams use node, artifact, and cloud elements. Draw both for complete architecture documentation.

How do I add a database to a component diagram in PlantUML?

Use the database "Name" keyword to add a database element to a component diagram. It renders with a cylinder icon. Connect it to components with a standard arrow: [User Service] --> "User DB". You can also place it inside a package "Data Layer" { ... } block to group it with other data stores.

How do I group components into layers in PlantUML?

Use the package "Layer Name" { ... } syntax to group components. Place component declarations inside the curly braces. PlantUML also supports frame, cloud, node, rectangle, and database as alternative grouping constructs — each renders with a different border style. Use package for software layers and cloud for cloud provider zones.

Can I use component diagrams for microservices documentation?

Yes — PlantUML component diagrams are ideal for microservices documentation. Map each independently deployable service to one component, use packages to group services by domain, and label arrows with protocols (REST, gRPC, AMQP). For event-driven architectures, use a queue element for the event bus between producers and consumers.

How do component diagrams in PlantUML relate to the C4 model?

At the C4 model’s C3 level, component diagrams map directly to individual container internals — showing the modules inside a single container. Use the C4-PlantUML open-source library on GitHub for official C4 macro support with consistent styling. The library provides Component(), Container_Boundary(), and Rel() macros that match the formal C4 notation.

How do I style a PlantUML component or architecture diagram?

Add !theme THEME_NAME after @startuml for a quick visual preset — try cerulean, materia, or plain. For precise styling, use skinparam ComponentBackgroundColor, skinparam ComponentBorderColor, and skinparam ArrowColor. See our PlantUML cheat sheet for the full skinparam reference with example values.

What is the best PlantUML component diagram example to start with?

Start with the three-layer example: package "Frontend" { [Web App] }, package "Backend" { [API] [Service] }, package "Data" { database "DB" }, then connect with arrows. This pattern covers 90% of real-world cases. Paste it into our free PlantUML generator to render and export instantly.

J
Joshua

SEO strategist and founder of AI Tool Synergy. Focused on building topical authority through data-driven content and free tools that actually work. Explore all free tools at aitoolsynergy.com/free-tools-online — no signup ever required.