- 1Class Diagram in UML | Beginner-Friendly Guide with Examples
- 2Object Diagram in UML | Simple, Visual Examples for Beginners
- 3Component Diagram in UML | Beginner-Friendly Tutorial with Java Examples
- 4Deployment Diagram in UML | Beginner’s Guide with Examples and Java Use Cases
- 5Package Diagram in UML | Java-Focused Tutorial with Real Examples
- 6Composite Structure Diagram in UML | Java Examples & Complete Guide for Beginners


- 1Class Diagram in UML | Beginner-Friendly Guide with Examples
- 2Object Diagram in UML | Simple, Visual Examples for Beginners
- 3Component Diagram in UML | Beginner-Friendly Tutorial with Java Examples
- 4Deployment Diagram in UML | Beginner’s Guide with Examples and Java Use Cases
- 5Package Diagram in UML | Java-Focused Tutorial with Real Examples
- 6Composite Structure Diagram in UML | Java Examples & Complete Guide for Beginners

- 1Use Case Diagram in UML | Beginner's Guide with Java and Real-World Examples
- 2Activity Diagram in UML | Java-Centric Beginner's Guide with Real Examples
- 3Sequence Diagram in UML | Step-by-Step Java Guide with Real-World Examples
- 4UML Communication Diagram | Java-Based Tutorial with Real-Life Examples
- 5UML State Machine Diagram | Java-Centric Tutorial with Real Examples
- 6UML Interaction Overview Diagram | Java Tutorial with School-Based Examples
- 7UML Timing Diagram | Java Tutorial with Real-World Timing Examples

- 1UML Relationships in Java: Association, Aggregation, Composition Explained with Examples
- 2UML Inheritance and Generalization | Java Examples for Beginners
- 3Interfaces vs Abstract Classes in UML with Java Examples
- 4Multiplicity and Navigability in UML – Easy Guide with Real-Life Examples
- 5Constraints and Notes in UML – Beginner-Friendly Guide with Java Examples

- 1UML in Software Development Lifecycle (SDLC) – Complete Guide with Examples
- 2How to Create UML Diagrams from Requirements – Step-by-Step with Examples
- 3UML and Agile: A Practical Guide for Beginners
- 4Case Study: UML for an E-commerce Application – Step-by-Step UML Design
- 5UML Best Practices and Common Mistakes – A Beginner’s Guide with Examples


- 1Quiz: UML Concepts – Test Your Understanding of UML Diagrams and Principles
- 2Practical Assignment: UML Modeling – Step-by-Step UML Design Task for Java Beginners
- 3UML Review and Feedback – How to Evaluate and Improve UML Models in Java Projects
- 4UML Certificate of Completion – How to Earn and Use Your Certification
Composite Structure Diagram in UML
Next Topic ⮕Use Case Diagram in UML | Beginner's Guide with Java and Real-World Examples
Introduction
Software systems are rarely just a flat set of objects. They’re made up of components that contain other components — all collaborating to deliver functionality. In UML, a Composite Structure Diagram helps us visualize the internal structure of a class or component by showing how its parts connect and interact.
This diagram is ideal for modeling complex systems where you want to go beyond the high-level class structure and examine the architecture within individual components. In this tutorial, we’ll explore Composite Structure Diagrams using a real-world example of a school system built in Java.
What is a Composite Structure Diagram?
A Composite Structure Diagram shows the internal configuration of a classifier (like a class or component) and the interactions between its parts through connectors and ports. Think of it as an exploded view of a system’s internals.
It’s like opening a machine to see its gears and how they’re connected — not just what the machine does, but how it does it internally.

Why Use Composite Structure Diagrams?
- Model internal architectures: Show how parts of a class or component are wired
- Design reusable components: Define clear internal structure and communication
- Clarify complex interactions: Particularly helpful in embedded or service-based systems
- Bridge between class and deployment diagrams: Offers medium-level detail
Key Elements of Composite Structure Diagrams
1. Classifier (Class/Component)
The main element whose internal structure is being modeled — like ResultService
.
2. Part
An instance of a property of the classifier. For example, a ResultService
might have parts like StudentRepository
and MarkCalculator
.
3. Port
A port is an interaction point where the classifier exposes services or communicates with other components.
4. Connector
A line between parts or ports showing how they interact internally. Can be typed (representing specific interfaces) or untyped.

