how-to · 7 min read
Documenting a payments integration
Imagine a small team adding card payments to an existing checkout. The integration touches an external provider, a new webhook endpoint, a database table for payment attempts and a few internal classes that decide what to retry. One diagram cannot explain all of that to a new engineer, a reviewer and an on-call operator at the same time.
A better approach is a small set of diagrams, each answering one question and owned by one person. The tools below cover the views that usually matter: a source-first overview, the data contract, the request and failure paths, the code shape and the deployment topology. The point is not diagram completeness; it is that each view stays current enough to be trusted.
One integration, several questions, several diagrams
Before opening a tool, write down the questions the documentation has to answer. A payments integration commonly raises five: what are the moving parts, what data is stored, what happens on a successful request, what happens when the provider declines or times out, and where the services actually run. Those questions do not share the same audience or the same rate of change.
Assign one owner to the whole diagram set and one reviewer per view. The owner keeps the index and the review dates; the reviewer is usually the person who owns the code or the runbook behind that view. This keeps the diagrams from becoming anonymous artifacts that nobody updates when a table or endpoint changes.
Source-first overviews in the Mermaid editor
The Mermaid editor is the quickest way to get a source-first picture: paste a flowchart, sequence, class, ER, state, gantt, pie or mindmap template, edit the text, and the preview re-renders live. Sources are capped at 200 KB, rendering waits for a short typing pause, and syntax errors show Mermaid's own message so a broken diagram is obvious rather than silently blank. The rendered image exports as SVG or PNG, and the source downloads as an editable .mmd file.
The portability is the point: a .mmd file can live in the repository next to the integration code and is readable in a review. The limit is equally important: this is a drawing tool, not an architecture model. It does not know which services exist, cannot synchronize with code, and will happily render a diagram that describes an API that was removed. Treat the overview as a map drawn by a person, not as generated truth.
The data contract: an ER diagram for schema and cardinality
The ER diagram maker keeps the data conversation concrete. Each entity gets attribute rows with a name, a type and a key marker for primary or foreign keys, and relationships use one-to-one, one-to-many or many-to-many cardinality. The generated Mermaid source shows the matching symbols, and validation reports duplicate entity or attribute names, invalid identifiers, missing labels and unknown relationship endpoints before anything renders.
Use it to agree on the payment attempt record, the link to the customer and the relationship to the order, not to reproduce every column. The editor is capped at 30 entities and 100 relationships, and it is not a migration tool: it does not validate referential integrity, store data types to the database's precision or generate SQL. The diagram records the contract the team agreed on; the migration remains code and must be reviewed as code.
The request path: sequence diagrams for success and failure
The sequence diagram maker models participants and actors, three message types, optional notes and Mermaid's autonumber directive. Solid arrows represent requests, dashed arrows responses and async messages cover events such as a webhook acknowledgment. A happy-path diagram with a note on idempotency and a separate failure-path diagram for a declined card or a provider timeout are far more useful than one crowded diagram that tries to show both.
The tool is capped at 50 participants and 100 messages, and it deliberately does not model activation bars, alt/loop fragments or other advanced sequence syntax. That constraint pushes the author toward separate diagrams for separate cases, which is easier to review. Remember that a sequence diagram is not an executable protocol model: timing, concurrency and retry semantics are described by the labels and notes, not validated by the tool.
The code shape: a small UML class view
The UML class diagram maker shows classes with attributes and methods, plus inheritance, association, composition, aggregation and dependency arrows. Two templates cover a library and a payment example, validation catches duplicate class names, duplicate relationships and missing endpoints, and the generated Mermaid classDiagram source can be downloaded as .mmd or exported as SVG or PNG.
Keep this view small and focused on the classes and interfaces a newcomer has to understand, such as a payment service, a provider client and a retry policy. It is not runtime truth: the diagram describes intended structure, not what the framework instantiates or what the service mesh actually calls. Avoid duplicating the ER diagram here; the database schema belongs to the ER view, while the class view is about code responsibilities and boundaries.
The deployment view: network diagrams as documentation
The network diagram maker maps a deployment topology: the browser or checkout service, the API server, the payment worker, the database and the external provider boundary, with routers, switches, firewalls, servers, cloud, PC and Wi-Fi device types. Links can be solid or dashed and carry labels, the whole topology sits under a named subgraph, and validation flags unknown devices, self-links and duplicate names.
It is a static documentation diagram. It does not scan, discover or monitor a network, and the devices you draw are the only source of truth. Device shapes are schematic, not vendor icons, and the editor is limited to 50 devices. That is a good match for a diagram kept in a design document, as long as it is labeled with the environment and the date and stripped of internal hostnames, addresses and secrets before it is shared.
Ownership, freshness and a review loop
A diagram set needs the same care as the code it describes. Keep a short index that lists each diagram, the question it answers, its owner, the last review date and the commit or document it was checked against. Put the .mmd files and saved JSON projects in the repository so they can be diffed in pull requests instead of living only in someone's browser.
Define update triggers: a schema change updates the ER view, a new message or failure mode updates the sequence diagrams, a new service or environment updates the deployment diagram, and a change in class responsibilities updates the UML view. Sanitize before sharing: replace API keys, tokens, card data, customer identifiers and internal addresses with placeholders, and review every export, because notes and labels are just as visible as boxes.
A practical review loop is short. The author draws the view from the current code and API contract, a reviewer compares it with the diff and the provider documentation, and any known gap is written down as a caveat rather than hidden. Record the review date, export a PDF or SVG for the architecture document, and keep the editable source next to the code so the next change starts from something current.

