The UML Composite Structure Diagram is a powerful structural diagram used to explore the internal architecture of a structured classifier, such as a class, component, or system. It focuses on how an entity is composed of interconnected Parts and how it interacts with the outside world through its Ports.

This diagram is essential for defining the black-box and white-box views of a system component, ensuring clear boundaries, and enabling component reusability.
Core Structure and Context
The diagram is drawn within the context of a Classifier (the boundary box), which defines the overall system or component being analyzed.
A. Classifier Role (Boundary)
- Notation: A large rectangular box.
- Purpose: Represents the overall class, component, or system whose internal structure is being defined. All other elements in the diagram are contained within this boundary.
Fundamental Elements of the Internal View
The internal structure is defined by three key elements: Parts, Ports, and Connectors.
B. Parts
A Part represents a role played by an instance of a classifier (like a class or component) within the overall composite structure. Essentially, a Part is an internal building block.
- Notation: A rectangular box inside the boundary, labeled with its name and type.
- Syntax:
partName: PartType(e.g.,dataCache: CachingModule). - Key Distinction: A Part is not the object itself, but the role that object plays within the context of the containing classifier. A Part can itself be a composite structure, allowing for deep nesting.
C. Ports
A Port is a distinct interaction point between the composite structure (the boundary) and its environment, or between its internal Parts. Ports formalize the interfaces the component uses or provides.
- Notation: A small square attached to the boundary edge or the edge of an internal Part.
- Types of Ports:
- Public Port: Attached to the outer boundary; exposed to the environment.
- Encapsulated Port: Attached to an internal Part; only connects that Part to other internal Parts or the system boundary.
- Purpose: Ports explicitly define the required and provided interfaces, allowing the internal structure to be hidden (black-box view) while still defining its contractual interaction points.
D. Connectors
A Connector models the communication link or flow of information/signals between two elements (either two Ports, two Parts, or a Port and a Part).
- Notation: A line connecting the two linked elements.
- Purpose: Represents the implementation of the communication link, showing how data or messages are transferred internally.
Modeling Interfaces: Provided and Required
Interfaces define the contractual obligations of the Ports and are crucial for architectural clarity.
A. Provided Interface (Lollipop Notation)
- Notation: A circle (or “lollipop”) connected to a Port.
- Purpose: Shows the services or operations that the classifier (or Part) offers to its environment or internal components.
B. Required Interface (Socket Notation)
- Notation: A semi-circle (or “socket”) connected to a Port.
- Purpose: Shows the services or operations that the classifier (or Part) needs from its environment or other internal components to function correctly.
Assembly Connector: A connector line often links a Required Interface (Socket) of one Part to the Provided Interface (Lollipop) of another Part, illustrating how internal components are wired together to fulfill the system’s function.
Modeling Collaboration: Roles and Collaborations
Composite Structure Diagrams can also model dynamic Collaborations—specific sets of roles and connections that work together to perform a task.
A. Collaboration Use
- Notation: A dashed ellipse containing the names of the collaborating roles.
- Purpose: Represents an instance of a collaboration pattern (e.g., a specific Observer pattern implementation) being used within the larger component.
Step-by-Step Modeling Example: A Smart Home Controller
Let’s model the internal structure of a HomeAutomationSystem component.
- Classifier Boundary: Define the outer box as
HomeAutomationSystem. - External Ports: Add a Port labeled
apiPortto the boundary. Attach a Provided Interface (Lollipop) forICommandReceiver(what the outside world can send) and a Required Interface (Socket) forIExternalWeatherService(what the system needs). - Internal Parts:
scheduler: TaskScheduler(Handles timed events).deviceManager: DeviceCoordinator(Communicates with hardware).
- Internal Connections:
- Connect the
apiPortto thedeviceManagerPart using a Connector. - Connect the
schedulerPart’s output Port to thedeviceManagerPart’s input Port, showing that the scheduler tells the device manager when to act.
- Connect the
- Nested Structure (Optional): Show that the
deviceManageritself contains Parts likezigbeeAdapterandwifiAdapter.
This diagram clearly shows that the HomeAutomationSystem is composed of two major internal parts, uses a specific API, and requires an external weather service to function.
Summary
The UML Composite Structure Diagram moves beyond the black-box view of a class or component to reveal its white-box architecture. By using Parts to define roles, Ports to define interaction points, and Connectors to define internal communication, it allows architects and developers to precisely understand and design complex, reusable, and clearly encapsulated components.
