Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

UML: package, component and deployment diagrams

UML package, component and deployment diagrams show how a system is organised into modules (packages), how those modules provide and require interfaces (components), and how software artifacts run on hardware (deployment).

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers use these UML diagrams when they design, review and deploy software systems. Package diagrams help organise large code bases; component diagrams show how parts of the system depend on each other and expose interfaces; deployment diagrams show where software artifacts run on hardware and how nodes communicate. Clear diagrams reduce integration problems and make deployment planning and testing easier.

Key ideas

Start from basic definitions before using terms.

  • UML: the Unified Modeling Language; a standardized visual language to describe software structure and behaviour (used here only as the notation system).
  • Package: a named grouping of related model elements (classes, components, other packages). A package is used to organise a large model into smaller units. Draw a package as a rectangle with a small tab (folder icon) or simply a rectangle labelled with the package name. The exact UML stereotype text is optional but common: <<package>> followed by the name.
  • Component: a modular, replaceable, deployable part of a system that encapsulates its contents and exposes two things: interfaces it provides and interfaces it requires. Draw a component as a rectangle with the component icon (a small rectangle with two smaller rectangles on its left) in the upper-right corner, or use the standalone component symbol. Label with its name and optional stereotype <<component>>.
  • Interface: a named set of operations (methods / services) that a component offers or needs. Represent a provided interface with a lollipop symbol (a small circle attached by a short line to the component). Represent a required interface as a socket (a semicircle or a cup) or as a dependency arrow to an interface.
  • Artifact: a physical file or product created by the build process (for example a .jar, .war, executable, or database file). In deployment diagrams, draw an artifact as a rectangle with the stereotype <<artifact>> and the artifact name. An artifact may manifest a component; show this with a dashed dependency labeled <<manifest>> from the artifact to the component.
  • Node: a physical computational resource (hardware or a virtual machine, e.g., server, mobile device). Draw a node as a 3D box (a cube) or a rectangular box labelled with <<node>> and its name.
  • Deployment: the relationship that places an artifact on a node (artifact deployed_on node). Represent with a dependency labelled «deploy» or by drawing the artifact inside the node box (common exam drawing).
  • Assembly connector: a connector between a provided interface (lollipop) of one component and the required interface (socket) of another. Draw a solid line connecting the lollipop to the socket; label with the interface name where needed.
  • Dependency: a directed relationship showing that one element (client) depends on another (supplier). Draw as a dashed line with an open arrowhead from the client to the supplier.

Exact statements universities expect (definitions written as exam answers):

  • Definition: "A package is a UML element used to group related model elements to manage large models. Packages may contain other packages and define visibility of their contents to other packages."

  • Definition: "A component is a modular part of a system that encapsulates implementation and exposes behaviour through interfaces. Components are replaceable units that can be independently deployed."

  • Definition: "A deployment diagram models the physical deployment of artifacts on nodes and the communication paths between those nodes."

Assumptions behind models and when they apply:

  • Assume a model abstracts details not necessary for the task (e.g., internal class design is omitted in a component diagram unless important for the interfaces).
  • Use package diagrams when organizing code, showing dependencies and visibility across subsystems.
  • Use component diagrams when showing replaceable parts, third-party libraries, microservices and their interfaces.
  • Use deployment diagrams when planning hardware & VM allocation, network communication and artifact placement.

Diagrams you may be asked to draw (describe exactly what to draw and label):

  • Package diagram to show three packages: UI, BusinessLogic, DataAccess. Draw three rectangles with small tabs in the top-left corner. Label them UI, BusinessLogic, DataAccess. Draw a dependency dashed arrow from UI to BusinessLogic and from BusinessLogic to DataAccess. Optionally show Common package that both UI and BusinessLogic import; draw a dashed dependency arrow labeled <<import>> (package import) from UI & BusinessLogic to Common.

  • Component diagram to show a WebApp component and AuthService component. Draw two component rectangles, each labelled and with <<component>>. Attach a lollipop to AuthService labelled AuthAPI. On WebApp draw a socket (or a dependency arrow) labelled AuthAPI pointing to the AuthService lollipop. Connect WebApp to a Database component with a dependency arrow. Label provided and required interfaces clearly.

  • Deployment diagram for the system above: draw three nodes as boxes: WebServer (node), AppServer (node), DBServer (node). Inside WebServer draw artifact <<artifact>> webapp.war. Inside DBServer draw artifact <<artifact>> customer.db. Draw communication lines (solid) between WebServer and AppServer, and between AppServer and DBServer. Where necessary, show multiplicity (e.g., 3 x WebServer instances) by writing WebServer [3] or by drawing three node boxes.

Formulas

