moving to local dev

This commit is contained in:
George Powell
2025-12-22 23:57:46 -05:00
parent c8179da75d
commit ca60002dd9
4 changed files with 143 additions and 23 deletions

3
.gitignore vendored
View File

@@ -24,3 +24,6 @@ vite.config.ts.timestamp-*
# SQLite
*.db
llms-*

123
CLAUDE.md Normal file
View File

@@ -0,0 +1,123 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Bibdle is a daily Bible verse guessing game built with SvelteKit 5. Players read a verse and try to guess which book of the Bible it comes from. The game provides feedback hints (Testament match, Section match, Adjacent book) similar to Wordle-style games. Progress is stored locally in the browser and a new verse is generated daily.
## Tech Stack
- **Framework**: SvelteKit 5 with Svelte 5 (uses runes: `$state`, `$derived`, `$effect`, `$props`)
- **Styling**: Tailwind CSS 4
- **Database**: SQLite with Drizzle ORM
- **Auth**: Session-based authentication using @oslojs/crypto (SHA-256 hashed tokens)
- **Deployment**: Node.js adapter for production builds
- **External API**: bible-api.com for fetching random verses
## Development Commands
```bash
# Start development server
npm run dev
# Type checking
npm run check
npm run check:watch
# Build for production
npm run build
# Preview production build
npm run preview
# Database operations
npm run db:push # Push schema changes to database
npm run db:generate # Generate migrations
npm run db:migrate # Run migrations
npm run db:studio # Open Drizzle Studio GUI
```
## Architecture
### Database Schema (`src/lib/server/db/schema.ts`)
- **user**: User accounts with id and age
- **session**: Auth sessions linked to users with expiration timestamps
- **daily_verses**: Cached daily verses with book ID, verse text, reference, and date
Sessions expire after 30 days and are automatically renewed when less than 15 days remain.
### Bible Data (`src/lib/types/bible.ts`)
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 - higher is more popular)
### Daily Verse System (`src/routes/+page.server.ts`)
The `getTodayVerse()` function:
1. Checks database for existing verse for today's date
2. If none exists, fetches from bible-api.com (random verse + 2 consecutive verses)
3. Caches in database with UTC date key
4. Returns verse with book metadata for the game
### Game Logic (`src/routes/+page.svelte`)
**State Management:**
- `guesses` array stores game state in localStorage keyed by date
- Each guess tracks: book, testamentMatch, sectionMatch, adjacent
- `isWon` is derived from whether any guess matches the correct book
**Grading System:**
```javascript
// Grade formula combines performance + difficulty
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:**
- ✅ Green checkmark: Exact match
- 🟩 Green square: Section matches
- 🟧 Orange square: Testament matches (shared results)
- ‼️ Double exclamation: Adjacent book in Bible order
- 🟥 Red square: No match
### Authentication System (`src/lib/server/auth.ts`)
- Token-based sessions with SHA-256 hashing
- Cookies store session tokens, validated on each request
- Hook in `src/hooks.server.ts` populates `event.locals.user` and `event.locals.session`
- Note: Currently the schema includes user table but auth UI is not yet implemented
## Key Files
- `src/routes/+page.svelte` - Main game UI and client-side logic
- `src/routes/+page.server.ts` - Server load function, fetches/caches daily verse
- `src/lib/server/bible-api.ts` - External API integration for verse fetching
- `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 definitions
- `src/hooks.server.ts` - SvelteKit server hook for session validation
## Environment Variables
Required in `.env`:
- `DATABASE_URL` - Path to SQLite database file (e.g., `./local.db`)
## Deployment
The project uses `@sveltejs/adapter-node` for deployment. The build output is a Node.js server that can be run with systemd or similar process managers. See `bibdle.service` and `bibdle.socket` for systemd configuration.
## Important Notes
- Uses Svelte 5 runes syntax (`$state`, `$derived`, `$effect`, `$props`) - not stores or reactive declarations
- The schema includes authentication tables but the login/signup UI is not yet implemented
- Daily verses are cached permanently in the database to ensure consistency
- LocalStorage persists guesses per day using the key pattern `bibdle-guesses-${date}`
- The game validates book IDs from the API against the hardcoded `bibleBooks` array

