Decision: Data storage — SQLite schema and content loading strategy #10
Labels
No labels
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:prototype
wayfinder:research
wayfinder:research
wayfinder:task
wayfinder:task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#6 Decision: User model — single user vs multi-user with auth
gaetan/knowledgify
Reference
gaetan/knowledgify#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #1
Question
What does the SQLite database schema look like, and how does content loading work?
The content model and user model are settled, so we can now design the storage layer.
Cards table:
Progress table:
Key design questions:
Should cards be stored in the DB or only in JSON? The content model says JSON is source of truth. Options:
How to handle card updates? If a card's question/answer changes in JSON, does the progress reset? Or is it preserved?
Should we store card hashes? To detect when JSON content changes without re-parsing everything.
Database file location? Same directory as the binary? User's home directory? Configurable?
This decision shapes the data access layer and the content loading pipeline.
Dependencies
Resolution
Data storage decided:
Cards in DB: Yes. JSON files are parsed and upserted into SQLite on startup. All queries (due cards, category stats, search) use the DB.
Sync strategy: Hash-based. Store SHA256 hash of card content (question+answer+explanation) in DB. On startup, compare hashes. If changed → delete progress row (reset). If unchanged → keep progress.
Card update behavior: If a card's content changes in JSON, its progress is automatically reset (hash mismatch). The user starts fresh with the new card.
DB file location: Configurable via
KNOWLEDGIFY_DBenv var. Default:./knowledgify.db.SQLite driver:
modernc.org/sqlite(pure Go, no CGO required).Final DB schema:
Startup flow:
content/next_review <= now→ due cards