Skip to content

How I map complex backends

How I understand complex backends by identifying system boundaries, making inputs and outputs explicit, and diagramming the data journey.

When backend behavior spans several systems, I start by mapping the data journey. I look for cohesive boundaries, identify their inputs and outputs, and trace how they connect.

I treat a backend as a system of systems and write down the connections as I find them. A diagram gives me a record I can check against the code and extend as I learn more about the behavior.

Identify the inputs and outputs

When I’m reading a piece of the backend, I try to understand it as a black box: what goes in, what happens at its boundary, and what comes out? Those outputs include side effects. Writing to a database or putting work on a queue matters just as much to this model as a return value.

For example, say an API request creates a database row and queues a job. The job performs a scan, then saves the scan results by updating the row the API created. Another API reads that row, combines it with a second data model, and returns the data.

I can describe each piece in terms of its inputs and outputs. The first API takes a request and produces a row and queued work. The job takes that work, performs the scan, and updates the row with the results. The read API takes a request, reads two models, and produces a response.

Trace the data journey

But understanding those pieces individually only gets me part of the way there. I also need to understand the data journey: how the row starts out, how the job changes it, and how those results reach the later API response. That’s where the system diagram becomes useful.

The Create API creates a database row and enqueues work. The job scans and updates the row with results. The Read API reads that row and a second data model to produce a response.

Mermaid source
flowchart TD
    create[Create API] -->|Creates| row[Database row]
    create -->|Enqueues work| queue[Job queue]
    queue -->|Supplies work| job[Job]
    job -->|Performs| scan[Scan]
    scan -->|Results| job
    job -->|Updates with scan results| row
    row -->|Read by| read[Read API]
    other[Second data model] -->|Read by| read
    read --> response[API response]

As I read through the system, I add each piece of behavior to my notes or diagram. That lets me check how the function in front of me fits into the larger sequence without repeatedly reconstructing the whole journey.

Understand the surrounding systems

Then there’s all the surrounding machinery. An auth system determines who can call those APIs and what data they can read. An auditing system might be watching changes through behavior that isn’t obvious in the endpoint. Instrumentation collects monitoring data and metrics. Logging gives me another part of the system to understand.

I also need to understand the data models and how the ORM reads and writes them. Depending on the work, scaling concerns can matter too. A feature that changes when a job runs may require understanding both its data access and the load it creates.

If auth determines whether the read can happen, or auditing reacts to the database update, I add that to the diagram too.

How far to open each black box depends on the change. I start with its inputs, outputs, and side effects, then go deeper where the behavior I’m changing depends on its internals. That takes judgment, especially when the boundaries are unfamiliar.

End of this series

Making sense of backends