Files
guestguard/docker-compose.yml
T
Kwaku Danso 98678ff5a3 feat(tier2): finish the finish line — Block H follow-ups, Block G geolocation, cross-cutting
Three threads of work land here together to close out Tier 2.

### Block H follow-ups — day-of check-in
- Scanner is now an "open on your phone" magic-link flow. Hosts on
  desktop mint a scoped JWT via POST /events/{id}/scanner-ticket and
  render its URL into a QR; phone scans it and lands on /scanner with
  the ticket as bearer. The ticket carries Audience=scanner so it can
  never substitute for a session token.
- Plus-one confirmation at the door: scan → POST /check-in/preview to
  fetch guest + expected party size → confirm buttons ("Just them",
  "Party of N", custom) → POST /check-in. No more silent arrival_count=1.
- Offline scan queue: failed POSTs go into an IndexedDB store and drain
  on the 'online' event with poison-message protection.
- Day-of arrivals headline widget on the event overview, gated to the
  host's local calendar date so it doesn't dominate the page weeks out.
- Tab nav restyled with inline heroicons + scrollable segmented control;
  Check-in moves to the rightmost slot.
- PWA: manifest + service worker scoped to /scanner, generated 192/512
  icons (Go scripted renderer in scripts/gen-scanner-icons.go).
- Confirmation email QR was rendering broken because html/template
  rewrites data: URLs to #ZgotmplZ; mark the value as template.URL.
- Email "open your invitation" link 404'd because we had no token to
  put after /rsvp/. Threaded AccessLink through the RSVPConfirmed NATS
  event from the API at submit time.

### Block G remainder — geolocation + threshold preview
- Pluggable GeoResolver in the fraud engine (NullResolver, IPApiResolver
  for the free ip-api.com fallback, MaxMindResolver behind GG_GEOIP_DB_PATH).
  Wrapped in a Redis cache (30d TTL). Geo flows through both gRPC and
  NATS scoring paths.
