Following a Change Through a System
Most applications pass data through several layers: a user interface, an API, business logic, and a database, often with other services in between. Following a change means tracing one piece of data across those layers to see where it is created, altered or lost.
The typical path
A request from a user often travels like this:
- The UI collects input and sends a request.
- The API receives it, validates it and checks who is calling.
- The backend logic applies the rules and may call other services.
- The database stores or returns the data.
- The response travels back, is transformed again and is rendered.
Each step can reshape the data: renaming fields, converting types, formatting dates, rounding numbers or dropping values. See Layered Architecture and HTTP Fundamentals.
Trace it, layer by layer
Choose one concrete example, such as a customer with id 42 whose address change does not show up, and check each boundary:
- In the browser, open the developer tools Network tab. What request was sent (URL, method, body)? What status and body came back?
- At the API, do the logs show the request arriving? Use a correlation or request id if one exists. An API testing tool lets you send the same request without the UI.
- In the backend, is the value still correct after validation and mapping? A debugger or temporary log line helps.
- In the database, query the row directly. Was it written? When was it last updated? See SQL Fundamentals.
- On the way back out, check whether the response, cache or UI state is showing stale data.
The first layer where the data is wrong is where to dig. If it is right on both sides of a boundary, the problem is elsewhere.
Things that hide changes
- Caches (browser, server, CDN) returning old data.
- Asynchronous work. Queues and background jobs mean the change happens later, after the request has finished.
- Different environments, with different databases or configuration.
- Transformations such as time zones, encodings and rounding; see Dates, Times and Time Zones.
When a request spans several services, distributed tracing tools can show the path automatically. See Monitoring Concepts.
Try it
Pick a simple feature that saves data (for example editing a profile name). With the browser developer tools open, make a change and inspect the request. Then find the matching log line and the stored row. Compare the value at the three points and see where it changes form.
Common mistakes
- Debugging the layer where the bug shows up instead of where the data first goes wrong.
- Forgetting that a cache or a background job can show old data or delay a change.
- Checking a different environment or database than the one the problem happened in.
Check yourself
- A customer's address change does not show up. Which five places would you check, in order?
- How do you know the problem is not at a boundary between two layers?
- Name three things that can make a saved change look missing.