When I started Koshly, my first thought was to build a server.
That’s how I always built apps. A Flutter app, an API, a database in the cloud and a login screen. You sign up once and your expenses are there on any phone you use.
But I didn’t build Koshly that way. There is no server for your data and no login. Everything is saved in a database on your phone. And the more I worked on it, the more I felt this was the better choice.
In this post I’ll explain why I went offline-first, and how I set it up so I can still add a sync server later without rewriting the app.
What offline-first gave us
No login, no sign-up, nothing. Think about the first time you open an expense app. You just paid ₹120 for chai and want to add it. If the app first asks you to create an account, there’s a good chance you close it. With Koshly you tap Get started and add it. No form, no email.
Your transactions stay on your phone. Koshly reads your bank SMS to add payments for you. That means your salary, your rent, and every UPI payment. People don’t want that on someone else’s server, and I don’t want to keep it either. If it never leaves the phone, there’s nothing to leak.
It works without internet. Every screen reads from the database on the phone, so there’s no loading spinner waiting for a server. On a flight, in a basement, with bad network, it works the same.
No login problems. No password reset, no email verification, no session expiring in the middle of adding an expense.
Deleting your data is just uninstalling. Apps with accounts need an account deletion page for the Play Store. Koshly has one too, and it says “There’s nothing to request”, because there is no account. Uninstall the app or clear its data and everything is gone. No email, no waiting.
No server to run for your data. No database in the cloud to pay for, back up or keep secure. The only server Koshly has is for an optional feature that sends redacted SMS reports to help improve detection, and it never gets your transactions.
Getting the database ready for sync
The Flutter docs explain an offline-first app as one that can offer most or all of its features without internet. The word that matters is first. I didn’t want to close the door on sync. Someday someone will want Koshly on two phones. So I made a few small choices from day one that cost almost nothing now and make adding a server easy later.
What we already have
1. Every row has its own ID. SQLite gives every row a number id. But id 5 on my phone and id 5 on your phone are two different transactions. So every table that holds your data also has a uuid:
| |
The number id is only used inside the phone. The uuid is what a server would use to know two rows are the same transaction. Even the default categories have fixed IDs, like cat-food-dining-v1, so “Food” is the same category on every phone.
2. Every change saves when it happened. Transactions, accounts, categories, budgets and friends all have an updatedAt, and every update writes it. If the same transaction is edited on two phones, this time decides which one wins. Budget limits go one step further: changing a limit adds a new version instead of overwriting the old one.
3. Money is stored as a whole number. Amounts are saved in paise as an int, not as a double. So two phones can never be off by a paisa because of decimal rounding.
4. Screens don’t care where data comes from. The screens never talk to the database directly. They go through a provider and a repository. They also listen to the database, so when anything changes in it, the screen updates by itself. Today the only things writing to the database are you and the SMS importer. Later, a sync would just be one more thing writing to it, and the screens wouldn’t need any change.
What we still have to do
It’s not all ready. Before I build sync, I need to add:
deletedAt(soft deletes). Right now deleting a transaction removes the row. For sync, the app has to remember it was deleted, so the other phone deletes it too. The row stays with adeletedAttime, and the app just hides it.- A “not synced yet” flag. Every change gets marked as not synced. Save on the phone first, send it when there’s internet, and clear the flag once the server has it.
- The last sync time. The phone remembers when it last synced, so it only asks the server for what changed after that, not everything again.
- Balances worked out from transactions. Account balances are saved and updated on every change. If two phones change things offline, merging those balances goes wrong. Calculating them again from the synced transactions doesn’t.
None of these need the screens to change.
The checklist
| For sync | Koshly |
|---|---|
Unique ID for every row (uuid) | ✅ Has it |
updatedAt on every change | ✅ Has it |
| Money as a whole number | ✅ Has it |
| Screens read through repositories | ✅ Has it |
deletedAt for deletes | ❌ To do |
| “Not synced yet” flag | ❌ To do |
| Last sync time | ❌ To do |
| Balances calculated, not stored | ❌ To do |
Where Koshly is today
Koshly still has no account. The only thing that can leave your phone is the optional Google Drive backup. It saves a copy of your data in a hidden folder in your own Drive, so you don’t lose anything when you reinstall or change phones. It goes from your phone straight to Google, and my server never sees it.
So my first thought was a server, and I’m glad I didn’t go with it. Offline-first made Koshly open faster, easier to trust and simpler to run. And if I add sync one day, the database is already ready for it.
If you want to see how it feels with no login, try Koshly on Google Play.
