- docs/README.md: navigation hub - docs/architecture.md: system overview, tech stack, data flows, ports - docs/backend/: supabase-core, schema, rpcs, rls, seed, docker - docs/frontend/: app-structure, screens, api-client - docs/next-steps.md: Phase 2/3/4 plan + open decisions - Fix README demo-account emails to match the actual seed
4.7 KiB
App Structure
Entry point, global state (contexts), the event hook, the tab shell, and the demo clock. For individual screens see screens.md; for the data layer see api-client.md.
Entry & providers (main.tsx, App.tsx)
App wraps everything in two providers, then renders the Shell:
<ToastProvider>
<AuthProvider>
<Shell />
</AuthProvider>
</ToastProvider>
ToastProvider— outermost, so any component (including auth) can show a toast.AuthProvider— holds the session + profile (below).Shell— decides what to render based on auth state (below).
AuthContext (context/AuthContext.tsx)
Holds the Supabase session, the current Profile, and a loading flag.
- On mount, reads the persisted session (
supabase.auth.getSession()) and loads the profile for that user id. - Subscribes to
onAuthStateChangeso login/logout anywhere updates the context. loadProfile(userId)fetchesprofileswhereid = userId(RLS returns only the caller's own row — see ../backend/rls.md).- Exposes:
session,user,profile,loading,refreshProfile(),signOut().
The profile is the app's source of truth for the current user's
roleandpoints. After any points-changing action, screens callrefreshProfile()to re-fetch.
ToastContext (context/ToastContext.tsx)
Transient, auto-dismissing toasts. useToast().toast(message, 'ok' | 'err').
Used for login success, connection results, check-in results, and RPC errors.
The event hook (lib/useEvent.ts)
Loads the agenda once and exposes it in a convenient shape:
interface EventData {
slots: { slot: Slot; sessions: Session[] }[]; // grouped, ordered by slot id
sessionById: Map<string, Session>;
slotById: Map<number, Slot>;
now: Date; // the (simulated) event clock
loading: boolean;
error: string | null;
}
- Calls
getAgenda()(theget_agenda()RPC) and groups the flat rows withgroupAgenda()(see api-client.md). - Every screen that needs the schedule calls
useEvent()— the agenda is fetched per screen mount (cheap, and keeps each screen self-contained).
The event clock (lib/time.ts)
The app uses a simulated "now" so the demo always looks mid-event:
export const EVENT_DATE = '2026-10-23';
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
At 10:20, Slot 1 (09:00–09:45) is done and Slot 2 (10:00–10:45) is
now — matching the mockup. Helpers:
| Function | Returns |
|---|---|
slotStatus(slot, now) |
'done' | 'now' | 'next' |
fmtTime(time) |
"09:00" from "09:00:00" |
fmtRange(slot) |
"09:00–09:45" |
greeting(now) |
"Good morning" / "afternoon" / "evening" |
This is a frontend-only concern. The database stores real slot times; the clock just decides which slot is "live" for display. To use the real clock, replace
DEFAULT_NOWwithnew Date().
The Shell (App.tsx)
The Shell is the navigation container. Render logic, in order:
loading→ full-screen spinner.- No session / no profile →
<Login />(full screen, no tab bar). feedbackSessionset →<Feedback />full-screen takeover (no tab bar).- Otherwise → the active tab + the bottom tab bar.
Tabs
| Tab id | Label | Screen | Notes |
|---|---|---|---|
home |
🏠 Home | Home |
default tab |
agenda |
📅 Agenda | Agenda |
|
scan |
📷 Scan / Check-in | Scan |
label is role-aware (below) |
connections |
🤝 Connect | Connections |
|
profile |
👤 Profile | Profile |
- Role-aware Scan tab: if
profile.roleisstafforadmin, the tab label is "Check-in" and theScanscreen defaults to staff mode. Otherwise it's "Scan". - Leaderboard is not a tab — it's reached from the Home points pill and the
Home quick-actions. It renders as a tab in the shell but is opened via
go('leaderboard'). - Feedback is a full-screen takeover (no tab bar), opened from the Agenda
session sheet via
openFeedback(sessionId).
Shared UI components (components/ui.tsx)
| Component | Purpose |
|---|---|
Avatar |
Colored initials circle (color derived from a hash of the id) |
Spinner |
Loading indicator |
Empty |
Empty-state placeholder (icon + text) |
Sheet |
Bottom-sheet modal (backdrop + grab handle) |
QrImage |
Renders a string (e.g. a QR token) as a scannable QR (qrcode.react) |
Scanner |
Camera QR scanner (html5-qrcode) with a manual-entry fallback and a hasCamera guard (headless/no-camera environments fall back to typing the code) |