Thread

The easy route would be to just store everything in the SQLite database, but I really do prefer the approach of having local files. I think the right choice is going to be a hybrid approach where the app uses both local files and a database, but I need to find the right balance... There should be an app database storing 'Spaces' with their names and icons/images. This database will be stored inside the app directory, and it will therefore be device-specific. This means, each device will have its own local database. This creates a bit of a problem in terms of continuity because of no global database that's hosted in the cloud. Imagine the following scenario: - The user bookmarks a note on their Mac. - Now the user opens the iOS app, but the bookmark is not to be found. The bookmark will not appear automatically, because as already mentioned, each device has its own local database. Luckily, there is another way to do it that solves the problem of continuity. I could simply use hidden folders inside the space folder. Then the local database will just mirror the information found in the files located in the hidden `.space/` folder. The folder structure could be something like: ``` /Documents/My_Project_Space/ β”œβ”€β”€ .space/ β”‚ β”œβ”€β”€ settings.json (spaceName, icon/image, bookmarks, recentNotes, ...) β”‚ └── history/ β”‚ └── F0B35EEF/ (Folder named by note ID) β”‚ β”œβ”€β”€ 20260112_1000.json β”‚ └── 20260112_1045.json β”œβ”€β”€ assets/ β”‚ └── some_image.png β”œβ”€β”€ Work_Notes/ β”‚ └── meeting_jan_12.json └── some_other_note.json ``` The local files should always be the source of truth, while the database is there mirroring for performance. If the user types a character in a note, the local DB should be updated and immediately refresh the UI, this should take <1ms, so the user sees the change instantly. Then after, the app triggers a background task to write the updated JSON to the disk. I'm still in the process of figuring out the best architecture before beginning implementation, but I think I'm starting to have a pretty good idea of how to best do this. #dev #app
Frederik Handberg's avatar Frederik Handberg
Gemini 3 Thinking is really good at brainstorming implementation architectures for my notes app. I'm trying to decide how I want to store notes. Currently, I have an approach of using a local JSON-file for each note document, but I _need_ a local SQLite database for version control and other features. Technically, I don't really need the database for version control, as I could have a `/.history/[note-id]` folder and then store each version of the note, but this is not efficient at all. It increases disk usage like crazy compared to the database-approach. #dev
View quoted note →

Replies (1)