In Part 1, I explained how I built Thryvo Cal so every part can be tested on its own. In Part 2, I covered what happens when the signal drops. This last part steps back and asks a different question: how did the first phase make the second one possible?
Phase 1: A foundation you can trust
The first version of the app was simple. It fetched food data from the server and showed it. The goal wasn’t features, it was structure:
- Parts receive their tools from outside, so tests can swap in practice versions and never need the internet.
- Each layer relies on a simple agreement, not on one specific provider.
- Heavy data conversion runs in the background, so the screen isn’t tied up while data is processed.
- Failures are recorded and passed along, never swallowed.
None of this added a feature users could see. It added confidence for me.
Phase 2: Stop depending on the signal
As the app moved toward production, relying only on the server became a weakness. A dropped connection meant a broken experience, so the app grew in four ways:
- A copy of the data lives on the phone, so people can view and log food offline.
- The app checks for a connection before asking the server, and carries on with local data when there isn’t one.
- The two copies are reconciled automatically. If the server has more, the phone catches up. If the phone has more, the server catches up.
- Each item records when it last changed, to support more reliable syncing.
How the food list loads now
food list loading · 2 decisions, 4 outcomes
With no connection, the app skips the server. With one, it compares both copies and fills in whatever is missing on either side. Either way, the screen reads from the phone.
Before and after
| Aspect | Phase 1 | Phase 2 |
|---|---|---|
| Where data lives | Server only | Server and phone |
| Without internet | Doesn't work | Works fully |
| When the connection drops | Handled after the error happens | Checked before the request |
| Two copies disagree | Not applicable | Reconciled automatically |
| Heavy data conversion | In the background for server data | In the background for both sources |
Why the second phase was affordable
Adding a local database to an app can mean rewriting half of it. Here, it didn’t, and the reason traces back to Phase 1.
Because every data source already followed the same agreement, the phone’s database slotted in beside the server as just another source. The screens and the logic behind them didn’t need to know. The background processing and the habit of recording failures carried over as well.
That’s the real lesson of the series: boundaries and testability look like extra effort early on, and then they make the big changes cheap.
What still needs work
The current reconciliation compares how many items each side has. That catches missing entries well, but it isn’t a full answer to edited items or conflicting changes. The “last updated” timestamp is in place to help with that, and it’s the next thing I want to build on.
What I’d keep from this whole journey
- Build the foundation before you need it. I didn’t know offline support was coming, but I knew change was.
- Make every decision testable. If you can’t test a piece in isolation, you can’t change it with confidence.
- Write down the why, and the limits. The decision records are why I could write this series at all.
If you’ve been following along, thank you. Which decision in your own projects paid off the most later?
#SoftwareArchitecture #OfflineFirst #Testing #Flutter #AppDevelopment #EngineeringDecisions