View File

@@ -6,7 +6,7 @@ After=network-online.target bibdle.socket
[Service]
Environment=NODE_ENV=production
Environment=ORIGIN=https://bibdle.orthodox.cafe
Environment=ORIGIN=https://bibdle.com
Environment=DATABASE_URL=local.db
Environment=IDLE_TIMEOUT=60
WorkingDirectory=/home/george/projects/bibdle

38
todo.md
View File

@@ -2,24 +2,18 @@
- dark mode between sunset and sunrise
- https://news.ycombinator.com/item?id=44846281
- connect to cloudflare
- light mode after sunrise
- https://github.com/GitSquared/node-geolite2-redist
get approximate user location from IP
- https://www.npmjs.com/package/sunrise-sunset-js
get sunrise/sunset times by lat/longitude
- top XX% next to the "rank" stat on complete
### Difficulty levels
- Below the success screen, a small button for hard mode:
- difficult mode (guess old or new testament, first try only)
- impossible mode (1894 scrivener koine greek NT or some hebrew version for OT)
- maybe remove rank and average guesses
- only show "top 10 / 5 / 1%" if there are more than 10/20/100 guesses?
- hovering or tapping BIBDLE fades in and out to BIBLE DAILY
- Difficulty levels
- difficult mode (guess old or new testament, first try *only*)
- impossible mode (1894 scrivener koine greek NT or some hebrew version for OT) three guesses only
# bibdle unlimited
- Practice mode: Unlimited verses
@@ -33,11 +27,11 @@
- linkedin post
- ocf discord server
-
- nick makiej ✅
# About this game
As a young camper at the Metropolis of Boston Camp, I remember His Eminence Metropolitan Methodios would visit every Sunday. He was often surrounded by important people for his entire time there, so I never gathered the courage to introduce myself, but his homilies during Liturgy always stood out to me. In some ways, they differed year after year, but a majority of his message remained strikingly familiar. "Take ten minutes to read the Bible every day," he asked. "Just ten minutes. Go somewhere quiet, turn off the TV (or iPod or cell phone), and read in peace and quiet."
As a young camper at the Metropolis of Boston Camp, I remember His Eminence Metropolitan Methodios would visit every Sunday. He was often surrounded by important people for his entire time there, so I never gathered the courage to introduce myself, but his homilies during Liturgy always stood out to me. In some ways, they differed year after year, but a majority of his message remained strikingly familiar. "Take ten minutes to read the Bible every day," he asked. "Just ten minutes. Go somewhere quiet, turn off the TV (then iPod, then cell phone), and read in peace and quiet."
Despite His Eminence's otherwise cool and intimidating aura, it never came across as a demand or an order. Yet it wasn't exactly polite either. It sounded closer to pleading... like to his core, he knew how important it was, what he was asking — how important it would be for our lives.
@@ -45,26 +39,26 @@ I never really followed through with what he asked. The Metropolis of Boston Cam
I created Bibdle from a combination of two things. The first is my lifelong desire to create experiences that people love; to create experiences that bring people together. The second is my guilt for never reading the Bible at home like Metropolitan Methodios asked. I hope it helps you with this challenge as much as it's helped me!
---------------
------------------------------
# done
## december 21st
- better guess emoji consistency (removed ambiguous red squares)
- HH:MM until next verse
- triodion font for verse
- triodion font for verse (PT Serif)
- custom verses for Christmas Eve and Christmas
## before december 19th
- improve design (uniform column widths on desktop)
- moved to bibdle.com
- v2: avg guesses per bible verse updating daily (on completion: avg. guesses: 6)
- v2: you're the XXXth person to guess correctly today
- metadata
- favicon
- site title
- deploy
------------------------------