From 36801120692d02e2836d8bd82aba4f59b27a96a3 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Thu, 1 Oct 2026 05:34:43 -0500 Subject: [PATCH] plan(bdinvite): curate frontend specification and implementation plan --- 01-plans/bdinvite/frontend-specification.md | 1067 +++++++++++++++++++ 01-plans/bdinvite/implementation-plan.md | 915 ++++++++++++++++ 2 files changed, 1982 insertions(+) create mode 100644 01-plans/bdinvite/frontend-specification.md create mode 100644 01-plans/bdinvite/implementation-plan.md diff --git a/01-plans/bdinvite/frontend-specification.md b/01-plans/bdinvite/frontend-specification.md new file mode 100644 index 0000000..7887257 --- /dev/null +++ b/01-plans/bdinvite/frontend-specification.md @@ -0,0 +1,1067 @@ +--- +type: plan +status: completed +project: bdinvite +tags: + - bdinvite + - frontend + - react + - design + - specifications +--- + +# Digital Invitation — Frontend Specification + +## 1. Purpose + +A responsive, mobile-first digital birthday invitation that reproduces the visual character of a physical invitation while adding an interactive RSVP flow. + +The application has two distinct experiences: + +### Guest experience + +A highly designed invitation consisting of: + +1. Invitation cover + +2. RSVP call-to-action + +3. RSVP form + +4. Submission feedback + +5. Optional event/location information + + +### Admin experience + +A simple dashboard allowing the event organizer to: + +- authenticate + +- view people who have responded + +- inspect RSVP information + +- distinguish successful registrations from other states + +- optionally export or manage responses + + +The guest experience is the primary design focus. The admin dashboard deliberately does **not** need the invitation's visual effects. + +--- + +# 2. Design Principles + +The frontend should follow five principles. + +### 2.1 The invitation is a physical object + +The invitation maintains a fixed vertical aspect ratio regardless of viewport width. + +The browser provides a responsive **stage** around it. + +```text +Desktop + +┌────────────────────────────────────────────┐ +│ │ +│ ┌──────────────────┐ │ +│ │ │ │ +│ │ INVITATION │ │ +│ │ │ │ +│ │ │ │ +│ └──────────────────┘ │ +│ │ +└────────────────────────────────────────────┘ +``` + +On mobile, the invitation expands to occupy the available width. + +--- + +### 2.2 One visual composition + +There should not be separate mobile and desktop invitation designs. + +The same invitation is scaled responsively. + +Desktop provides additional surrounding space; mobile provides essentially the entire viewport to the invitation. + +--- + +### 2.3 Decoration must not interfere with information + +The animated particle background is subordinate to the content. + +Particles should: + +- concentrate toward the upper-left and lower-right + +- remain sparse around the central content + +- move slowly + +- vary in size and opacity + +- have soft golden glows + +- occasionally pulse subtly + +- never make text difficult to read + + +The central diagonal/content region should remain substantially darker. + +--- + +### 2.4 The RSVP interaction is part of the invitation + +The form should not look like an unrelated web application. + +It inherits: + +- background + +- typography + +- spacing + +- color + +- particle atmosphere + +- restrained visual language + + +The admin dashboard is exempt from this constraint. + +--- + +### 2.5 Content is configuration, not code + +Event-specific copy must not be hardcoded into components. + +The frontend should be capable of rendering a different invitation by changing configuration. + +For example: + +```text +Birthday Party +You're Invited +Isabelle Snow +October 28 +7:00 PM +``` + +should be data rather than component markup. + +--- + +# 3. Guest Experience + +## State 1 — Invitation + +The initial viewport displays the invitation. + +Conceptually: + +```text +┌─────────────────────────────┐ +│ │ +│ BIRTHDAY PARTY │ +│ │ +│ YOU'RE INVITED │ +│ │ +│ ISABELLE SNOW │ +│ │ +│ OCT 28 │ +│ 7:00 PM │ +│ │ +│ │ +│ CONFIRMA TU ASISTENCIA │ +│ ↓ │ +│ │ +└─────────────────────────────┘ +``` + +The actual visual hierarchy should use the previously established typography system: + +- script/display font for major handwritten elements + +- Montserrat or equivalent geometric sans-serif for metadata + +- uppercase + generous tracking for supporting information + + +The address is deliberately omitted from the front. + +Instead, its position becomes the RSVP CTA. + +--- + +# 4. RSVP CTA + +The CTA should be visually integrated into the invitation. + +Default copy: + +> **CONFIRMA TU ASISTENCIA** +> ↓ + +The entire CTA region should be interactive. + +Interaction: + +```text +click CTA + ↓ +smooth transition + ↓ +RSVP section +``` + +The CTA should also be keyboard accessible and have a visible focus state. + +The arrow is decorative but should not be the only indication that the element is interactive. + +--- + +# 5. RSVP Form + +The form appears below the invitation. + +Conceptually: + +```text +┌─────────────────────────────┐ +│ │ +│ ¿NOS VEMOS? │ +│ │ +│ NOMBRE COMPLETO │ +│ ───────────────────── │ +│ │ +│ TELÉFONO │ +│ ───────────────────── │ +│ │ +│ CORREO · OPCIONAL │ +│ ───────────────────── │ +│ │ +│ TE VEO AHÍ │ +│ │ +└─────────────────────────────┘ +``` + +### Fields + +#### Full name + +Required. + +```text +name +``` + +Validation: + +- non-empty + +- reasonable maximum length + +- whitespace normalized + + +#### Phone + +Required. + +```text +phone +``` + +The frontend should perform basic format validation but should **not assume a specific international phone-number format unless the event requires one**. + +#### Email + +Optional. + +```text +email +``` + +If provided, it should be validated as an email address. + +The frontend should not make email mandatory simply because the backend can store it. + +--- + +# 6. Submit Button + +Default: + +> **TE VEO AHÍ** + +The wording is configurable. + +Other possible configured values could include: + +```text +TE VEO AHÍ +NOS VEMOS +AHÍ ESTARÉ +CONFIRMAR ASISTENCIA +``` + +The component should not care which copy is selected. + +--- + +# 7. Form Validation + +Validation should happen before submission. + +For example: + +```text +NOMBRE COMPLETO +[ ] + +Este campo es obligatorio. +``` + +Errors should appear close to the relevant field. + +Avoid browser-default validation messages as the primary experience. + +The visual treatment should remain consistent with the invitation. + +The form should not clear valid fields merely because one field failed validation. + +--- + +# 8. Submission State + +After the user submits: + +```text +form + ↓ +submitting +``` + +The button enters a loading state. + +For example: + +```text +ENVIANDO... +``` + +The user should not be able to submit the same form repeatedly while the request is in progress. + +This state is particularly important because the backend may take longer than expected. + +--- + +# 9. Successful Submission + +The backend returns a semantic success response. + +The frontend transitions to: + +```text +┌─────────────────────────────┐ +│ │ +│ ¡PERFECTO! │ +│ │ +│ Tu asistencia ha sido │ +│ confirmada. │ +│ │ +│ Gracias, [Nombre]. │ +│ │ +│ TE VEO EN 00:00:00 │ +│ │ +│ [MAP] │ +│ │ +└─────────────────────────────┘ +``` + +** implementar un counter para la hora y fecha de la fiesta, hora colombia; + +Dirección es un area circular t + +Your proposed: + +> "Perfecto! Has sido registrado, gracias" + +works functionally, but I would make the wording more natural: + +> **¡Perfecto! Tu asistencia ha sido confirmada. Gracias.** + +Or, more personal: + +> **¡Perfecto! Te esperamos. Gracias por confirmar.** + +Again, this should be configurable. + +The frontend should not infer success from HTTP status alone. The API contract should define a semantic result. + +--- + +# 10. Duplicate Submission + +This is an important state. + +For example, the backend determines that the phone number or email already corresponds to an RSVP. + +The frontend displays: + +> **¡UPS!** + +> Parece que ya tenemos tus datos registrados. + +Potentially: + +> Si necesitas modificar tu información, ponte en contacto con nosotros. + +I would **not expose which field caused the duplicate** unless there is a reason to do so. + +For example, don't necessarily tell the user: + +> El correo `foo@example.com` ya está registrado. + +That unnecessarily reveals stored information. + +The frontend only needs to know: + +```text +DUPLICATE_RSVP +``` + +and render the configured message. + +--- + +# 11. Unexpected Error + +The application needs a generic failure state. + +For example: + +> **ALGO SALIÓ MAL** + +> No pudimos registrar tu asistencia. Inténtalo nuevamente. + +With: + +> **INTENTAR DE NUEVO** + +The frontend should distinguish this from validation and duplicate responses. + +Conceptually: + +```text +VALIDATION_ERROR + ↓ +fix form + +DUPLICATE + ↓ +duplicate message + +SUCCESS + ↓ +confirmation + +SERVER_ERROR + ↓ +retry +``` + +This separation is important. + +--- + +# 12. Network Failure + +A network failure should produce essentially the same user-facing state as an unexpected server failure. + +The frontend should not expose: + +```text +500 Internal Server Error +SQLite database locked +Connection refused +FastAPI exception +``` + +Those are implementation details. + +Instead: + +> **No pudimos comunicarnos con el servidor.** + +> Inténtalo nuevamente. + +--- + +# 13. Optional Post-RSVP Information + +After successful registration, the application can expose practical information: + +```text +¡PERFECTO! + +Te esperamos el 28. + +FRESCO RISTORANTE +514 S BRAND BLVD. +GLENDALE, CA + +[ VER UBICACIÓN ] +``` + +I would actually put the location **after successful RSVP**, assuming there isn't a reason guests need the address before responding. + +This creates a nice information hierarchy: + +```text +Invitation + ↓ +RSVP + ↓ +Confirmation + ↓ +Logistics +``` + +--- + +# 14. Invitation Configuration + +The event-specific content should be represented by configuration. + +Conceptually: + +```ts +interface InvitationConfig { + title: string; + invitationText: string; + honoree: string; + + date: string; + time: string; + + rsvp: { + title: string; + cta: string; + + fields: { + name: FieldConfig; + phone: FieldConfig; + email: FieldConfig; + }; + + submitLabel: string; + }; + + messages: { + success: string; + duplicate: string; + validation: string; + error: string; + }; + + location?: { + name: string; + address: string; + mapsUrl?: string; + }; +} +``` + +The exact implementation language/framework is irrelevant to the specification. + +The important requirement is: + +**changing event content must not require modifying presentation components.** + +--- + +# 15. Backend Boundary + +The frontend should have a very small conceptual API. + +For example: + +```text +POST /api/rsvp +``` + +Request: + +```json +{ + "name": "...", + "phone": "...", + "email": "..." +} +``` + +The frontend should only care about semantic responses such as: + +```text +SUCCESS +DUPLICATE +VALIDATION_ERROR +ERROR +``` + +It should not know: + +```text +SQLite +FastAPI +database schema +database IDs +SQL queries +persistence strategy +``` + +That gives you the separation you're looking for. + +The backend can change from SQLite to PostgreSQL later without requiring the invitation UI to change. + +--- + +# 16. Accessibility Requirements + +This is particularly important because the design is highly visual. + +The invitation must still work without relying on visual effects. + +Requirements: + +- semantic HTML + +- keyboard-accessible CTA + +- keyboard-accessible form + +- labels associated with inputs + +- visible focus states + +- sufficient text contrast + +- `aria-live` for submission feedback + +- reduced-motion support + +- screen-reader-friendly error messages + + +### Reduced motion + +If: + +```css +@media (prefers-reduced-motion: reduce) +``` + +is active: + +- disable particle movement + +- disable particle pulsing + +- disable elaborate scrolling animation + +- retain the visual background + +- allow normal browser scrolling + + +The invitation should remain visually attractive as a static composition. + +--- + +# 17. Particle Background Specification + +The background should be implemented independently from the content. + +### Particle properties + +Each particle may have: + +```text +position +radius +opacity +blur +gold intensity +velocity +twinkle speed +twinkle phase +``` + +### Spatial distribution + +High density: + +```text +upper-left +lower-right +``` + +Low density: + +```text +central content region +``` + +### Animation + +Movement should be extremely slow. + +The goal is: + +> "the background is alive" + +rather than: + +> "there is a particle animation." + +The background should never compete with the typography. + +--- + +# 18. Responsive Behavior + +The invitation itself maintains its aspect ratio. + +Conceptually: + +```css +.invitation { + width: min(100%, 480px); + aspect-ratio: ; +} +``` + +Desktop: + +```text + ┌──────────────┐ + │ │ + │ INVITATION │ + │ │ + └──────────────┘ +``` + +Mobile: + +```text +┌────────────────┐ +│ │ +│ INVITATION │ +│ │ +│ │ +└────────────────┘ +``` + +The surrounding page/stage adapts to the viewport. + +No separate desktop artwork is required. + +--- + +# 19. Admin Dashboard + +The dashboard should deliberately be much simpler. + +I would **not attempt to reproduce the invitation aesthetic** here. + +Something like: + +```text +┌──────────────────────────────────────────────────┐ +│ RSVP Dashboard Log out │ +├──────────────────────────────────────────────────┤ +│ │ +│ Responses: 37 │ +│ │ +│ Search: [________________________] │ +│ │ +│ Name Phone Email │ +│ ─────────────────────────────────────────────── │ +│ Ana García 300... ana@... │ +│ Carlos Pérez 311... — │ +│ María López 315... maria@... │ +│ │ +└──────────────────────────────────────────────────┘ +``` + +### Dashboard capabilities + +Minimum viable dashboard: + +- authentication + +- total RSVP count + +- response table + +- name + +- phone + +- email + +- submission timestamp + +- search/filter + + +Potentially later: + +- CSV export + +- delete/cancel RSVP + +- edit RSVP + +- attendance status + +- guest count + + +But those should not be required for v1. + +--- + +# 20. Admin Authentication + +Authentication is a backend concern, but the frontend needs to represent: + +```text +/login +/dashboard +``` + +Unauthenticated users attempting to access the dashboard are redirected to login. + +The dashboard should not rely on hiding the route as its security mechanism. + +The API must enforce authorization independently. + +--- + +# 21. Suggested Application Structure + +I would organize the frontend conceptually like this: + +```text +src/ +├── invitation/ +│ ├── Invitation.tsx +│ ├── InvitationContent.tsx +│ ├── ParticleBackground.tsx +│ ├── RSVPCTA.tsx +│ ├── RSVPForm.tsx +│ └── RSVPResult.tsx +│ +├── admin/ +│ ├── Login.tsx +│ ├── Dashboard.tsx +│ └── RSVPTable.tsx +│ +├── components/ +│ ├── Button.tsx +│ ├── Field.tsx +│ └── ... +│ +├── config/ +│ └── invitation.ts +│ +├── api/ +│ └── rsvp.ts +│ +└── styles/ + ├── invitation.css + ├── particles.css + └── admin.css +``` + +The exact framework doesn't matter; this is primarily a **separation-of-concerns model**. + +--- + +# 22. Guest State Machine + +I would explicitly document this because it gives the frontend implementation a very clear contract: + +```text + ┌──────────────┐ + │ INVITATION │ + └──────┬───────┘ + │ + CTA click + │ + ▼ + ┌──────────────┐ + │ RSVP FORM │ + └──────┬───────┘ + │ + submit + │ + ▼ + ┌──────────────┐ + │ SUBMITTING │ + └──────┬───────┘ + │ + ┌──────────┼───────────┐ + │ │ │ + ▼ ▼ ▼ + SUCCESS DUPLICATE ERROR + │ │ │ + ▼ ▼ ▼ + RESULT RESULT RESULT +``` + +Validation occurs before `SUBMITTING`: + +```text +RSVP FORM + │ + ├── invalid → validation errors + │ + └── valid → SUBMITTING +``` + +This is probably the most important functional artifact in the specification because it makes the frontend/backend boundary explicit. + +--- + +# 23. Things I Think We're Now Missing + +There are only a few things I'd decide before implementation. + +### 1. What happens after successful RSVP? + +I recommend: + +**confirmation + event information + location link** + +rather than simply showing "thanks." + +### 2. Can someone change their RSVP? + +For v1, I'd say **no** unless there is a concrete requirement. + +If someone needs to change their information, provide a contact mechanism rather than building an account system. + +### 3. Can someone bring a guest? + +This needs to be decided because it fundamentally changes the data model. + +If everyone is individually invited, the current form is sufficient. + +If: + +> "Andrés + 1" + +is possible, you'll eventually need a guest-count or companion field. + +### 4. Is the phone number actually necessary? + +If the host genuinely uses it to coordinate the event, keep it required. + +If it's only being collected because "RSVP forms usually ask for phone," I'd reconsider. Collecting less personal information makes the system simpler. + +### 5. What does duplicate mean? + +I'd define it at the API contract level, for example: + +> A submission is considered a duplicate if the normalized phone number already belongs to an existing RSVP, or if a provided email matches an existing RSVP. + +The frontend shouldn't implement that logic. + +--- + +# Final product model + +The complete experience becomes: + +```text + GUEST + │ + ▼ + ┌──────────────────┐ + │ INVITATION │ + │ │ + │ Birthday │ + │ Party │ + │ │ + │ Isabelle Snow │ + │ │ + │ OCT 28 │ + │ 7:00 PM │ + │ │ + │ CONFIRMA TU │ + │ ASISTENCIA ↓ │ + └────────┬─────────┘ + │ + ▼ + ┌──────────────────┐ + │ RSVP FORM │ + │ │ + │ Nombre │ + │ Teléfono │ + │ Email (optional) │ + │ │ + │ TE VEO AHÍ │ + └────────┬─────────┘ + │ + submit + │ + ▼ + ┌──────────────────┐ + │ SUBMITTING │ + └────────┬─────────┘ + │ + ┌───────────┼────────────┐ + ▼ ▼ ▼ + SUCCESS DUPLICATE ERROR + │ │ │ + ▼ ▼ ▼ + "¡Perfecto!" "¡Ups!" "Algo salió + mal" + │ + ▼ + EVENT INFO + │ + ▼ + LOCATION / MAP + + + ADMIN + │ + ▼ + ┌─────────────┐ + │ LOGIN │ + └──────┬──────┘ + ▼ + ┌─────────────┐ + │ DASHBOARD │ + │ │ + │ 37 RSVPs │ + │ │ + │ Name │ + │ Phone │ + │ Email │ + │ Timestamp │ + └─────────────┘ +``` + diff --git a/01-plans/bdinvite/implementation-plan.md b/01-plans/bdinvite/implementation-plan.md new file mode 100644 index 0000000..e18967b --- /dev/null +++ b/01-plans/bdinvite/implementation-plan.md @@ -0,0 +1,915 @@ +--- +type: plan +status: completed +project: bdinvite +tags: + - bdinvite + - react + - fastapi + - traefik + - deployment + - birthday +--- + +# Birthday Invitation App — Implementation Plan + +## Goal + +Build a complete interactive birthday invitation application (`bdinvite`) with: + +- **Guest experience**: A visually rich, mobile-first invitation with animated golden bokeh particles, RSVP form, countdown timer, and map preview — served publicly at `demos.roadtotech.me/birthday/invite` +- **Admin dashboard**: A simple RSVP management and invitation configuration editor, protected by Authelia — served at `demos.roadtotech.me/birthday/admin` +- **Backend**: Lightweight FastAPI service with SQLite (WAL mode), Pydantic validation, and a clean API contract + +Working directory: `Sites/bdinvite` (forge: [bdinvite](https://gitea.roadtotech.me/kiskaadee/bdinvite)) + +--- + +## User Review Required + +> [!IMPORTANT] +> **New infrastructure**: `demos.roadtotech.me` does not currently exist in the homelab. This plan creates Traefik routing for it via docker-compose labels. The wildcard DNS (`*.roadtotech.me`) and TLS certificate already cover it — no Core/NixOS changes needed. + +> [!IMPORTANT] +> **Authelia split routing**: The admin path (`/birthday/admin/*`) will be Authelia-protected via a higher-priority Traefik router. The public path (`/birthday/*`) will be unprotected. Both route to the same container. This is a pattern not yet used in the homelab (all current apps use full-domain Authelia protection or none), so deployment verification is critical. + +> [!WARNING] +> **Static map preview**: The plan uses a static map tile image URL stored in configuration (`map_preview_url`). You'll need to generate or source this image for the actual venue. During development, a placeholder will be used. + +--- + +## Resolved Decisions (from grill-me) + +| Decision | Choice | +|---|---| +| Frontend framework | React + Vite + TypeScript | +| Styling | CSS Modules | +| Particle rendering | Canvas 2D | +| Typography | Google Fonts (Great Vibes / Alex Brush + Montserrat) | +| Container architecture | Single container (multi-stage: Node build → Python runtime) | +| Database | SQLite with WAL mode, volume-mounted | +| Authentication | Authelia-only (ForwardAuth at Traefik level) | +| Routing | Path-based on `demos.roadtotech.me/birthday/*` | +| Traefik split | Two routers: public (no auth) + admin (Authelia) | +| SPA routing | React Router v6 with `basename=/birthday` | +| CTA transition | Smooth scroll + fade | +| Countdown format | `DD : HH : MM : SS` with state transitions | +| Map preview | Static tile image in circular treatment, linking to `mapUrl` | +| Duplicate detection | Normalized phone number uniqueness | +| Phone validation | Colombian format (10 digits, starts with 3, optional +57) | +| Guest +1 | Not supported in v1 | +| Config management | Server-managed (DB-stored, admin-editable, API-served) | +| Admin edit scope | Flat form with text preview; visual design is code-only | +| CSV export | Included in v1 | +| Working directory | `Sites/bdinvite` (canonical) | + +--- + +## Proposed Changes + +### P0 — Project Scaffolding & Infrastructure + +#### [NEW] `app.yaml` + +The `appctl` manifest for service identity and deployment: + +```yaml +name: "bdinvite" +aliases: + - "birthday" + - "invite" +domain: "demos.roadtotech.me" +description: "Interactive Digital Birthday Invitation with RSVP" +visible: true +auth: false # Public route exists; Authelia applied selectively via labels +networks: + - proxy-net +env: + BASE_PATH: "/birthday" +homepage: + title: "Birthday Invite" + group: "Applications" + icon: "party.png" + container: "bdinvite" + weight: 30 +``` + +#### [NEW] `docker-compose.yml` + +Single-container deployment with split Traefik routing: + +```yaml +services: + bdinvite: + build: . + container_name: bdinvite + restart: unless-stopped + volumes: + - ./data:/app/data + environment: + - BASE_PATH=/birthday + networks: + - proxy-net + labels: + - "diun.enable=false" + - "traefik.enable=true" + + # ── Public router (invitation + API) ── + - "traefik.http.routers.bdinvite-public.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday`)" + - "traefik.http.routers.bdinvite-public.entrypoints=websecure" + - "traefik.http.routers.bdinvite-public.tls=true" + - "traefik.http.routers.bdinvite-public.priority=10" + - "traefik.http.routers.bdinvite-public.service=bdinvite-svc" + + # ── Admin router (Authelia-protected) ── + - "traefik.http.routers.bdinvite-admin.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday/admin`)" + - "traefik.http.routers.bdinvite-admin.entrypoints=websecure" + - "traefik.http.routers.bdinvite-admin.tls=true" + - "traefik.http.routers.bdinvite-admin.priority=20" + - "traefik.http.routers.bdinvite-admin.middlewares=authelia-auth@docker" + - "traefik.http.routers.bdinvite-admin.service=bdinvite-svc" + + # ── HTTP → HTTPS redirect ── + - "traefik.http.routers.bdinvite-red.rule=Host(`${SERVICE_DOMAIN:-demos.roadtotech.me}`) && PathPrefix(`/birthday`)" + - "traefik.http.routers.bdinvite-red.entrypoints=web" + - "traefik.http.routers.bdinvite-red.middlewares=https-redirect@docker" + + # ── Service target ── + - "traefik.http.services.bdinvite-svc.loadbalancer.server.port=8000" + +networks: + proxy-net: + external: true +``` + +#### [NEW] `Dockerfile` + +Multi-stage build: Node (build React) → Python (serve with FastAPI): + +```dockerfile +# ── Stage 1: Build React frontend ── +FROM node:20-alpine AS frontend-build +WORKDIR /build +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +# ── Stage 2: Python runtime ── +FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim +WORKDIR /app + +ENV UV_COMPILE_BYTECODE=1 + +COPY backend/pyproject.toml backend/uv.lock* ./ +RUN uv sync --frozen --no-install-project --no-dev + +COPY backend/ . +COPY --from=frontend-build /build/dist ./static + +CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] +``` + +#### [NEW] `.gitignore` + +```gitignore +# Dependencies +frontend/node_modules/ +backend/__pycache__/ +backend/*.pyc + +# Build output +frontend/dist/ + +# Data +data/ + +# Environment +.env +*.env.local + +# IDE +.vscode/ +.idea/ +``` + +--- + +### P1 — Backend (FastAPI + SQLite) + +Directory: `backend/` + +```text +backend/ +├── pyproject.toml +├── app/ +│ ├── __init__.py +│ ├── main.py # FastAPI app, lifespan, static mount +│ ├── config.py # Pydantic Settings +│ ├── database.py # SQLite engine, session, Base +│ ├── models.py # SQLAlchemy models (RSVP, InvitationConfig) +│ ├── schemas.py # Pydantic request/response schemas +│ ├── routes/ +│ │ ├── __init__.py +│ │ ├── rsvp.py # POST /api/rsvp +│ │ ├── config.py # GET /api/config, PUT /api/config +│ │ └── admin.py # GET /api/admin/rsvps, GET /api/admin/export +│ └── services/ +│ ├── __init__.py +│ ├── rsvp.py # RSVP business logic + phone normalization +│ └── config.py # Config CRUD + seed defaults +``` + +#### [NEW] `backend/pyproject.toml` + +```toml +[project] +name = "bdinvite" +version = "0.1.0" +description = "Birthday Invitation RSVP Backend" +requires-python = ">=3.11" +dependencies = [ + "fastapi>=0.115.0", + "uvicorn>=0.30.0", + "sqlalchemy>=2.0.0", + "pydantic>=2.0.0", + "pydantic-settings>=2.0.0", +] + +[dependency-groups] +dev = [ + "httpx>=0.27.0", + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", +] +``` + +#### Database Models + +**RSVP table** (`rsvps`): + +| Column | Type | Constraints | +|---|---|---| +| `id` | INTEGER | PK, autoincrement | +| `name` | TEXT | NOT NULL | +| `phone` | TEXT | NOT NULL, UNIQUE (normalized) | +| `email` | TEXT | nullable | +| `created_at` | DATETIME | NOT NULL, default=utcnow | + +**InvitationConfig table** (`invitation_config`): + +| Column | Type | Notes | +|---|---|---| +| `id` | INTEGER | PK (always 1 — singleton row) | +| `honoree_name` | TEXT | "Isabelle Snow" | +| `event_date` | TEXT | "2026-10-28" | +| `event_time` | TEXT | "19:00" | +| `event_timezone` | TEXT | "America/Bogota" | +| `title` | TEXT | "Birthday Party" | +| `invitation_text` | TEXT | "You're invited to the birthday party honoring" | +| `address_name` | TEXT | "Fresco Ristorante" | +| `address_lines` | TEXT | "514 S Brand Blvd\nGlendale, CA 91204" | +| `map_preview_url` | TEXT | Static map tile image URL | +| `map_url` | TEXT | Google Maps link | +| `rsvp_heading` | TEXT | "¿Nos vemos?" | +| `rsvp_cta` | TEXT | "CONFIRMA TU ASISTENCIA" | +| `submit_label` | TEXT | "TE VEO AHÍ" | +| `msg_success` | TEXT | "¡Perfecto! Tu asistencia ha sido confirmada." | +| `msg_duplicate` | TEXT | "Parece que ya tenemos tus datos registrados." | +| `msg_error` | TEXT | "No pudimos registrar tu asistencia. Inténtalo nuevamente." | +| `updated_at` | DATETIME | | + +#### API Endpoints + +All API routes are mounted under `/birthday/api/`: + +| Method | Path | Auth | Description | +|---|---|---|---| +| `GET` | `/birthday/api/config` | Public | Serves invitation configuration to guest frontend | +| `POST` | `/birthday/api/rsvp` | Public | Submit RSVP (name, phone, email?) | +| `GET` | `/birthday/api/admin/rsvps` | Authelia | List all RSVPs (with optional `?search=` query param) | +| `GET` | `/birthday/api/admin/export` | Authelia | Download CSV of all RSVPs | +| `GET` | `/birthday/api/admin/config` | Authelia | Get full config (same as public, but admin context) | +| `PUT` | `/birthday/api/admin/config` | Authelia | Update invitation configuration | + +#### API Response Contract + +**POST `/birthday/api/rsvp`** request: +```json +{ + "name": "Andrés García", + "phone": "300 123 4567", + "email": "andres@example.com" +} +``` + +**Responses** (all use a `result` discriminator): + +```json +// 201 Created — Success +{ "result": "SUCCESS", "name": "Andrés García" } + +// 409 Conflict — Duplicate +{ "result": "DUPLICATE" } + +// 422 Unprocessable — Validation +{ "result": "VALIDATION_ERROR", "errors": { "phone": "Formato de teléfono inválido" } } + +// 500 — Server error +{ "result": "ERROR" } +``` + +#### Phone Normalization Logic + +```python +import re + +def normalize_phone(raw: str) -> str: + """ + Normalize Colombian phone numbers. + Strips +57 prefix, spaces, dashes, parentheses. + Returns 10-digit number starting with 3. + """ + digits = re.sub(r'[^\d]', '', raw) + if digits.startswith('57') and len(digits) == 12: + digits = digits[2:] + if len(digits) != 10 or not digits.startswith('3'): + raise ValueError("Formato de teléfono inválido") + return digits +``` + +#### Admin Auth Guard + +Admin endpoints validate the `Remote-User` header (injected by Authelia ForwardAuth): + +```python +from fastapi import Header, HTTPException + +def require_admin(remote_user: str | None = Header(None, alias="Remote-User")): + if not remote_user: + raise HTTPException(status_code=401, detail="Not authenticated") + return remote_user +``` + +#### SPA Catch-All + +FastAPI mounts the built React app as static files and provides a catch-all for client-side routing: + +```python +from fastapi import FastAPI +from fastapi.staticfiles import StaticFiles +from fastapi.responses import FileResponse + +app = FastAPI() + +# API routes first (registered before catch-all) +app.include_router(rsvp_router, prefix="/birthday/api") +app.include_router(admin_router, prefix="/birthday/api/admin") +app.include_router(config_router, prefix="/birthday/api") + +# Static assets (JS, CSS, images) +app.mount("/birthday/assets", StaticFiles(directory="static/assets"), name="assets") + +# SPA catch-all: any /birthday/* path serves index.html +@app.get("/birthday/{full_path:path}") +async def spa_catch_all(full_path: str): + return FileResponse("static/index.html") +``` + +--- + +### P2 — Frontend: Guest Invitation (React + Vite + TypeScript) + +Directory: `frontend/` + +```text +frontend/ +├── package.json +├── vite.config.ts +├── tsconfig.json +├── index.html +├── public/ +│ └── (static assets) +├── src/ +│ ├── main.tsx +│ ├── App.tsx +│ ├── api/ +│ │ └── client.ts # fetch wrapper for /birthday/api/* +│ ├── types/ +│ │ └── config.ts # InvitationConfig TypeScript interface +│ ├── hooks/ +│ │ ├── useConfig.ts # Fetch & cache invitation config +│ │ ├── useCountdown.ts # Live countdown against event datetime +│ │ └── useRsvpForm.ts # Form state, validation, submission +│ ├── invitation/ +│ │ ├── Invitation.tsx # Main invitation composition +│ │ ├── InvitationContent.tsx # Title, honoree, date/time display +│ │ ├── ParticleBackground.tsx # Canvas 2D bokeh particles +│ │ ├── RsvpCta.tsx # "CONFIRMA TU ASISTENCIA ↓" +│ │ ├── RsvpForm.tsx # Name, phone, email fields + submit +│ │ ├── RsvpResult.tsx # Success / Duplicate / Error states +│ │ ├── Countdown.tsx # "TE VEO EN DD:HH:MM:SS" +│ │ └── MapPreview.tsx # Circular map preview + link +│ ├── admin/ +│ │ ├── AdminLayout.tsx # Dashboard shell (header, nav) +│ │ ├── RsvpTable.tsx # RSVP list with search + count +│ │ └── ConfigEditor.tsx # Invitation config form + preview +│ ├── components/ +│ │ ├── Button.tsx +│ │ ├── Field.tsx +│ │ └── Spinner.tsx +│ └── styles/ +│ ├── global.module.css +│ ├── invitation.module.css +│ ├── particles.module.css +│ ├── rsvp.module.css +│ ├── result.module.css +│ └── admin.module.css +``` + +#### Vite Configuration + +```typescript +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + base: '/birthday/', + build: { + outDir: 'dist', + assetsDir: 'assets', + }, + server: { + proxy: { + '/birthday/api': 'http://localhost:8000', + }, + }, +}); +``` + +#### React Router Setup + +```tsx +import { BrowserRouter, Routes, Route } from 'react-router-dom'; + +function App() { + return ( + + + {/* Guest routes */} + } /> + + {/* Admin routes */} + }> + } /> + } /> + + + {/* Default redirect */} + } /> + + + ); +} +``` + +--- + +### P3 — Guest Experience: Visual Design + +#### Color Palette + +| Role | Value | Usage | +|---|---|---| +| Background | `#0a0a0a` | Page/invitation base | +| Gold primary | `#d4a843` | Particle glow, accents | +| Gold light | `#f0d68a` | Particle highlights, CTA hover | +| Gold dark | `#8b7332` | Subtle text accents | +| Text primary | `#ffffff` | Headings, body | +| Text secondary | `rgba(255,255,255,0.7)` | Metadata, labels | +| Error | `#e74c3c` | Validation errors | +| Success | `#d4a843` | Confirmation accent | + +#### Typography + +```css +/* Script/display — "Birthday Party", honoree name */ +@import url('https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap'); + +/* Geometric sans-serif — metadata, labels, buttons */ +@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap'); +``` + +| Element | Font | Weight | Size (mobile) | Tracking | +|---|---|---|---|---| +| Title ("Birthday Party") | Great Vibes | 400 | ~3rem | normal | +| Invitation text | Montserrat | 300 | 0.85rem | 0.2em | +| Honoree name | Great Vibes | 400 | ~2.5rem | normal | +| Date/time | Montserrat | 500 | 1.2rem | 0.15em | +| CTA | Montserrat | 400 | 0.8rem | 0.25em | +| Form labels | Montserrat | 300 | 0.75rem | 0.15em | +| Result heading | Montserrat | 600 | 1.5rem | 0.1em | +| Countdown digits | Montserrat | 300 | 1.8rem | 0.05em | + +#### Invitation Layout (Mobile-First) + +```css +.invitation { + width: min(100%, 480px); + min-height: 100vh; + margin: 0 auto; + position: relative; + overflow: hidden; +} +``` + +The invitation is a single scrollable composition: + +```text +┌─────────────────────────────┐ +│ │ +│ [ParticleBackground] │ ← Canvas, position: fixed, z-index: 0 +│ │ +│ ┌─────────────────────────┐ │ +│ │ │ │ +│ │ Birthday Party │ │ ← Great Vibes, ~3rem +│ │ │ │ +│ │ YOU'RE INVITED TO │ │ ← Montserrat 300, tracked +│ │ THE BIRTHDAY PARTY │ │ +│ │ HONORING │ │ +│ │ │ │ +│ │ Isabelle Snow │ │ ← Great Vibes, ~2.5rem +│ │ │ │ +│ │ FRIDAY | OCT 28 | 7PM │ │ ← Montserrat 500, tracked +│ │ │ │ +│ │ CONFIRMA TU ASISTENCIA │ │ ← CTA (interactive) +│ │ ↓ │ │ +│ │ │ │ +│ └─────────────────────────┘ │ +│ │ +│ ┌─────────────────────────┐ │ ← scroll target +│ │ │ │ +│ │ ¿NOS VEMOS? │ │ +│ │ │ │ +│ │ [name field] │ │ +│ │ [phone field] │ │ +│ │ [email field] │ │ +│ │ │ │ +│ │ TE VEO AHÍ │ │ +│ │ │ │ +│ └─────────────────────────┘ │ +│ │ +│ ┌─────────────────────────┐ │ ← replaces form on submit +│ │ │ │ +│ │ ¡PERFECTO! │ │ +│ │ │ │ +│ │ Tu asistencia ha sido │ │ +│ │ confirmada. │ │ +│ │ │ │ +│ │ Gracias, Andrés. │ │ +│ │ │ │ +│ │ · │ │ +│ │ · │ │ +│ │ TE VEO EN │ │ +│ │ 12 : 04 : 37 : 22 │ │ +│ │ │ │ +│ │ · │ │ +│ │ │ │ +│ │ ╭──────╮ │ │ ← circular map preview +│ │ ╭─┤ ├─╮ │ │ ~140px, clip-path: circle() +│ │ │ │ MAP │ │ │ │ +│ │ ╰─┤ ├─╯ │ │ +│ │ ╰──────╯ │ │ +│ │ │ │ +│ │ VER UBICACIÓN ↗ │ │ ← link to mapUrl +│ │ │ │ +│ └─────────────────────────┘ │ +│ │ +└─────────────────────────────┘ +``` + +#### Particle Background Specification + +Canvas implementation details: + +```typescript +interface Particle { + x: number; + y: number; + radius: number; // 2–12px + opacity: number; // 0.1–0.6 + blur: number; // 2–15px (via ctx.shadowBlur) + goldIntensity: number; // 0–1 (hue shift between warm/cool gold) + vx: number; // -0.15 to 0.15 px/frame + vy: number; // -0.15 to 0.15 px/frame + twinkleSpeed: number; // 0.005–0.02 + twinklePhase: number; // 0–2π +} +``` + +Spatial distribution uses a weighted probability that concentrates particles in the upper-left and lower-right quadrants: + +```typescript +function generatePosition(width: number, height: number): [number, number] { + // Bias toward upper-left and lower-right corners + const bias = Math.random(); + if (bias < 0.4) { + // Upper-left quadrant + return [Math.random() * width * 0.5, Math.random() * height * 0.4]; + } else if (bias < 0.8) { + // Lower-right quadrant + return [width * 0.5 + Math.random() * width * 0.5, height * 0.6 + Math.random() * height * 0.4]; + } else { + // Sparse center/other areas + return [Math.random() * width, Math.random() * height]; + } +} +``` + +Particle count: ~120 on desktop, ~80 on mobile (based on `window.innerWidth`). + +`prefers-reduced-motion`: particles are rendered once as a static frame, animation loop does not run. + +#### Countdown Hook + +```typescript +function useCountdown(eventDate: string, eventTime: string, timezone: string) { + // 1. Construct target: "2026-10-28T19:00:00" in America/Bogota + // 2. Convert to UTC milliseconds using Intl.DateTimeFormat or manual offset + // (Colombia = UTC-5, no DST, so offset is always -5h) + // 3. Calculate: target - Date.now() + // 4. Return { days, hours, minutes, seconds, state } + // state: 'counting' | 'in_progress' | 'finished' + // 5. Update every second via setInterval +} +``` + +States: +- `counting`: `TE VEO EN 12 : 04 : 37 : 22` +- `in_progress`: `EVENTO EN CURSO` +- `finished`: `EVENTO FINALIZADO` + +#### Map Preview Component + +```tsx +function MapPreview({ previewUrl, mapUrl }: { previewUrl: string; mapUrl: string }) { + return ( + +
+ Ubicación del evento +
+ VER UBICACIÓN ↗ +
+ ); +} +``` + +CSS for circular treatment: +```css +.mapCircle { + width: 140px; + height: 140px; + border-radius: 50%; + overflow: hidden; + border: 1px solid rgba(212, 168, 67, 0.3); + transition: transform 0.2s ease, border-color 0.2s ease; +} + +.mapLink:hover .mapCircle { + transform: scale(1.05); + border-color: rgba(212, 168, 67, 0.6); +} +``` + +--- + +### P4 — Frontend: Admin Dashboard + +The admin dashboard is a clean, functional interface. No invitation visual effects. + +#### Admin Layout + +```text +┌──────────────────────────────────────────────────┐ +│ 🎂 RSVP Dashboard [Config] │ +├──────────────────────────────────────────────────┤ +│ │ +│ Respuestas: 37 [Descargar] │ +│ │ +│ Buscar: [________________________] │ +│ │ +│ ┌────────────┬──────────────┬───────┬─────────┐ │ +│ │ Nombre │ Teléfono │ Email │ Fecha │ │ +│ ├────────────┼──────────────┼───────┼─────────┤ │ +│ │ Ana García │ 300 123 4567 │ ana@… │ Sep 30 │ │ +│ │ Carlos P. │ 311 987 6543 │ — │ Sep 29 │ │ +│ └────────────┴──────────────┴───────┴─────────┘ │ +│ │ +└──────────────────────────────────────────────────┘ +``` + +#### Config Editor + +```text +┌──────────────────────────────────────────────────┐ +│ 🎂 Configuración [← Volver] │ +├──────────────────────────────────────────────────┤ +│ │ +│ ┌─── Editar ──────────────────────────────────┐ │ +│ │ │ │ +│ │ Nombre del homenajeado │ │ +│ │ [Isabelle Snow ] │ │ +│ │ │ │ +│ │ Fecha del evento │ │ +│ │ [2026-10-28] │ │ +│ │ │ │ +│ │ Hora Zona horaria │ │ +│ │ [19:00] [America/Bogota ] │ │ +│ │ │ │ +│ │ Texto de invitación │ │ +│ │ [You're invited to the birthday...] │ │ +│ │ │ │ +│ │ Nombre del lugar │ │ +│ │ [Fresco Ristorante ] │ │ +│ │ │ │ +│ │ Dirección (una línea por línea) │ │ +│ │ [514 S Brand Blvd ] │ │ +│ │ [Glendale, CA 91204 ] │ │ +│ │ │ │ +│ │ URL preview del mapa │ │ +│ │ [https://tile.openstreetmap.org/...] │ │ +│ │ │ │ +│ │ URL del mapa (Google Maps, etc.) │ │ +│ │ [https://www.google.com/maps/...] │ │ +│ │ │ │ +│ │ ... (CTA, submit label, messages) ... │ │ +│ │ │ │ +│ │ [Guardar cambios] │ │ +│ │ │ │ +│ └─────────────────────────────────────────────┘ │ +│ │ +│ ┌─── Vista previa ───────────────────────────┐ │ +│ │ │ │ +│ │ Birthday Party │ │ +│ │ You're invited to the birthday party... │ │ +│ │ Isabelle Snow │ │ +│ │ FRIDAY | OCT 28 | 7:00 PM │ │ +│ │ FRESCO RISTORANTE │ │ +│ │ 514 S Brand Blvd, Glendale, CA 91204 │ │ +│ │ │ │ +│ └────────────────────────────────────────────┘ │ +│ │ +└──────────────────────────────────────────────────┘ +``` + +The preview is a plain-text rendering of how the fields compose — **not** a visual replica of the invitation with particles and fonts. It shows the content hierarchy so the admin can verify field values before saving. + +--- + +### P5 — Accessibility + +| Requirement | Implementation | +|---|---| +| Semantic HTML | `
`, `
`, `
`, `

`–`

`, `