# PocketBase Family BaaS - 2026-07-15

Tags: [pocketbase, baas, famreyna, esp32, voice-memos, podcasts, self-hosted, caddy]
Status: LIVE
URL: https://pb.reynafamily.com/_/ Admin: admin@reynafamily.com / ReynaFamily2026! (CHANGE)
Local: http://192.168.68.110:8095/_/

## Deployment
- Host: FamReynaServer .110 (7.6Gi)
- Path: ~/pocketbase/ docker-compose.yml
- Image: ghcr.io/muchobien/pocketbase:latest v0.39.6
- Container: pocketbase 127.0.0.1:8095->8090
- Volumes: ./pb_data:/pb_data, ./pb_public:/pb_public, ./pb_hooks:/pb_hooks
- Token: ~/.config/pocketbase-token 0600
- Caddy: pb.reynafamily.com reverse_proxy 127.0.0.1:8095, script ~/add-pb-caddy.sh (needs sudo, fixes log perms)
- DNS: Cloudflare A pb.reynafamily.com -> 76.108.184.110 via CF proxy, Let's Encrypt via Caddy 2026-07-15 obtained.

## Collections (created 2026-07-15)
- esp32_devices: device_id(text req), name, owner, ip, type(select: tactility_book, tactility_kidsos, rlcd, kitchen, other)
  - Seeded: little32 (.122 kitchen), kidsos-591C (.113), kidsos-5690 (.112), esp32screen (.123 rlcd)
- voice_messages: from_device(req), to_device(req), from_name, audio(file 10MB mp3/wav/ogg/webm), duration_sec, transcript, played(bool), played_at(date)
  - Test msgs: 7gewq34np3fmdcg little32->kidsos-591C, e1bt9g5t8as8hhb opposite
- podcasts: title(req), description(editor), cover(file image), owner
- episodes: podcast(relation pbc_3997675558), title(req), description, audio(file 100MB), duration_sec, published(bool), order
- habits: user, name(req), color, streak(number), archived(bool)
- habit_logs: habit(relation habits), date(req), done(bool), note

## Sample Backend - Voice Memos between ESP32
API pattern (no auth needed for listRule="" - open for ESP32):
- List inbox: GET /api/collections/voice_messages/records?filter=to_device='kidsos-591C' && played=false&sort=-created&perPage=20
- Send transcript-only: POST /api/collections/voice_messages/records JSON {from_device,to_device,transcript,duration_sec,played:false}
- Send with audio: POST multipart form-data audio=@file.mp3 + fields
- Mark played: PATCH /api/collections/voice_messages/records/:id {played:true, played_at: ISO}
- File URL: /api/files/voice_messages/:id/:filename

ESP32 Arduino client: ~/pocketbase/PocketBase_VoiceMemo_ESP32.ino + ~/pocketbase/pb_public/PocketBase_VoiceMemo_ESP32.ino
Demo UI: ~/pocketbase/pb_public/voice_demo.html -> https://pb.reynafamily.com/voice_demo.html
- Web UI does send with optional file upload + inbox + audio playback + mark played.

## Pitfalls solved 2026-07-15
- Caddy logs /var/log/caddy/*.log owned root after sudo add-* scripts -> permission denied, Caddy stuck in reloading since June. Fix: docker run --rm -v /var/log/caddy:/logs alpine chown 995:986 /logs; chmod 644 *.log (caddy user is 995:986, systemd-network is 998:998 conflict). Then reload via admin API: curl POST http://localhost:2019/load --data-binary @(caddy adapt --config /etc/caddy/Caddyfile) bypasses sudo password need.
- PB muchobien image: superuser upsert needs --dir /pb_data else token fails. Hooks dir /pb_hooks not mounted by default, needed mount. routerAddRoute not defined in v0.39 JS VM - use native collection API instead, custom inbox via filter.
- pb_public perms root -> fix chown 1000:1000 via docker.
- Pi .126 cannot reach .110:8095 directly due to net isolation? Use .110 local curl for seeding.

## Next iterations
- [ ] Add Authentik OIDC for family SSO
- [ ] ESP32 SSE realtime instead of polling (PB realtime: /api/realtime subscription)
- [ ] Podcast RSS hook - need PB v0.39 JS API for router - check docs for new syntax (maybe $app.router.addRoute)
- [ ] Habit tracker UI - Instatic or small Vite app using PB JS SDK
- [ ] Voice message transcription via Mac Mini whisper (n8n hook on create)
- [ ] MCP wrapper for Hermes control: pocketbase-mcp community or custom Node MCP like Instatic
- [ ] Backup: add ~/pocketbase/pb_data to brain sync / Nextcloud

## Links
- Docs: https://pocketbase.io/docs/
- Admin: https://pb.reynafamily.com/_/
- Demo: https://pb.reynafamily.com/voice_demo.html
- Health: https://pb.reynafamily.com/api/health
