haechandev
Engineering

From full Firebase reads to syncing only what changed

How repeated read costs led me to introduce content versions and fetch only changed crop information.

August 23, 2026

Dajoa had to be built quickly. Rather than set up a large server architecture, I started with Flutter and Firebase. Administrators added crop information, pest and disease content, and YouTube videos, and the app displayed them immediately. It was a sensible initial choice: we could ship operating tools quickly without managing separate infrastructure.

The problem came from leaving that first structure unchanged.

Initially, opening the app fetched everything

With only a small number of crops, I began by downloading the entire list on every launch. The implementation was simple: fetch the list and display it locally.

During development, repeated hot reloads triggered the same reads. Database usage grew even before there were many users. After launch, each user opening the app could repeat a full read.

The issue was more than data volume. Editing one crop description made the app fetch every unchanged crop again. Serverless infrastructure still needs cost awareness.

Comparing timestamps was only the first improvement

My first approach compared the last download time with the administrator’s update time. Without an update, use the local data; otherwise fetch again.

This reduced full downloads on every launch, but editing one crop still required retrieving the whole list. We knew that something changed, without knowing what changed.

Introduce a content version

I added a content synchronization version separate from the app release version. Every crop or pest-content change increments the global version, and changed records retain that version.

Current content version: 14
App’s last synchronized version: 10

Fetch only records with syncVersion 11 through 14.

The app first checks the current version. If it matches the local version, it downloads nothing. Otherwise, it queries the changed crops and advances the local version only after applying the changes.

This does not send a separate request for every crop. One query filters by change version. If three of one hundred records changed, only those three are downloaded. If all changed, it is effectively a full read. This suits content services where most records stay unchanged.

Reduce reads and make data state explicit

Versioned synchronization also tells us which state the app has. If the network disconnects partway through, keep the old sync version and fetch the same changes next time.

Deletions need their own treatment. Simply removing a document gives an older app no way to know it disappeared. In a production design, deletion events should also be versioned, or tombstones should be sent for local cleanup.

A simple first architecture is fine for shipping quickly. The lesson from Dajoa was to identify repeated calls early and move only changed data before usage grows.