How zapidan/newsletter-hub works
Project Type and Purpose
• This is a full-stack, cross-platform newsletter management system (“Newsletter Hub”).
• Frontend targets:
• Web (src/web, built with Vite + React + TypeScript)
• Mobile (mobile-app, built with React Native + TypeScript)
• Shared logic/components: src/common
• Backend uses Supabase: database (PostgreSQL), Auth, Edge Functions for email handling, and RLS policies via supabase/functions and supabase/migrations.
• CI/CD pipelines generate test dashboards, coverage reports, and deploy the app.
File Structure Analysis
• Top-level directories:
• mobile-app → React Native application for iOS/Android
• src/web → React web application
• src/common → shared hooks, services, utilities, contexts used by both front and web
• supabase → database schema (migrations) and serverless functions
• scripts → automation (test report generation, CI helpers)
• tests & src/__tests__ → unit, integration, E2E test suites (Vitest, Playwright)
• Config and deployment files: pnpm-workspace.yaml, GitHub workflows, Vite/Vitest configs, Tailwind, ESLint, tsconfig, etc.
Key Components
• Web Client (src/web)
• Mobile Client (mobile-app)
• Shared Library (src/common)
• Supabase Backend:
• Auth Service
• Database (Postgres) with schema migrations
• Edge Functions (handle-email)
• External Services:
• Email provider/inbound processor (invokes Edge Function)
• Hosting/CDN for Web (e.g., Vercel/Netlify/GitHub Pages)
• App Stores for Mobile
• CI/CD & Testing Infrastructure:
• GitHub Actions workflows
• Test Dashboard (static site)
• Coverage reports (html/)
• Playwright & Vitest test runners
Relationships & Data Flows
• User interacts with Web or Mobile → UI components → call shared API layer in src/common/services → Supabase client
• Supabase Auth for login/identity
• Queries/Mutations against Postgres via Supabase
• Real-time updates (optional) via Supabase subscriptions
• Inbound emails trigger Supabase Edge Function → processes and writes to DB
• Webhooks or scheduled tasks (if any) likewise handled by Edge Functions
• CI pipelines run tests → generate dashboards → deploy to GH Pages
Architectural Patterns & Principles
• Monorepo with clear separation: web, mobile, common, backend.
• Shared code drives DRY: src/common exposes contexts, hooks, services to both clients.
• Serverless functions for event-driven processing (email).
• Database migrations for schema evolution.
• Automated testing and reporting integrated into CI.
1) Users & Devices
2) Presentation Tier (Web, Mobile)
3) Application Tier (Shared Library & Supabase Edge Functions)
4) Data Tier (Postgres DB)
• “Supabase JS Client & Auth”
• “Edge Function: handle-email”
e. In Data Tier, place “Postgres (supabase/migrations)”.
• Web/Mobile → Shared Library → Supabase JS Client → Auth/DB
• Email Provider → Edge Function → DB
• CI/CD (GitHub Actions) → Test & Reporting (Test Dashboard, Coverage) → Deployment targets