7.8 KiB
CLAUDE.md — GuestGuard
This file configures Claude Code's behaviour for this project.
What this project is
GuestGuard is a secure event RSVP platform with real-time fraud detection. Guests receive unique, cryptographically signed invitation links. When someone accesses a link, the system collects device fingerprints and IP geolocation, scores the access for fraud risk, and blocks unauthorised users.
The architecture has three components, each with a genuine reason to be separate:
- Core API (Go) — All synchronous CRUD: events, guests, RSVPs, tokens, auth. Publishes events to NATS. Serves REST + WebSocket.
- Fraud Engine (Python/FastAPI) — Consumes access events from NATS, runs ML risk scoring, publishes fraud scores back. Exposes gRPC for synchronous scoring during RSVP submission.
- Notification Worker (Go) — Consumes events from NATS, sends SMS via Twilio, email via AWS SES, with retry and backoff.
Message broker: NATS JetStream. Frontend: Nuxt 3 with Tailwind CSS. Database: PostgreSQL. Cache: Redis.
Architecture document
Read docs/ARCHITECTURE.md for the full architecture, data flows, database schema, fraud scoring model, and API design. Always reference this file before building any feature — it contains the detailed specifications for every component.
Project context
- Owner: alchemistkay (Kwaku Danso)
- Platform: k4scloud homelab (k3s) + GitHub mirror
- Domain: guestguard.k4scloud.com
- Registry: harbor.k4scloud.com/guestguard
- GitOps: Gitea Actions → Harbor → ArgoCD
- Go module: github.com/alchemistkay/guestguard
Repository structure
guestguard/
├── CLAUDE.md # This file
├── docs/
│ └── ARCHITECTURE.md # Full architecture spec (read this first)
├── cmd/
│ ├── api/main.go # Core API entrypoint
│ └── notifier/main.go # Notification worker entrypoint
├── internal/
│ ├── api/ # HTTP handlers, middleware, WebSocket
│ ├── auth/ # JWT, OAuth
│ ├── domain/ # Business logic (events, guests, RSVPs, tokens)
│ ├── fraud/ # gRPC client for fraud engine
│ ├── nats/ # NATS publisher/subscriber
│ ├── notification/ # Twilio, SES adapters
│ └── storage/ # PostgreSQL, Redis repositories
├── fraud-engine/
│ ├── app/ # FastAPI app
│ ├── scoring/ # Risk scoring logic
│ ├── consumers/ # NATS event consumers
│ └── Dockerfile
├── frontend/
│ ├── pages/
│ ├── components/
│ ├── composables/
│ └── Dockerfile
├── docker-compose.yml
├── Makefile
└── README.md
Conventions
Go services (Core API + Notification Worker)
- Module path:
github.com/alchemistkay/guestguard - Use
log/slogfor logging (JSON handler in production) - Use
net/httpstdlib with Go 1.22+ routing for the Core API - Health endpoint at
GET /healthon every service - Config via
os.Getenvwith defaults — no Viper - Graceful shutdown with signal handling (SIGINT, SIGTERM)
- Table-driven tests
- PostgreSQL via
github.com/jackc/pgx/v5 - Redis via
github.com/redis/go-redis/v9 - NATS via
github.com/nats-io/nats.go - JWT via
github.com/golang-jwt/jwt/v5 - gRPC via
google.golang.org/grpc(client to fraud engine)
Python service (Fraud Engine)
- Python 3.11+ with FastAPI
- Pydantic v2 for schemas, pydantic-settings for config
rufffor linting and formattingpytestfor testing- scikit-learn for ML model (start with heuristic scoring, upgrade later)
- NATS via
nats-py - gRPC via
grpcio(server)
Frontend (Nuxt 3)
- Nuxt 3 with Tailwind CSS
- Dark theme (zinc-950 background)
- Brand colour: green (#22c55e) — conveys safety/security
- All API calls use relative URLs via
useApi()composable - WebSocket URLs derived from
window.location - No NUXT_ env vars for API URLs in production
- SSR for landing page, client-side for dashboard
Docker
- Multi-stage builds
- Alpine base for Go, slim base for Python, Alpine for Nuxt (node)
- Non-root user in final image (UID 1000)
- Health check via k8s probes (not HEALTHCHECK in Dockerfile)
Git
- Branch: main (default), feature/, release/, hotfix/*
- Commit messages: conventional commits (feat:, fix:, chore:, docs:, ci:)
- Squash merge feature branches
- Always commit package-lock.json
What to build vs what NOT to build
Claude Code builds:
- All Go source code (cmd/, internal/)
- All Python source code (fraud-engine/)
- All frontend code (frontend/)
- Unit tests and integration tests
- docker-compose.yml for local development
- Dockerfiles (multi-stage, following conventions above)
- Database migrations (golang-migrate)
- Protobuf definitions for gRPC (fraud scoring)
- NATS subject definitions and message schemas
- Makefile
Claude Code does NOT build (human handles):
- Kubernetes manifests (Deployments, Services, etc.)
- Gitea Actions CI/CD pipelines
- ArgoCD Application definitions
- NetworkPolicies
- Sealed Secrets
- Terraform
- Grafana dashboards
- Prometheus alert rules
- Helm charts or Kustomize overlays
- Harbor project configuration
Quality gates before handoff
Before marking application code as "ready for deployment":
docker-compose upstarts all services (API, fraud engine, notifier, frontend, PostgreSQL, Redis, NATS)- Health endpoints return 200 on API (
/health), fraud engine (/health) - Unit tests pass:
go test ./...andcd fraud-engine && pytest -v - Frontend loads at http://localhost:3000 and can reach backend APIs
- Core flow works: create event → add guest → generate token → access RSVP link → submit RSVP
- Fraud flow works: access with different fingerprint → risk score > 60 → SMS verification triggered
- Notification flow works: RSVP confirmed → confirmation event published to NATS → worker logs delivery attempt
- No hardcoded localhost URLs in production code paths
- Structured JSON logging on all services
- Prometheus metrics endpoint exposed on API (
/metrics)
Build order
When building this project, follow this sequence:
Phase 1: Core API foundation
- Go project scaffold (cmd/api, internal packages)
- Config loading from environment
- PostgreSQL connection + schema (events, guests, tokens, rsvps tables)
- Event CRUD endpoints (POST/GET/PATCH/DELETE /events)
- Guest management endpoints (POST/GET /events/:id/guests, CSV import)
- Token generation (HMAC-SHA256 signed, per-guest unique)
- RSVP endpoint (validate token → record response)
- Health endpoint
- Unit tests for token logic and RSVP validation
- Dockerfile
Phase 2: NATS + Fraud Engine
- NATS JetStream connection in Core API
- Publish access events on token validation (guest.access.attempted)
- Fraud Engine scaffold (FastAPI + NATS consumer)
- Device fingerprint collection (frontend JavaScript)
- Heuristic risk scoring (weighted features)
- gRPC service definition (proto file)
- gRPC server in Fraud Engine
- gRPC client in Core API (synchronous scoring during RSVP)
- Publish fraud.scored events back to NATS
- Core API consumes fraud scores, flags tokens
- Integration tests (NATS end-to-end)
Phase 3: Notifications + Frontend
- Notification Worker scaffold (cmd/notifier)
- NATS consumers (invitation.send, rsvp.confirmed, fraud.alert)
- Twilio SMS adapter (with retry logic)
- Nuxt 3 frontend scaffold
- Landing page
- RSVP flow pages (/rsvp/:token)
- Host dashboard (event list, guest management, RSVP tracking)
- Real-time monitor page (WebSocket for live RSVPs + fraud alerts)
- docker-compose.yml for full local development
- End-to-end testing