Files
chadebebe/CLAUDE.md

135 lines
3.2 KiB
Markdown

# 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``<html lang="pt-BR">` and metadata description
- `app/[slug]/page.tsx``Intl.NumberFormat('pt-BR', ...)` for prices
- `components/share-button.tsx` — "Compartilhar" label
- `app/not-found.tsx`, `app/page.tsx` — page copy
To switch language, update those files and rebuild the image.
### Admin token
The admin authenticates by visiting the site with `?adm=<token>` once. The token is set as an env var:
```yaml
- ADMIN_TOKEN=long-random-hex-at-least-16-chars
```
The token is also accepted from the cookie `adm_token` after first visit.
### Guests
Each guest gets their own URL: `https://chadebebe.omeu.website/<slug>?usr=<token>`. Manage guests at `/admin/guests` or via CLI:
```bash
npm run guest:create -- --name="Martin"
npm run guest:list
npm run guest:delete -- --id=<guest-id>
```
## 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.
### 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`.