# Confexe — Architecture

**Confexe** is a multi-tenant conference operating system: create, manage, promote, operate, and close conferences (physical / virtual / hybrid) from one platform.

## 1. System overview

```
Platform → Organizations → Conferences → Tracks → Sessions → Participants
```

- **Single Next.js 16 app** (App Router, TypeScript, Tailwind 4) serving three surfaces:
  1. **Public surface** — landing page, auto-generated conference websites (`/c/[slug]/…`), registration, digital tickets, certificate verification.
  2. **App surface** — role-based dashboards (`/dashboard`, `/me`, `/admin`) behind session auth.
  3. **API surface** — REST endpoints under `/api/v1/…` (API-first: everything the UI does goes through server actions or these routes).
- **Prisma 6 + SQLite** (`prisma/dev.db`). Deliberately pinned: Prisma 7 broke `url` in schema files. SQLite → no Prisma enums; statuses are strings whose allowed values live in `src/lib/constants.ts`.
- **Server actions** carry most mutations (like MindWell); REST routes exist for integration-shaped things (check-in scan, ticket lookup, webhook-shaped payment confirm).
- Payments are a **Razorpay/Stripe-shaped mock** (`Payment` rows with gateway/txn fields) — swap `src/lib/payments.ts` for a real gateway adapter later.
- Files (logos/banners/photos) are URL fields seeded with placeholder images; object storage adapter is a later phase.

## 2. Tenancy & RBAC

- `Organization` owns `Conference`s. `OrgMember(role)` scopes org access; `ConfMember(role)` scopes per-conference access.
- Platform roles on `User.platformRole`: `SUPER_ADMIN | USER`.
- Conference roles: `ORGANIZER, CO_ORGANIZER, EVENT_MANAGER, SPEAKER, MODERATOR, SPONSOR, VOLUNTEER, REVIEWER, FINANCE_MANAGER, CONTENT_MANAGER` (attendees are `Registration`s, not members).
- Permission checks: `src/lib/rbac.ts` exposes `can(user, conference, action)`; every server action and dashboard layout calls it. Data isolation = every query filters by `conferenceId`/`orgId` derived from the caller's memberships, never from client input alone.

## 3. Core lifecycle wiring (not disconnected CRUD)

```
Registration → Payment → Ticket(QR) → Check-in → Attendance → Feedback → Certificate → Analytics
CFP Submission → Review → Acceptance → Speaker → Session → Schedule → Proceedings
Sponsor → Tier/Package → Payment → Visibility on public site → Analytics
```

Each arrow is a foreign key + status transition recorded in `AuditLog`.

## 4. Entity map (Prisma models)

| Domain | Models |
|---|---|
| Identity | `User`, `AuthSession`, `Organization`, `OrgMember`, `ConfMember` |
| Conference | `Conference`, `Track`, `Room`, `Session`, `Speaker`, `SessionSpeaker`, `Announcement` |
| Registration | `TicketType`, `Coupon`, `Registration`, `Payment`, `CheckIn`, `ScheduleItem` (personal agenda) |
| CFP | `Submission`, `Review` |
| Commercial | `Sponsor` |
| Post-event | `Feedback`, `Certificate` |
| Platform | `Notification`, `AuditLog` |

Status vocabularies (strings, see `constants.ts`):
- Conference: `DRAFT → PUBLISHED → LIVE → COMPLETED → ARCHIVED`
- Registration: `PENDING → CONFIRMED → CANCELLED`
- Payment: `CREATED → SUCCESS | FAILED → REFUNDED`
- Submission: `DRAFT → SUBMITTED → UNDER_REVIEW → REVISION_REQUIRED → ACCEPTED | REJECTED → SCHEDULED`

## 5. Route map

```
/                       platform landing + published conference directory
/login /signup          auth (email+password, bcrypt, httpOnly session cookie)
/c/[slug]               conference public site: home
  /schedule /speakers /sponsors /register /faq
  /ticket/[code]        digital ticket (QR)
/verify/[certId]        public certificate verification
/me                     attendee portal: tickets, my schedule, certificates
/dashboard              organizer home (conferences + stats)
/dashboard/conferences/new
/dashboard/c/[id]/      workspace: overview, registrations, agenda, speakers,
                        tickets, checkin, submissions, sponsors, certificates,
                        announcements, settings
/admin                  super-admin: platform stats, users, conferences, audit log
/api/v1/…               REST: conferences, registrations, checkin, tickets
```

## 6. Scheduling engine

Sessions carry `roomId + startAt + endAt`. Conflict rule enforced at write time: same room, overlapping interval → reject; same speaker double-booked → warn. Agenda renders day-wise / track-wise groupings; attendees bookmark sessions into `ScheduleItem`.

## 7. Certificates

`Certificate(certId = CFX-CERT-xxxxxxxx)` rows generated per confirmed (or checked-in) registration / speaker / volunteer. Public verification at `/verify/[certId]`; printable A4 landscape view with QR pointing back to the verification URL.

## 8. Build phases

- **Phase 1 (this build)**: auth, orgs, conference creation, public site, registration + ticketing + mock payments, QR tickets.
- **Phase 2 (this build)**: agenda builder w/ conflict detection, speakers, check-in, certificates, announcements, attendee portal, admin.
- **Phase 3 (schema + basic UI)**: CFP submissions, reviews, sponsors.
- **Phase 4–6 (future)**: streaming integrations, live Q&A/polls (WebSocket layer), AI assistant (semantic search over sessions/speakers), real gateways, object storage, queue workers, multi-region.

Run: `npm run dev` → http://localhost:3300 · Reseed: `npm run db:seed`
