This is a quick design note for how my MyNextHome app will handle two things:
- Pulling open home listings from Trade Me New Zealand (via my own backend).
- Saving my own visiting notes locally on the phone, then syncing them to my server when I’m online.
Nothing here is final — it’s just the first clean version so I can keep building without keeping everything in my head.
1. The Three Tables (Minimal but Enough)
1) users
Very basic — just enough so the server knows who owns which notes.
Fields
-
id– primary key -
email– optional -
name– optional -
created_at,updated_at
I’ll worry about real login/auth later. For now this just lets the server store notes properly.
2) properties
Every time the app pulls a listing from Trade Me and I interact with it (e.g. I save notes), it becomes a “property” in my system.
Fields
-
id– my internal property ID -
source–"trademe" -
source_listing_id– Trade Me’sListingId title-
location(suburb/city) -
bedrooms,bathrooms thumbnail_url-
raw_payload(the whole Trade Me JSON — optional but handy) - timestamps
Basically: a simplified snapshot of the listing, enough for the app UI and for attaching notes.
3) visit_notes
This is the star of the project. This is the stuff I own: my comments, impressions, ratings.
Fields
-
id– server-side ID user_idproperty_id-
client_local_id– generated by the app (important for syncing) note_textrating-
tags– JSON list like["sunny", "quiet street"] -
photos– probably URLs later -
is_deleted– soft delete - timestamps
Sync uses updated_at for conflict resolution (simple last-write-wins for now).
2. Data Flow: How Listings Move Through the System
A) Trade Me → My Backend → Mobile App
This part is basically me “curating” Trade Me’s raw data into something my app can use.
Step 1: My backend calls Trade Me
- It asks for open homes, e.g. next weekend.
- It loops through the results and upserts into the
propertiestable. - I can cache these for a few minutes or an hour so the app loads fast.
Step 2: Mobile app calls my API
A super clean endpoint like:
GET /open-homes
The backend returns a list of properties shaped exactly how my React Native screens want them:
- internal
propertyId - Trade Me listing ID
- title
- location
- bedrooms
- thumbnail
- open-home times
Step 3: App shows the list
When I tap into a property, the app stores the property locally (just the fields it needs for offline mode + linking notes).
That’s basically it.
3. Data Flow: My Notes → My Backend
This is the part that makes the app actually mine — not just a read-only viewer.
A) Local-first note writing
When I write a note:
- The app creates/updates a local note record
- It gives it a
localId(UUID) - Marks it as
isDirty = true - Saves it immediately (offline-friendly)
So I can write notes even in the elevator, at an open home with bad reception, or on a walk.
B) Syncing up to my server
Whenever:
- I come back online,
- or I open the app,
- or I hit a “Sync” button,
the app grabs all the dirty notes and sends them to:
POST /sync/visit-notes
The request includes:
clientLocalId- optional
serverId - the property details (either my own
propertyIdor Trade Me’s ID) - the note text, rating, tags, updatedAt timestamp, etc.
Backend behaviour
- If the note doesn’t exist → create it
- If it does exist → update it (compare timestamps)
- Return the server IDs back to the app
App behaviour
- Writes back the new
serverId - Clears
isDirty - Updates local timestamps
Done.
C) Optional: Sync down (for multi-device later)
If I ever want to use the app on two devices, the app can call:
GET /sync/visit-notes?since=2025-11-20T00:00:00Z
And the backend returns whatever changed after that.
App merges it.
Pretty simple.
4. Why This Setup Works
- My server protects my Trade Me keys
- Caching makes listing loading fast
- Local DB makes note-taking instant and offline-safe
- Sync is simple enough for v1 but expandable later
- The property table lets notes stay attached even if Trade Me hides/archives the listing
Top comments (0)