For this topic, list the UML syntax and not formulas. Write each syntax on its own line in backticks and short meaning:

  • <<package>> PackageName — package declaration; draw as rectangle with tab.
  • <<component>> ComponentName — component declaration; draw as component rectangle.
  • lollipop: InterfaceName — provided interface (draw a small circle connected to the component).
  • required socket: InterfaceName — required interface (draw semicircle or dependency arrow to interface).
  • <<artifact>> artifactName — artifact placed on a node.
  • <<node>> NodeName — node (hardware or VM) in deployment diagram.
  • client - - -▸ supplier (dashed arrow) — dependency.
  • componentA — componentB (solid line) with lollipop-to-socket — assembly connector.
  • artifact deployed_on node — deployment relationship (often drawn by placing artifact inside node).

Worked examples

Example 1 — Package diagram for a small e-commerce system (exam-style)

Question: Draw and explain a package diagram that organises an e-commerce system into UI, Orders, Catalog, Payments and Common. Show dependencies.

Model answer (step-by-step):

  1. Draw five rectangles with tabs and label each: UI, Orders, Catalog, Payments, Common.
  2. Show that UI depends on Orders, Catalog and Payments: draw dashed arrows from UI to each of those packages. Dashed arrow head points toward supplier (Orders/Catalog/Payments).
  3. Show that Orders uses classes from Catalog: draw a dashed arrow Orders -> Catalog.
  4. Place Common as a shared package and draw dashed arrows from UI, Orders, Catalog, and Payments to Common (shared utilities). Optionally annotate visibility if Common exposes only some classes.
  5. Final note: include <<package>> stereotypes if asked. State assumptions: this package-level diagram omits internal class relationships and shows only high-level dependencies.

Marks: 1–2 for correct boxes and labels, 2–3 for correct dependency arrows and explanations.

Example 2 — Component + Deployment for a web application (exam-style)

Question: Draw a component diagram showing WebUI and AuthService components with interfaces; then draw a deployment diagram showing a LoadBalancer, two WebServer nodes, an AppServer node and a DBServer node. Show artifacts and connections.

Model answer (step-by-step):

  1. Component diagram:
    • Draw two components: WebUI <<component>> and AuthService <<component>>.
    • On AuthService draw a lollipop labelled AuthAPI (provided). On WebUI draw a socket labelled AuthAPI (required). Connect socket to lollipop with a short solid line (assembly connector).
    • Add UserDB <<component>> if needed and show dependency AuthService -> UserDB.
  2. Deployment diagram:
    • Draw LoadBalancer <<node>> at top. Draw two boxes labelled WebServer <<node>> below it; write [2] or draw two separate nodes to indicate two instances.
    • Draw one AppServer <<node>> and one DBServer <<node>>.
    • Inside each WebServer place artifact <<artifact>> webapp.war. Inside AppServer place <<artifact>> auth-service.jar. Inside DBServer place <<artifact>> users.db.
    • Draw communication lines: LoadBalancer -> both WebServers; WebServers -> AppServer; AppServer -> DBServer. Label network protocols if required (HTTP, JDBC).
  3. Explain: show which artifacts deploy to which nodes; explain scaling (two web servers behind load balancer). If asked, show binding of components to artifacts: WebUI component implemented by webapp.war, AuthService implemented by auth-service.jar.

Final result: annotate that the arrow directions and correct symbols (lollipop/socket) are necessary for full marks.

Common mistakes

  • Putting artifacts outside nodes instead of showing them deployed_on nodes or placed inside the node box in the deployment diagram (examiners expect artifact inside node or labelled deploy relationship).
  • Reversing dependency arrow direction: remember arrow goes from the client (dependent) to the supplier.
  • Forgetting to map components to artifacts in deployment (how will component run? which artifact?), losing deployment traceability.
  • Not showing multiplicity for multiple node instances or mislabelling number of instances.
  • Using the component symbol inconsistently — be consistent in the diagram you pick (either compact rectangle with two small rectangles, or component symbol).

For your exam

Typical question types:

  • Definitions: define package, component, artifact, node, interface.
  • Short note: compare package vs component diagrams; what is deployment diagram and when to use it.
  • Draw diagrams: given a system description, draw package/component/deployment diagrams and label interfaces and artifacts.
  • Derivation/explain: explain how to map components to artifacts and artifacts to nodes; explain scaling and redundancy in deployment.
  • Small modelling task: show how to refactor packages or split a component into subcomponents.

What a full-marks answer includes:

  • Clear, correctly-labelled diagram with correct UML notation: <<package>>, <<component>>, lollipop/socket for interfaces, <<artifact>> inside <<node>>.
  • Correct directions on dependency arrows and assembly connectors.
  • A short textual explanation: assumptions (what is shown, what is omitted), mapping from components -> artifacts -> nodes, and any performance/scale notes for deployment.

Quick check

  1. What symbol denotes a provided interface in a component diagram?
  2. How do you show an artifact is deployed on a node in a deployment diagram?
  3. Name one reason to group classes into packages.

Answers: 1) A lollipop (small circle) attached to the component. 2) Place the <<artifact>> inside the <<node>> box or draw a deploy dependency from artifact to node. 3) To manage complexity and organise related model elements (improve modularity and visibility control).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?