How rytkhs/event-pay works
Project Type and Purpose
• This is a full-stack, server-rendered web application (“みんなの集金 / EventPay”) built on Next.js 14’s App Router, deployed to Cloudflare Workers via OpenNext.
• It serves small community event organizers by providing event management, attendance tracking, payment collection (via Stripe Connect), reminder emails and balance monitoring.
Core Architectural Layers
a. Presentation Layer (app/)
• Next.js pages, Server Actions and API routes under app/
• Marketing, auth, dashboard, events, guest, invite, payments, payouts, settings, public/legal, error pages
b. Feature Layer (features/)
• Organized by domain: auth, events, guest, invite, payments, settlements, stripe-connect, settings
• Each has actions, components, hooks, services, validation and type definitions
c. Domain/Core Layer (core/)
• Domain models, constants, types, utilities, ports/interfaces, services (payment, settlement, stripe-connect), notification & logging, security, rate-limit, session management, analytics
• Implements hexagonal/clean-architecture patterns: core defines interfaces (ports) and domain logic, adapters in features or core/stripe, core/services implement business rules
d. Infrastructure/Integrations
• Supabase (Postgres) for BaaS: auth, database CRUD, RLS, migrations under supabase/
• Stripe (Checkout, Connect, Webhooks) for payments
• Upstash Redis for rate limiting (@upstash/ratelimit)
• Email service and Slack notifications via core/notification and Resend API
• Cloudflare R2 for incremental caching (open-next.config.ts)
• GitHub Actions for scheduled cron tasks (send reminders, monitor balance) hitting /api/cron/* routes
Main Components
• End users (organizers in dashboard, participants/guests via invite links, public visitors)
• Cloudflare Workers Edge (OpenNext worker.js)
• Next.js App Router & Server Actions
• API Routes / Serverless Functions:
• /api/payments/verify-session
• /api/webhooks/{stripe, stripe-connect}
• /api/cron/{send-reminders, monitor-platform-balance}
• /api/workers/*
• Feature modules orchestrating core services
• Core domain services & adapters
• Supabase Postgres DB
• Upstash Redis
• Stripe Connect & Stripe API
• Email/Slack notification endpoints
• GitHub Actions scheduler
Component Interactions and Data Flows
a. User Request Flow
User Browser → DNS → Cloudflare Workers (edge) → Next.js Router
→ Server-Side Rendering or Server Action
→ Feature layer → Core service → Supabase or External API
→ Response → Edge Cache / CDN → Browser
b. Payment Flow
Dashboard initiates checkout → Next.js Server Action calls Stripe API
→ Redirect to Stripe Checkout → Stripe → Webhook POST → /api/webhooks/stripe route
→ Core webhook handler → Update Supabase, trigger email via core/notification
c. Cron Tasks
GitHub Actions → HTTP POST to /api/cron/send-reminders and /api/cron/monitor-platform-balance
→ Cloudflare Worker → Next.js API Route → core/notification → dispatch emails & Slack alerts
d. Rate Limiting & Security
Requests pass through Upstash Redis rate limiter (core/rate-limit/client.ts)
Security headers applied in next.config.mjs; CSP, HSTS, Permissions-Policy
Architectural Patterns and Principles
• Clean / Hexagonal Architecture: core/ defines ports and domain logic, features/ and core/stripe-connect/adapters implement adapters
• Separation of concerns: Presentation (app/), Features, Core Domain, Infrastructure
• Serverless microservices style: each API route is an independent serverless function
• Edge-first: via Cloudflare Workers + R2 incremental caching for SSR and static assets