How vishesh1111/cep works
1. Purpose and Runtime
Campus Events is a full-stack Next.js 14 App Router application for student event discovery, registration, QR-ticket attendance, and administrator event operations. It runs TypeScript/React on Node.js, is intended for Vercel deployment, and uses Supabase Cloud for PostgreSQL, Auth, Storage, RLS, and realtime-oriented data updates. Primary app entry points are src/app/page.tsx, src/app/layout.tsx, and src/middleware.ts.
2. Route and Access Composition
Routes are partitioned into unauthenticated auth flows and authenticated main flows. Auth pages cover login, registration, password reset, and Supabase callback completion under src/app/(auth)/layout.tsx and src/app/auth/callback/route.ts. The authenticated shell is src/app/(main)/layout.tsx; middleware and Supabase middleware utilities enforce session-aware navigation at src/middleware.ts and src/lib/supabase/middleware.ts.
3. Supabase Integration and Authorization Boundary
Supabase clients are separated by execution context: browser client, server client, and middleware session handling in src/lib/supabase/client.ts, src/lib/supabase/server.ts, and src/lib/supabase/middleware.ts. Database access is constrained by Supabase RLS and schema policies. The generated/application database contract is represented in src/types/database.ts; foundational schema and policies begin in supabase/migration.sql, with additive access/feature migrations in files such as supabase/admin-invitations.sql.
4. Student Event Lifecycle
Students browse/filter event listings, inspect event details, register, receive a QR-backed registration, and track attendance through dashboard views. Primary route surfaces are src/app/(main)/events/page.tsx, src/app/(main)/events/[id]/page.tsx, and src/app/(main)/dashboard/page.tsx. Server actions implement event retrieval and registration/waitlist transitions in src/lib/actions/events.ts, src/lib/actions/registration.ts, and src/lib/actions/waitlist.ts. Database-side atomic seat handling prevents overbooking and supports waitlist promotion.
5. Admin Operations Plane
Admin-only pages provide event creation/editing, registration oversight, invitations, announcements, analytics, and check-in. Key routes are src/app/(main)/admin/page.tsx, src/app/(main)/admin/events/page.tsx, and src/app/(main)/admin/check-in/page.tsx. Corresponding server-side command boundaries are organized by domain in src/lib/actions/admin-registrations.ts, src/lib/actions/admin-invitations.ts, and src/lib/actions/announcements.ts. UI components in src/components/admin/event-form.tsx and src/components/admin/analytics-charts.tsx are the primary interactive interfaces.
6. QR Attendance and Certificates
Registration records carry unique QR values; admins submit scanned/manual values to the check-in action, which validates and records attendance. The scanner supports camera and jsQR paths through src/components/admin/qr-scanner.tsx, src/components/admin/qr-scanner-jsqr.tsx, and src/lib/actions/checkin.ts. Certificate generation is exposed as a route handler at src/app/api/certificate/[registrationId]/route.ts, backed by React/PDF composition in src/lib/pdf/certificate.tsx.
7. API, Communications, and Operations
Most mutations use Next.js server actions rather than a broad REST API. Route handlers exist for externally consumable or operational functions: certificate download, email dispatch, seeding, and diagnostic checks at src/app/api/email/route.ts, src/app/api/seed/route.ts, and src/app/api/check-events/route.ts. Docker support is supplied by Dockerfile and docker-compose.yml; database setup and seeded development data are maintained under supabase/migration.sql and supabase/seed.sql.
Main entry points: client.ts Context clients · layout.tsx Authenticated shell · middleware.ts Session navigation · page.tsx Events & dashboard
Components 19
Next.js application
- App entry & layout · Root page and layout establish the application shell.
src/app/page.tsx - Auth routes · Login, registration, reset, and callback flows.
src/app/(auth)/layout.tsx - Authenticated shell · Shared protected application layout.
src/app/(main)/layout.tsx - Session navigation · Enforces session-aware navigation.
src/middleware.ts - Certificate download · Generates certificates for registrations.
src/app/api/certificate/[registrationId]/route.ts - Certificate PDF
src/lib/pdf/certificate.tsx - Operational APIs · Email dispatch, seed, and diagnostic endpoints.
src/app/api/email/route.ts
Student lifecycle
- Events & dashboard · Browse, detail, registration, and attendance views.
src/app/(main)/events/page.tsx - Event retrieval
src/lib/actions/events.ts - Registration & waitlist · Creates registrations and manages waitlist transitions.
src/lib/actions/registration.ts
Admin operations
- Admin pages · Event operations, oversight, invitations, analytics, and check-in.
src/app/(main)/admin/page.tsx - Admin commands · Registration, invitation, and announcement commands.
src/lib/actions/admin-registrations.ts - Admin forms & analytics
src/components/admin/event-form.tsx - QR scanner · Supports camera and jsQR scanning paths.
src/components/admin/qr-scanner.tsx - Attendance check-in · Validates QR values and records attendance.
src/lib/actions/checkin.ts
Supabase Cloud
- Context clients · Separate browser, server, and middleware clients.
src/lib/supabase/client.ts - Postgres, Auth & Storage · Cloud data, identity, storage, and realtime services.
- Schema & RLS policies · Policies constrain access; database logic handles seats and promotion.
supabase/migration.sql - Database contract
src/types/database.ts
Connections 23
- App entry & layout → Auth routes: hosts
- App entry & layout → Authenticated shell: hosts
- Session navigation → Auth routes: routes sessions
- Session navigation → Authenticated shell: protects
- Session navigation → Context clients: uses middleware client
- Authenticated shell → Events & dashboard: contains
- Authenticated shell → Admin pages: contains
- Events & dashboard → Event retrieval: loads events
- Events & dashboard → Registration & waitlist: registers
- Event retrieval → Context clients: queries through
- Registration & waitlist → Context clients: mutates through
- Admin pages → Admin forms & analytics: renders
- Admin forms & analytics → Admin commands: submits
- Admin pages → QR scanner: uses
- QR scanner → Attendance check-in: submits QR value
- Admin commands → Context clients: mutates through
- Attendance check-in → Context clients: records through
- Certificate download → Certificate PDF: renders
- Certificate download → Context clients: loads registration
- Context clients → Postgres, Auth & Storage: accesses
- Postgres, Auth & Storage → Schema & RLS policies: enforces
- Database contract → Postgres, Auth & Storage: models
- Operational APIs → Context clients: operates through