- geo_jump scoring feature: >500km in <1h flags ("accessed from Lagos
  and Paris within 12 minutes"); >500km in <6h is a softer signal. The
  existing single-signal cap keeps a lone geo_jump in MEDIUM.
- FraudScored event carries geo_country/city/lat/lon; ApplyScore uses
  COALESCE so a later re-score without geo doesn't wipe earlier data.
- Threshold-slider live preview: GET /events/{id}/security/thresholds/preview
  returns band counts the host's existing access events would have
  fallen into under the proposed thresholds. Debounced (250ms) widget
  under the Advanced sliders so the host gets concrete feedback instead
  of guessing.

### Cross-cutting — audit, tier-gating, feature flags
- audit_log table + internal/audit.Recorder (async fire-and-forget on
  detached context so an audit blip never fails the real action). Wired
  into branding update, thresholds update, allowlist add/remove,
  collaborator invite/role-change/remove, message create/send-now/cancel.
- Tier-gating: extended billing.Limits with MaxCollaborators,
  CustomBranding, Scanner, Broadcasts. Free = none; Pro = 5 + all;
  Business = unlimited. Gates the scanner-ticket, message create,
  branding put, and collaborator invite endpoints with 402 +
  structured upgrade payload. Auto-reminders, fraud detection, and
  analytics deliberately stay on every tier — those are safety + visibility
  features, not upsell levers.
- Feature flags: feature_flags table + internal/flags.Store with 30s
  in-memory refresh, stable sha256(key + user_id) percent bucketing,
  unknown-key-defaults-on. Six Tier 2 flags pre-seeded. Three handlers
  (branding, broadcasts, scanner) check the kill switch ahead of the
  tier gate so ops can pull a feature back without a redeploy.

### Verified
- go test ./... + fraud-engine pytest (12/12 incl. 3 new geo_jump tests + 5
  new flags tests).
- docker compose build + up across api, fraud-engine, notifier, frontend.
- /health endpoints 200; migrations 0014 + 0015 applied; 6 flags
  seeded; audit_log table + partial indexes confirmed.
- Fraud-engine logs confirm geo resolver kind=CachedGeoResolver provider=auto.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 20:30:02 +01:00

174 lines
5.1 KiB
YAML

services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: guestguard
POSTGRES_PASSWORD: guestguard
POSTGRES_DB: guestguard
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U guestguard -d guestguard"]
interval: 5s
timeout: 3s
retries: 10
mailpit:
image: axllent/mailpit:latest
ports:
- "1025:1025" # SMTP
- "8025:8025" # Web UI
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8025/api/v1/info"]
interval: 5s
timeout: 3s
retries: 10
redis:
image: redis:7-alpine
command: ["redis-server", "--save", "", "--appendonly", "no"]
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
nats:
image: nats:2.10-alpine
command:
- "-js"
- "-sd"
- "/data"
- "-m"
- "8222"
ports:
- "4222:4222"
- "8222:8222"
volumes:
- nats-data:/data
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8222/healthz"]
interval: 5s
timeout: 3s
retries: 10
api:
build:
context: .
dockerfile: cmd/api/Dockerfile
environment:
GG_ENV: development
GG_HTTP_ADDR: :8080
GG_DATABASE_URL: postgres://guestguard:guestguard@postgres:5432/guestguard?sslmode=disable
GG_NATS_URL: nats://nats:4222
GG_FRAUD_GRPC_ADDR: fraud-engine:9091
GG_FRAUD_GRPC_TIMEOUT: 250ms
GG_REDIS_ADDR: redis:6379
GG_SMTP_HOST: mailpit
GG_SMTP_PORT: "1025"
GG_SMTP_FROM_EMAIL: noreply@guestguard.local
GG_SMTP_FROM_NAME: GuestGuard (dev)
# Resend overrides SMTP when GG_RESEND_API_KEY is set in .env at the
# project root. Leave unset and Mailpit (above) handles delivery.
GG_RESEND_API_KEY: ${GG_RESEND_API_KEY:-}
GG_RESEND_FROM_EMAIL: ${GG_RESEND_FROM_EMAIL:-}
GG_RESEND_FROM_NAME: ${GG_RESEND_FROM_NAME:-GuestGuard}
GG_TOKEN_SECRET: dev-only-insecure-secret-change-me
GG_JWT_SECRET: dev-only-insecure-jwt-secret-change-me-32+bytes
GG_PUBLIC_BASE_URL: http://localhost:3000
# Stripe billing — empty values leave billing disabled. Set in
# .env at the project root to enable.
GG_STRIPE_SECRET_KEY: ${GG_STRIPE_SECRET_KEY:-}
GG_STRIPE_WEBHOOK_SECRET: ${GG_STRIPE_WEBHOOK_SECRET:-}
GG_STRIPE_PRICE_PRO: ${GG_STRIPE_PRICE_PRO:-}
GG_STRIPE_PRICE_BUSINESS: ${GG_STRIPE_PRICE_BUSINESS:-}
# Tier 2 Block D — branding image uploads. Stored on the named
# volume below so they survive container restarts; production
# would back this with S3 + CDN instead.
GG_UPLOADS_DIR: /var/lib/guestguard/uploads
GG_UPLOADS_PUBLIC_URL: http://localhost:8080/uploads
volumes:
- uploads-data:/var/lib/guestguard/uploads
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
nats:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
fraud-engine:
build:
context: ./fraud-engine
dockerfile: Dockerfile
environment:
GG_ENV: development
GG_HTTP_ADDR: 0.0.0.0:8081
GG_GRPC_ADDR: 0.0.0.0:9091
GG_NATS_URL: nats://nats:4222
# Tier 2 Block G — geolocation. "auto" prefers MaxMind when a
# mmdb file lives at GG_GEOIP_DB_PATH, else falls back to free
# ip-api.com. Set GG_GEOIP_PROVIDER=null to disable entirely for
# local-only dev with no outbound internet.
GG_GEOIP_PROVIDER: ${GG_GEOIP_PROVIDER:-auto}
GG_GEOIP_DB_PATH: ${GG_GEOIP_DB_PATH:-/var/lib/guestguard/GeoLite2-City.mmdb}
GG_REDIS_URL: redis://redis:6379
ports:
- "8081:8081"
- "9091:9091"
depends_on:
nats:
condition: service_healthy
redis:
condition: service_healthy
restart: unless-stopped
notifier:
build:
context: .
dockerfile: cmd/notifier/Dockerfile
environment:
GG_ENV: development
GG_DATABASE_URL: postgres://guestguard:guestguard@postgres:5432/guestguard?sslmode=disable
GG_NATS_URL: nats://nats:4222
GG_PUBLIC_BASE_URL: http://localhost:3000
GG_SMTP_HOST: mailpit
GG_SMTP_PORT: "1025"
GG_SMTP_FROM_EMAIL: noreply@guestguard.local
GG_SMTP_FROM_NAME: GuestGuard (dev)
GG_RESEND_API_KEY: ${GG_RESEND_API_KEY:-}
GG_RESEND_FROM_EMAIL: ${GG_RESEND_FROM_EMAIL:-}
GG_RESEND_FROM_NAME: ${GG_RESEND_FROM_NAME:-GuestGuard}
depends_on:
postgres:
condition: service_healthy
nats:
condition: service_healthy
restart: unless-stopped
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
environment:
NODE_ENV: production
NUXT_PUBLIC_API_BASE: http://localhost:8080
NUXT_PUBLIC_WS_BASE: ws://localhost:8080
ports:
- "3000:3000"
depends_on:
- api
restart: unless-stopped
volumes:
postgres-data:
nats-data:
uploads-data: