Describe classes, attributes, and inheritance. Get a Mermaid UML class diagram.
UML class diagram for geometric shapes: abstract Shape with area() method, subclasses Circle (radius: double), Rectangle (width, height), Triangle (base, height). Each overrides area().
Try it →Employee class hierarchy: Person (name, email, phone). Employee extends Person (employeeId, salary, hireDate). Manager extends Employee (directReports list). Contractor extends Person (contractEnd, hourlyRate). Show visibility markers and getters.
Try it →E-commerce domain model: Customer has many Orders. Order has many LineItems. LineItem references a Product with unitPrice and quantity. Product has category, sku, price. Show associations with cardinality and key methods.
Try it →Payment processing using strategy pattern: PaymentProcessor uses a PaymentStrategy interface. Concrete strategies: StripeStrategy, PayPalStrategy, CryptoStrategy. Each implements charge(amount) and refund(txId). Show interface implementation and composition.
Try it →User, Order, Payment, Invoice — the nouns of your business. A class diagram is where they live: fields, methods, relationships. Anyone joining the team gets the mental model in 30 seconds.
Domain-driven design lives on class diagrams. Aggregate roots, value objects, entities, and the exact relationships between them — the diagram is the DDD spec.
Before you publish v1.0, sketch the public API as a class diagram. Users grep the docs for the diagram to understand what's exported. Cleaner than tsdoc alone.
Extract this method, move that field, collapse these three classes into one. A before/after class diagram makes the refactor reviewable at a glance — hard to hide breaking changes.
Factory, Strategy, Observer, Visitor — every classic design pattern has a canonical class diagram shape. Reference these in your RFCs and readers recognize the pattern instantly.
A one-line prompt will give you a box for every noun you mentioned. What it guesses at is the arrows — inheritance or interface, composition or aggregation, all of which read the same in English prose. Chat mode asks about the one arrow that changes the design, draws the rest, and then lists every arrow it chose on your behalf. Here is the outbound notification service of a mid-sized SaaS, built from a deliberately vague opening line.
Five replies produced a class diagram where every arrow has a reason: ..|> for the channel contract, *-- for attempts that die with their notification, o-- for channels that outlive the dispatcher. A one-shot prompt picks an arrow for each of those too — it just never tells you which one it picked, and a wrong *-- reads as a lifecycle guarantee your code does not actually make.
Class diagrams are the standard vocabulary for talking about software structure. Reach for them when you need to communicate the shape of an object-oriented codebase: which types exist, what attributes and methods they have, and how they relate through inheritance, composition, and association.
Where they shine: onboarding docs ("here's how our domain model is organized"), design RFCs proposing a new class hierarchy or refactor, and technical interviews where you need to sketch out a design in the whiteboard. They're also the go-to for documenting design patterns — factory, strategy, observer, visitor all have a canonical class diagram shape that readers recognize instantly.
Mermaid's classDiagram supports the full UML notation you'd expect: visibility markers (`+` public, `-` private, `#` protected, `~` package), abstract classes and methods, interfaces via the `<<interface>>` stereotype, generic types, and every relationship (inheritance `<|--`, composition `*--`, aggregation `o--`, association `--`, dependency `..>`). It stops short of full UML — no swimlanes, no full activity semantics — which for most engineering docs is a feature, not a bug. If you need those, you're probably reaching for the wrong tool.
Not sure how to phrase your prompt? Chat mode lets AI ask 2-3 clarifying questions about actors, events, and edge cases — then draws.
Read our in-depth tutorials — symbols, structures, 9 rules, and copy-paste prompt templates for real-world flows.
Describe entities and relationships. Get a Mermaid ERD with keys and cardinality.
Turn an API description into a sequence diagram with actors and arrows.
Describe a state machine. Get a Mermaid state diagram with transitions.