Example: School System - Result Generator
Scenario
Imagine you’re building a Java class called ResultService
. It has two main responsibilities:
- Fetching student records using a
StudentRepository
- Calculating marks via a
MarkCalculator
Java Code Snapshot
public class ResultService {
private StudentRepository studentRepo;
private MarkCalculator calculator;
public Result generateResult(int studentId) {
Student student = studentRepo.findById(studentId);
return calculator.calculate(student);
}
}
This class is composed of two parts: studentRepo
and calculator
. Let’s visualize this in a Composite Structure Diagram.
Composite Structure Representation
- Classifier:
ResultService
- Parts:
studentRepo : StudentRepository
,calculator : MarkCalculator
- Port:
resultPort
for exposing result generation functionality - Connectors: Link
ResultService
to its internal parts

Step-by-Step: How to Draw a Composite Structure Diagram
Step 1: Choose the Classifier
Decide what component or class you want to open up — this is your “main block.”
Step 2: Identify Internal Parts
Look at attributes and inner components that support the main logic.
Step 3: Define Ports
If your classifier exposes specific services or needs to receive input, define ports at the edges of the block.
Step 4: Add Connectors
Draw lines to show how parts are connected. Label if needed with interfaces or types.
Step 5: Organize Layout
Use nested rectangles or separate blocks. Keep the diagram clean and modular.
Another Example: Teacher Dashboard
Let’s say a TeacherDashboard
component in a school system internally uses:
ScheduleManager
: to manage class schedulesGradeUploader
: to upload student marks
Composite Diagram View
We’ll show:
- Ports for dashboard services
- Parts for its internal collaborators
- Connectors between the dashboard and its parts

Best Practices
- Use for medium-level detail: Don’t try to show every class or every method
- Be selective with ports: Only show those relevant for external/internal interactions
- Name clearly: Use intuitive labels for parts and ports
- Use notes where needed: Clarify complex connections or design decisions
Common Use Cases
- Modeling software components: Like Java beans, microservices, or UI widgets
- Embedded systems design: Showing internals of hardware modules or control loops
- Collaborative systems: Describing how agents, services, or controllers interact
Tools to Draw Composite Structure Diagrams
- StarUML: Full support for ports, parts, connectors
- Visual Paradigm: Great for enterprise modeling
- PlantUML: Partial support via component notation
- Lucidchart: Ideal for easy-to-read modular diagrams
PlantUML Workaround Example
@startuml
component "ResultService" {
[StudentRepository] --> [ResultService]
[MarkCalculator] --> [ResultService]
}
@enduml

Conclusion
Composite Structure Diagrams help bridge the gap between structural and behavioral views in software design. They are invaluable for modeling how components are built internally and how they collaborate through ports and connectors. Especially in modular Java applications or service-based designs, this diagram brings clarity to complex internals without overwhelming the viewer with low-level class detail.
Start with a familiar class — perhaps one you’ve written in Java — and draw its internal architecture. You’ll see your code from a new and insightful perspective.
Next up in this UML series, we’ll move into Use Case Diagrams — focusing on what your system offers to its users from the outside-in.
QUIZ
Question 1:What is the primary purpose of a Composite Structure Diagram in UML?
Question 2:In a Composite Structure Diagram, ports are used to represent interaction points with the environment or other parts.
Question 3:Which of the following are core elements in a Composite Structure Diagram?
Question 4:Which UML concept best describes a 'Part' in a Composite Structure Diagram?
Question 5:Connectors can only link external interfaces in a Composite Structure Diagram.
Question 6:Which of the following are valid use cases of Composite Structure Diagrams?
Question 7:In UML, what does a port typically indicate?
Question 8:A Composite Structure Diagram can contain nested parts within parts.
Question 9:In a Composite Structure Diagram, what do connectors typically represent?
Question 10:Consider this snippet for a school software system:
class School {
Classroom class1;
Classroom class2;
}
Which UML concept does this best relate to in a Composite Structure Diagram?
class School {
Classroom class1;
Classroom class2;
}