mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-04-05 17:33:31 -04:00
removed large xml and systemd service
This commit is contained in:
35
CLAUDE.md
35
CLAUDE.md
@@ -66,12 +66,25 @@ bun run db:studio # Open Drizzle Studio GUI
|
||||
|
||||
## Critical: Date/Time Handling
|
||||
|
||||
**Bibdle is played by users across many timezones worldwide. The verse shown to a player must always be the verse for the calendar date at *their* location — not the server's timezone, not UTC. A user in Tokyo on Wednesday must see Wednesday's verse, even if the server (or a user in New York) is still on Tuesday.**
|
||||
|
||||
**NEVER use server time or UTC time for user-facing date calculations.**
|
||||
|
||||
- Get today's date client-side: `new Date().toLocaleDateString("en-CA")` → `YYYY-MM-DD`
|
||||
- Pass the date to the server as a query param or POST body (`localDate`)
|
||||
- Server-side date arithmetic must use UTC methods on the client-provided date string: `new Date(dateStr + 'T00:00:00Z')` + `setUTCDate`/`getUTCDate`
|
||||
- `src/routes/+page.ts` has `ssr = false` so the load runs client-side with the true local date
|
||||
- Never set the user-facing URL to include their date as a parameter. It should always be passed to an API route behind the scenes if needed.
|
||||
|
||||
### Streak Calculation
|
||||
|
||||
A streak counts consecutive calendar days (in the user's local timezone) on which the user completed the puzzle. The rules:
|
||||
|
||||
- The client passes its local date (`localDate`) to the streak API. The server never uses its own clock.
|
||||
- A streak is **active** if the user has completed today's puzzle *or* yesterday's puzzle (they still have time to play today).
|
||||
- Walk backwards from `localDate` through the `dailyCompletions` records, counting each day that has a completion. Stop as soon as a day is missing.
|
||||
- A streak of 1 (completed only today or only yesterday, with no prior consecutive days) is **not displayed** — the minimum shown streak is 2.
|
||||
- "Yesterday" and all date arithmetic on the server must use UTC methods on the client-provided date string to avoid timezone drift: `new Date(localDate + 'T00:00:00Z')`, then `setUTCDate`/`getUTCDate`.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -88,11 +101,11 @@ Sessions expire after 30 days and auto-renew when < 15 days remain.
|
||||
|
||||
The `bibleBooks` array contains all 66 Bible books with metadata:
|
||||
- Testament (old/new), Section (Law, History, Wisdom, Prophets, Gospels, Epistles, Apocalyptic)
|
||||
- Order (1-66, used for adjacency detection), Popularity (2-10, affects grading)
|
||||
- Order (1-66, used for adjacency detection)
|
||||
|
||||
### Daily Verse System (`src/routes/+page.server.ts`)
|
||||
|
||||
`getTodayVerse()` checks the database for today's date, fetches from bible-api.com if missing (random verse + 2 consecutive), caches permanently, and returns verse with book metadata.
|
||||
`getTodayVerse()` checks the database for today's date, fetches a verse if missing, caches permanently, and returns verse with book metadata.
|
||||
|
||||
### Game Logic (`src/routes/+page.svelte`)
|
||||
|
||||
@@ -101,15 +114,7 @@ The `bibleBooks` array contains all 66 Bible books with metadata:
|
||||
- Each guess tracks: book, testamentMatch, sectionMatch, adjacent
|
||||
- `isWon` derived from whether any guess matches the correct book
|
||||
|
||||
**Grading System:**
|
||||
```javascript
|
||||
performanceScore = max(0, 10 - numGuesses)
|
||||
difficulty = 14 - popularity
|
||||
totalScore = performanceScore + difficulty * 0.8
|
||||
// S: 14+, A: 11+, B: 8+, C: 5+, C-: <5
|
||||
```
|
||||
|
||||
**Hint System:**
|
||||
**Hint System, for share grid:**
|
||||
- ✅ Exact match | 🟩 Section match | 🟧 Testament match | ‼️ Adjacent book | 🟥 No match
|
||||
|
||||
### Authentication System (`src/lib/server/auth.ts`)
|
||||
@@ -139,7 +144,7 @@ totalScore = performanceScore + difficulty * 0.8
|
||||
- `src/routes/+page.server.ts` / `+page.ts` — Server load (verse) + client load (`ssr: false`)
|
||||
- `src/routes/stats/+page.svelte` / `+page.server.ts` — Stats UI and server calculations
|
||||
- `src/lib/server/auth.ts` — Session management, password hashing, anonymous migration
|
||||
- `src/lib/server/bible-api.ts` — External API integration
|
||||
- `src/lib/server/bible-api.ts` — Random verse fetching from local XML Bible
|
||||
- `src/lib/server/bible.ts` — Bible book utility functions
|
||||
- `src/lib/types/bible.ts` — Bible books data and TypeScript types
|
||||
- `src/lib/server/db/schema.ts` — Drizzle ORM schema
|
||||
@@ -153,4 +158,8 @@ Required in `.env`:
|
||||
|
||||
## Deployment
|
||||
|
||||
Uses `@sveltejs/adapter-node`. See `bibdle.service` and `bibdle.socket` for systemd configuration.
|
||||
Uses `@sveltejs/adapter-node`. See `bibdle.service` systemd configuration.
|
||||
|
||||
## A Note
|
||||
|
||||
The main developer of this project is still learning a lot about developing full-stack applications. If they ask you to do something, make sure they understand how it will be implemented before proceeding.
|
||||
|
||||
Reference in New Issue
Block a user