diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c96435d --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +/bin/ +/vendor/ +*.exe +*.exe~ +*.dll +*.so +*.dylib +*.test +*.out +/storage/*.db +/storage/*.db-journal +.env +.idea/ +.vscode/ +*.swp +*.swo +.DS_Store + diff --git a/README.md b/README.md index 9480679..e4ddcbc 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ # PieVR + +## Database Schema & Core Concepts +- **Storage:** SQLite (`storage/` directory, ignored in `.gitignore`). +- **Tables:** + - `questions`: stores core question data (`id`, `type`, `question_text`, `payload` as JSON, `active`, `last_asked_at`, `streak`, `times_asked`, `times_correct`, `created_at`). + - `tags`: tags for granular and cross-cutting topic selection (`id`, `name`). + - `question_tags`: many-to-many relationship between questions and tags. +- **Priority & Spaced Repetition:** No hardcoded calendar intervals. Priorities and scheduling metrics are stored as raw counters (`streak`, `times_asked`, `last_asked_at`) in the database, while complex priority/decay formulas are calculated dynamically on the fly in Go. diff --git a/internal/storage/schema.sql b/internal/storage/schema.sql new file mode 100644 index 0000000..97b8f8f --- /dev/null +++ b/internal/storage/schema.sql @@ -0,0 +1,25 @@ +-- PieVR Database Schema + +CREATE TABLE IF NOT EXISTS questions ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + type TEXT NOT NULL, + question_text TEXT NOT NULL, + payload TEXT NOT NULL, + active BOOLEAN DEFAULT 1, + last_asked_at DATETIME, + streak INTEGER DEFAULT 0, + times_asked INTEGER DEFAULT 0, + times_correct INTEGER DEFAULT 0, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS tags ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT UNIQUE NOT NULL +); + +CREATE TABLE IF NOT EXISTS question_tags ( + question_id INTEGER REFERENCES questions(id) ON DELETE CASCADE, + tag_id INTEGER REFERENCES tags(id) ON DELETE CASCADE, + PRIMARY KEY (question_id, tag_id) +);