diff --git a/.gitignore b/.gitignore index c28067a..f38672c 100644 --- a/.gitignore +++ b/.gitignore @@ -59,5 +59,7 @@ drizzle/ .vscode/ .idea/ -# data -/data +# data — commit db snapshot but not secrets or SQLite temp files +/data/secrets.json +/data/db/*.db-wal +/data/db/*.db-shm diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..5a153db --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,123 @@ +# Chadebebe — Wishlist App + +Baby shower wishlist site running at `chadebebe.omeu.website`. Built on [Reggio Digital's wishlist app](https://github.com/Reggio-Digital/wishlist). + +## Stack + +- **Next.js 16** (App Router, standalone build) +- **SQLite** via better-sqlite3 + Drizzle ORM +- **Tailwind CSS v4** +- **Docker** with Traefik reverse proxy + +## Repository layout + +``` +src/ ← Next.js source code (this repo) +data/ + db/wishlist.db ← SQLite database (committed as snapshot) + uploads/ ← user-uploaded images (not committed) +docker-compose.yml ← deployment config (builds image + Traefik labels) +Dockerfile ← multi-stage Next.js build +``` + +## Customization + +### Site title and homepage text + +Stored in the `settings` table — edit directly in SQLite or via the admin UI: + +```sql +UPDATE settings SET value = 'My Title' WHERE key = 'siteTitle'; +UPDATE settings SET value = 'My subtitle' WHERE key = 'homepageSubtext'; +``` + +### Wishlists + +Each wishlist has a `slug` (URL path), `name`, `description`, and optional cover image. +Items live in `wishlist_items` linked by `wishlist_id`. + +To inspect or edit data directly: + +```bash +sqlite3 data/db/wishlist.db +``` + +### Locale / language + +UI strings are hardcoded in the source. The PT-BR localization lives in: + +- `app/layout.tsx` — `` and metadata description +- `app/[slug]/page.tsx` — `Intl.NumberFormat('pt-BR', ...)` for prices +- `components/share-button.tsx` — "Compartilhar" label +- `app/lock/page.tsx`, `app/not-found.tsx`, `app/page.tsx` — page copy + +To switch language, update those files and rebuild the image. + +### Admin credentials + +Set via environment variables in `docker-compose.yml`: + +```yaml +- ADMIN_USERNAME=your_username +- ADMIN_PASSWORD=your_password +``` + +## Deployment + +### Prerequisites + +- Docker + Docker Compose +- Traefik running on a `web` Docker network with a `letsencrypt` cert resolver +- Domain pointing to the server + +### First deploy + +```bash +git clone https://git.omeu.website/root/chadebebe.git +cd chadebebe + +# Build the image and start +docker compose up -d --build +``` + +The `data/db/wishlist.db` snapshot committed in the repo will be used as the initial database. On first run the app writes `data/secrets.json` (JWT keys) — this file is gitignored and must not be committed. + +### Updating the app + +```bash +# Pull latest source +git pull + +# Rebuild image and restart container +docker compose up -d --build +``` + +### Database backup + +The database is a single SQLite file. Back it up with: + +```bash +sqlite3 data/db/wishlist.db "PRAGMA wal_checkpoint(FULL);" +cp data/db/wishlist.db data/db/wishlist.db.bak +``` + +To commit a new snapshot to git: + +```bash +sqlite3 data/db/wishlist.db "PRAGMA wal_checkpoint(FULL);" +git add data/db/wishlist.db +git commit -m "chore: update db snapshot" +git push gitea main +``` + +## Local development + +```bash +cd src # if cloned at root level, otherwise you're already here +cp .env.example .env +npm install +npm run db:migrate +npm run dev +``` + +App runs at `http://localhost:3000`. Admin at `/admin`. diff --git a/data/db/wishlist.db b/data/db/wishlist.db new file mode 100755 index 0000000..91333f4 Binary files /dev/null and b/data/db/wishlist.db differ diff --git a/docker-compose.yml b/docker-compose.yml index bdfd22d..006304b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,27 @@ services: - app: - image: reggiodigital/wishlist:latest - container_name: wishlist + wishlist: + build: . + image: chadebebe-ptbr:latest + container_name: chadebebe restart: unless-stopped - ports: - - "3000:3000" environment: - # User/Group IDs (defaults to 1000:1000, Unraid users set to 99:100) - - PUID=${PUID:-1000} - - PGID=${PGID:-1000} - # Admin credentials - ADMIN_USERNAME=${ADMIN_USERNAME:-admin} - ADMIN_PASSWORD=${ADMIN_PASSWORD:-changeme} + - PUID=${PUID:-1000} + - PGID=${PGID:-1000} + - COOKIE_SECURE=true volumes: - - /folder-for-wishlist-data:/app/data + - ./data:/app/data + networks: + - web + labels: + - "traefik.enable=true" + - "traefik.http.routers.chadebebe.rule=Host(`chadebebe.omeu.website`)" + - "traefik.http.routers.chadebebe.entrypoints=https" + - "traefik.http.routers.chadebebe.tls=true" + - "traefik.http.routers.chadebebe.tls.certresolver=letsencrypt" + - "traefik.http.services.chadebebe.loadbalancer.server.port=3000" + +networks: + web: + external: true