# Architecture Research **Domain:** FamilySync v1.1 — integration analysis for Operability & Polish milestone **Researched:** 2026-06-10 **Confidence:** HIGH (grounded in actual codebase) ## Standard Architecture ### System Overview ``` ┌──────────────────────────────────────────────────────────────────┐ │ React PWA (apps/pwa/src/) │ │ ┌──────────────┐ ┌──────────────┐ ┌───────────────────────────┐ │ │ │ EventForm.tsx│ │SettingsSheet │ │ [NEW] SetupWizard / │ │ │ │ + reminder │ │ + Admin tab │ │ AdminSettings │ │ │ │ selector │ │ │ │ │ │ │ └──────┬───────┘ └──────┬───────┘ └────────────┬──────────────┘ │ │ │ api/client.ts (typed fetch wrappers) │ │ └─────────┼──────────────────────────────────────┬─┴───────────────┘ │ │ ▼ HTTP / SSE ▼ HTTP ┌──────────────────────────────────────────────────────────────────┐ │ Hono API (apps/api/src/index.ts) │ │ ┌──────────────┐ ┌────────────┐ ┌──────────────────────────────┐│ │ │ routes/ │ │ routes/ │ │ [NEW] routes/admin.ts + ││ │ │ events.ts │ │ push.ts │ │ routes/setup.ts ││ │ │ (enqueue to │ │ │ │ (role-gated credential mgmt, ││ │ │ outbox) │ │ │ │ first-run wizard endpoints) ││ │ └──────┬───────┘ └────────────┘ └──────────────────────────────┘│ │ │ │ │ ┌──────▼──────────────────────────────────────────────────────┐ │ │ │ broker/ │ │ │ │ outboxWorker.ts (15s setInterval + NEW event-driven drain) │ │ │ │ reminderScheduler.ts (1-min setInterval, MODIFIED: per- │ │ │ │ event VALARM lead, variable window) │ │ │ │ poller.ts (5-min setInterval, UNCHANGED) │ │ │ │ vevent.ts [MODIFIED: buildVeventString adds VALARM] │ │ │ │ sync.ts [MODIFIED: extract VALARM -> reminder_lead_minutes] │ │ │ │ crypto.ts (AES-256-GCM, REUSED by admin credential writes) │ │ │ └──────┬──────────────────────────────────────────────────────┘ │ └─────────┼────────────────────────────────────────────────────────┘ │ ▼ ┌──────────────────────────────────────────────────────────────────┐ │ Data layer (apps/api/src/db/) │ │ schema.ts: users (+is_admin), calendars, calendarEvents │ │ (+reminder_lead_minutes), calendarOutbox, │ │ memberCredentials, pushSubscriptions, lists, ... │ │ [NEW] app_config table (setup_complete flag, etc.) │ │ │ │ MariaDB (mariadb:11) + Redis (7-alpine, ioredis for pub/sub) │ └──────────────────────────────────────────────────────────────────┘ ``` ### Component Responsibilities | Component | File | Responsibility | v1.1 Status | | -------------------- | ------------------------------------------- | ---------------------------------------- | --------------------------------------------------- | | Event form | `apps/pwa/src/components/EventForm.tsx` | Create/edit event UI | MODIFY: add reminder selector | | Settings sheet | `apps/pwa/src/components/SettingsSheet.tsx` | Notifications toggle | MODIFY: add Admin section | | API client | `apps/pwa/src/api/client.ts` | Typed fetch wrappers | MODIFY: admin + setup endpoints | | Events route | `apps/api/src/routes/events.ts` | Calendar CRUD, outbox enqueue | MODIFY: pass reminder in payload, signal drain | | Push route | `apps/api/src/routes/push.ts` | VAPID subscription management | UNCHANGED | | VEVENT builder | `apps/api/src/broker/vevent.ts` | iCalendar string construction | MODIFY: add VALARM | | CalDAV sync | `apps/api/src/broker/sync.ts` | Fastmail REPORT -> DB upsert | MODIFY: extract VALARM trigger | | Outbox worker | `apps/api/src/broker/outboxWorker.ts` | CalDAV write-back drain | MODIFY: event-driven trigger subscription | | Reminder scheduler | `apps/api/src/broker/reminderScheduler.ts` | Push reminders for events | MODIFY: variable VALARM-based lead | | Poller | `apps/api/src/broker/poller.ts` | 5-min CalDAV sync | UNCHANGED | | Crypto | `apps/api/src/broker/crypto.ts` | AES-256-GCM encrypt/decrypt | UNCHANGED (reused by admin) | | DB schema | `apps/api/src/db/schema.ts` | Drizzle table definitions | MODIFY: is_admin, reminder_lead_minutes, app_config | | Index / wiring | `apps/api/src/index.ts` | App bootstrap + worker startup | MODIFY: mount admin + setup routes | | [NEW] Admin route | `apps/api/src/routes/admin.ts` | Role-gated credential + calendar mgmt | NEW | | [NEW] Setup route | `apps/api/src/routes/setup.ts` | First-run wizard endpoints + validation | NEW | | [NEW] Admin UI | `apps/pwa/src/components/AdminSettings.tsx` | Member credential UI, shared-cal picker | NEW | | [NEW] Setup wizard | `apps/pwa/src/components/SetupWizard.tsx` | First-run guided bootstrap | NEW | | [NEW] Outbox trigger | `apps/api/src/lib/outboxTrigger.ts` | In-process EventEmitter for drain signal | NEW | | [NEW] CI workflow | `.gitea/workflows/ci.yml` | Lint/typecheck/test on PR | NEW | --- ## Feature Integration Analysis ### (a) Per-Event Reminders: VALARM Authoring + Variable-Lead Scheduling #### Write path — what changes **`apps/pwa/src/components/EventForm.tsx`** — MODIFY Add a "Reminder" `