A Self-Healing Event Management System for Community Reading Sessions
The Reading Room Engine is an autonomous orchestration system that replaces manual event management chaos with "Calm-Tech." Built for a weekly community reading event in Ahmedabad, it handles 400-600 registrations and manages a queue-based invitation system with zero organizer intervention.
Before: Organizers manually processed 600 Google Form entries, texted 100 people individually, tracked RSVPs in spreadsheets, and chased down replacements when someone cancelled.
After: Users click "Register" on Monday. The system auto-invites the first 100, sends reminders, handles cancellations, and promotes waitlist membersβall automatically.
- One-Click Registration: Join the queue every Monday (9 AM - 11:59 PM IST)
- Automatic Invitations: Get notified when a spot opens (first 100 guaranteed)
- 24-Hour Response Window: Accept or decline with live countdown timer
- Self-Healing Waitlist: If you decline, the next person is instantly promoted
- Attendance Tracking: Mark yourself present during the event
- Book Reviews: Share what you read and your experience (optional)
- VIP Management: Maintain a permanent allowlist that auto-confirms
- One-Click Rollout: Start the invitation waterfall with a single button
- Kill Switch: Pause all automation instantly (emergency or venue changes)
- Attendee Dashboard: View all 100 confirmed guests + their details
- Feedback Curation: Select reviews to feature on the public portfolio
- Manual Overrides: Add 101st+ guests outside the automation
- Dynamic CTAs: "Register Now" (Monday) β "See What We're Reading" (Sunday)
- Live Library: Browse book reviews during event hours
- Community Story: Learn about the Reading Room philosophy
- Featured Feedback: See curated testimonials from past events
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PUBLIC PORTFOLIO β
β (Next.js App Router - SSR + Dynamic CTAs) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββ΄βββββββββββββ
β β
βββββββββΌβββββββββ βββββββββββΌβββββββββββ
β READER PORTAL β β ADMIN PORTAL β
β β’ Dashboard β β β’ Event Manager β
β β’ Profile β β β’ VIP List β
β β’ Feedback β β β’ Rollout Control β
βββββββββ¬βββββββββ βββββββββββ¬βββββββββββ
β β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌβββββββββββββββββ
β SUPABASE BACKEND β
β β’ PostgreSQL Database β
β β’ Row Level Security β
β β’ Edge Functions β
β β’ Realtime Subscriptions β
ββββββββββββββ¬βββββββββββββββββ
β
ββββββββββββββΌβββββββββββββββββ
β WATERFALL ENGINE β
β β’ Auto-Promotion Logic β
β β’ Expiry Cron Jobs β
β β’ Email Notifications β
βββββββββββββββββββββββββββββββ
The core automation that runs invisibly in the background:
- Trigger: User declines, timer expires, or admin removes someone
- Query: Find next person in
WAITINGstatus (ordered by queue position) - Promote: Change status to
INVITED, start 24-hour timer - Notify: Send email + push notification with venue details
- Repeat: Loop continues until all 100 seats are filled
Self-Healing: If someone cancels at 11:59 PM Saturday, the system instantly promotes the next personβno human intervention required.
users # Supabase Auth (email + role)
βββ profiles # Public info (name, bio, VIP flag)
events # Weekly reading sessions
βββ venue # Location details (JSONB)
βββ city # 'Ahmedabad' (future-proofed)
βββ status # 'draft' | 'open' | 'rolled_out' | 'completed'
registrations # The Queue + State Machine
βββ status # 'WAITING' | 'INVITED' | 'CONFIRMED' | 'DECLINED' | 'EXPIRED'
βββ queue_position # Event-scoped, auto-assigned
βββ expires_at # 24-hour countdown
book_reviews # User-submitted reads
event_feedback # Private ratings (admin-curated for portfolio)
vip_list # Admin-managed allowlistKey Constraints:
- One registration per user per event
- Email editing locked during
INVITED/CONFIRMEDstates - Queue positions unique per event
- Automatic expiry via database triggers
See DATABASE_SCHEMA.md for full SQL.
- Node.js 18+
- pnpm (recommended) or npm
- Supabase account (supabase.com)
- Resend account for emails (resend.com)
git clone <repository-url>
cd my-app
pnpm installCreate .env.local:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Email (Resend)
RESEND_API_KEY=re_your_api_key
# App Config
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_EVENT_TIMEZONE=Asia/Kolkata
NEXT_PUBLIC_DEFAULT_CITY=Ahmedabad# Run migrations
pnpm supabase db push
# Seed test data (optional)
pnpm supabase db seedpnpm supabase functions deploy waterfall
pnpm supabase functions deploy expire-invites
pnpm supabase functions deploy send-reminderspnpm dev
# Open http://localhost:3000| Document | Description |
|---|---|
| ARCHITECTURE.md | System design, data flows, security model |
| DATABASE_SCHEMA.md | Complete SQL schema + triggers |
| API_REFERENCE.md | REST endpoints + Edge Functions |
| DEPLOYMENT.md | Production deployment guide |
| CONTRIBUTING.md | Development workflow + code standards |
- Readers: Passwordless magic link (email-only)
- Admins: Email + password with forgot password flow
- Sessions: httpOnly cookies (XSS-proof)
- Role-Based Access Control (RBAC) via Supabase RLS
- Middleware route protection
- CSRF tokens on all mutations
- Rate limiting (Upstash Redis)
- Server-side queue position assignment
- Database-level email lock during invitations
- IP throttling for registration endpoints
- PostgreSQL transactions (SERIALIZABLE isolation)
- Unique constraints on user+event pairs
- Immutable audit logs for admin actions
- Framework: Next.js 14 (App Router)
- Language: TypeScript 5.0+
- Styling: Tailwind CSS 3.4+
- State: TanStack Query (React Query)
- Forms: React Hook Form + Zod validation
- Database: PostgreSQL (Supabase)
- Auth: Supabase Auth (magic link + password)
- Storage: Supabase Storage (future: profile pictures)
- Functions: Supabase Edge Functions (Deno runtime)
- Email: Resend (transactional emails)
- Push: Web Push API (service workers)
- Cron: Supabase Cron (timer expiry checks)
- Hosting: Vercel (Next.js) + Supabase (backend)
- Analytics: Vercel Analytics (optional)
- Monitoring: Sentry (error tracking, optional)
09:00 AM IST β Registration opens
β Queue positions auto-assigned
β VIPs auto-promoted to INVITED
11:59 PM IST β Registration closes
β Admin clicks "Roll Out"
β First 100 non-VIPs promoted to INVITED
β 24-hour timers start
β Invitation emails sent
Continuous β Waterfall monitors for vacancies
β Users click YES (β CONFIRMED) or NO (β DECLINED)
β Expired invites auto-marked (β EXPIRED)
β Next waitlist members promoted instantly
β 30-min reminder emails sent before expiry
Event Hours β "I Am Here" button activates
β Users mark attendance (β ATTENDED)
β Feedback form unlocks (book review + rating)
β Public "Live Library" page shows current reads
12:00 AM IST β Previous event marked as COMPLETED
β New event auto-created (future feature)
β Email locks released for all users
β Reliability scores updated (future feature)
my-app/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (auth)/ # Protected routes
β β β βββ admin/ # Admin portal
β β β βββ reader/ # User dashboard
β β βββ (public)/ # Public portfolio
β β βββ api/ # API routes
β βββ components/ # React components
β β βββ admin/
β β βββ reader/
β β βββ portfolio/
β β βββ shared/
β βββ lib/ # Utilities
β βββ supabase/ # DB clients
β βββ auth/ # Session management
β βββ utils/ # Helpers
βββ supabase/
β βββ functions/ # Edge Functions
β βββ migrations/ # SQL schemas
βββ docs/ # Documentation
pnpm dev # Start dev server
pnpm build # Build for production
pnpm start # Run production build
pnpm lint # Run ESLint
pnpm type-check # TypeScript validation
pnpm test # Run tests (future)pnpm supabase db reset # Reset database
pnpm supabase db push # Apply migrations
pnpm supabase db diff # Generate migration
pnpm supabase gen types ts # Generate TypeScript types- City selector in portfolio
- Timezone-aware scheduling
- Separate admin dashboards per city
- User profiles with reading history
- Book recommendations engine
- "Find Reading Buddies" matching
- Reliability scores (attendance tracking)
- Predictive no-show algorithms
- Capacity optimization suggestions
- React Native app (iOS + Android)
- Push notifications (native)
- Offline mode for feedback forms
We welcome contributions! Please read CONTRIBUTING.md for:
- Code style guidelines
- Branch naming conventions
- Pull request process
- Testing requirements
This project is proprietary software. All rights reserved.
Contact: Contact Form
- Founding Team: The visionaries who created The Reading Room
- Community: 600+ weekly readers who trust the system
- Contributors: Developers who make the magic happen
- Technical Issues: Create a GitHub issue
- Event Questions: Contact organizers via portfolio
- Security Concerns: Email security@yoursite.com
Built with β€οΈ for the Reading Room Community
Last Updated: December 31, 2025