{"id":51485754,"url":"https://github.com/badbread/simplyraffle","last_synced_at":"2026-07-07T06:04:30.929Z","repository":{"id":341131824,"uuid":"1167871104","full_name":"badbread/simplyraffle","owner":"badbread","description":"Production SaaS — Cloudflare Workers, Next.js 14, Stripe, Docker. Magic-link auth, edge payment validation, weighted random draw. Shipped solo.","archived":false,"fork":false,"pushed_at":"2026-03-04T02:37:30.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-04T06:40:02.926Z","etag":null,"topics":["cloudflare-workers","docker","fundraising","magic-link","nextjs","postgresql","prisma","saas","stripe","tailwindcss","typescript"],"latest_commit_sha":null,"homepage":"https://www.simplyraffle.com","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badbread.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-26T19:19:30.000Z","updated_at":"2026-03-04T02:40:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/badbread/simplyraffle","commit_stats":null,"previous_names":["badbread/breadraffle","badbread/simplyraffle"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/badbread/simplyraffle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbread%2Fsimplyraffle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbread%2Fsimplyraffle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbread%2Fsimplyraffle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbread%2Fsimplyraffle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badbread","download_url":"https://codeload.github.com/badbread/simplyraffle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badbread%2Fsimplyraffle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35216589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-07T02:00:07.222Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","docker","fundraising","magic-link","nextjs","postgresql","prisma","saas","stripe","tailwindcss","typescript"],"created_at":"2026-07-07T06:04:30.223Z","updated_at":"2026-07-07T06:04:30.923Z","avatar_url":"https://github.com/badbread.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimplyRaffle\n\n**Multi-tenant SaaS platform for school and nonprofit raffle events.**\nEach customer gets an isolated instance with their own database, subdomain, and admin panel — provisioned automatically, zero DevOps required on their end.\n\nLive at **[simplyraffle.com](https://www.simplyraffle.com)** · Demo at **[demo.simplyraffle.com](https://demo.simplyraffle.com)**\n\n\u003e Private repository — this README documents the architecture and engineering decisions. Source available on request.\n\n---\n\n## What It Does\n\nManages the full raffle lifecycle: participant onboarding → ticket distribution → prize selection → weighted random draw → winner notification → post-event reporting.\n\n**For administrators:** Dashboard with real-time stats, bulk CSV import (AI-powered column detection), email blasts with scheduling/cooldowns, configurable draw modes, live ceremony screen, and PDF/print reports.\n\n**For participants:** Magic-link access (no passwords, no accounts). Pick prizes, allocate tickets, view odds in real time from any device.\n\n---\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────┐\n│                    Cloudflare DNS                        │\n│              *.simplyraffle.com → Railway                │\n└────────────────────────┬────────────────────────────────┘\n                         │\n         ┌───────────────┼───────────────┐\n         ▼               ▼               ▼\n   ┌───────────┐   ┌───────────┐   ┌───────────┐\n   │  Tenant A │   │  Tenant B │   │  Tenant C │\n   │  Next.js  │   │  Next.js  │   │  Next.js  │\n   │  + Prisma │   │  + Prisma │   │  + Prisma │\n   │  + PG DB  │   │  + PG DB  │   │  + PG DB  │\n   └───────────┘   └───────────┘   └───────────┘\n         │               │               │\n         └───────────────┼───────────────┘\n                         │\n              ┌──────────┴──────────┐\n              │    Shared Infra     │\n              │  Resend (email)     │\n              │  Railway (hosting)  │\n              │  Anthropic (AI)     │\n              └─────────────────────┘\n```\n\n**Isolation model:** Each tenant runs its own container + PostgreSQL database on Railway. No shared data, no cross-tenant access. Provisioning is fully automated via a CLI tool that creates Railway projects, sets env vars, runs migrations, and configures DNS — a new customer is live in under 60 seconds.\n\n---\n\n## Stack\n\n| Layer | Technology |\n|---|---|\n| Framework | Next.js 14 (App Router, Server Components) |\n| Language | TypeScript (strict, zero `tsc` errors across 30k LOC) |\n| Styling | Tailwind CSS |\n| ORM / DB | Prisma 5 · PostgreSQL (8 models, 25 migrations) |\n| Email | Resend (batch API, 7 templates, family grouping) |\n| Auth | iron-session (admin) · magic-link tokens (participants) |\n| AI | Anthropic Claude Haiku (CSV column detection) |\n| Infra | Railway (containers + managed Postgres) · Cloudflare (DNS + SSL) |\n| Validation | Zod (all 54 API routes) |\n\n---\n\n## Engineering Highlights\n\n### Security\n- **Timing-safe secret comparison** (`crypto.timingSafeEqual`) on all service-to-service auth (cron, backups)\n- **CSRF protection** via `X-Requested-With` header enforcement on all mutating requests\n- **iron-session** encrypted cookies with 30-day TTL; middleware verifies on every request\n- **Security headers** on all responses: `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`, `Cache-Control: no-store`\n- **Password reset flow** with time-limited tokens and bcrypt hashing\n- **Student tokens opt-in** — API never returns magic-link tokens unless explicitly requested\n\n### Data Integrity\n- **Atomic transactions** for all multi-step mutations (bulk imports, entry submissions, draw execution, factory reset)\n- **Atomic JSON updates** via raw PostgreSQL `jsonb_set` for email blast history (no read-modify-write races)\n- **Plan-based participant limits** enforced at API level — unknown plan values fail closed to most restrictive tier\n- **Profanity filter** on participant imports\n\n### Performance\n- **Dashboard polling** pauses when tab is hidden, uses `AbortController` to cancel in-flight requests\n- **Batch email API** — 100 emails per Resend call, 400 recipients in ~3 seconds\n- **Conditional timers** — countdown intervals only run when actually needed\n- **Client-side redirect guard** returns `null` during redirect to prevent UI flash\n\n### AI-Powered Import\n- Raw CSV/Excel grid sent to Claude Haiku for header detection and column mapping\n- Confidence scoring with fallback to heuristic matching when no API key\n- Below-threshold imports surface an amber banner with \"Get help\" escalation\n\n### Multi-Tenant Provisioning\n- CLI provisioner creates Railway project + Postgres DB + env vars + DNS in one command\n- Plan limits (`community` / `starter` / `pro`) synced from env vars to DB on every container boot\n- Per-customer overrides via `EXTRA_PARTICIPANTS` env var\n- Automated backup/restore across instances\n\n---\n\n## Scale\n\n| Metric | Count |\n|---|---|\n| TypeScript source files | 168 |\n| Lines of code | 30,000+ |\n| API routes | 54 |\n| React components | 42 |\n| Prisma models | 8 |\n| Database migrations | 25 |\n| Commits | 187 |\n| Development time | ~3 weeks (solo) |\n\n---\n\n## Key Screens\n\n| Screen | What it does |\n|---|---|\n| **Admin Dashboard** | Real-time stats, phase-aware checklist, one-click draw |\n| **Setup Wizard** | Guided first-run configuration (enforced for new instances) |\n| **Participant Import** | AI-powered CSV parsing with confidence scoring |\n| **Prize Management** | Drag-to-reorder, image uploads, per-prize ticket limits |\n| **Live Ceremony** | Projector-ready draw animation with round-by-round reveals |\n| **Student Portal** | Mobile-first ticket allocation with real-time odds display |\n| **Reports** | PDF-ready summary, unused ticket reminders, draw audit log |\n| **Settings** | Branding, scheduling, email templates, draw mode configuration |\n\n---\n\n## Draw Modes\n\n| Mode | Behavior |\n|---|---|\n| **Open** | Anyone can enter any prize regardless of ticket balance |\n| **Fair First** | Students who haven't won yet get priority in early rounds |\n| **Exclusive** | Only students with allocated tickets are eligible |\n\nAll modes use cryptographically weighted random selection proportional to ticket allocation.\n\n---\n\n\u003e Source available on request for code review or technical discussion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbread%2Fsimplyraffle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadbread%2Fsimplyraffle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadbread%2Fsimplyraffle/lists"}