How zainulabedeen123/best-saas-kit works
Project Type & Purpose
• This is a full‐stack SaaS starter kit built with Next.js 15 (App Router + Server Actions), TypeScript, Tailwind CSS, and shadcn/ui.
• It provides user authentication (Supabase), subscription billing (Stripe), email notifications (Resend), and even an AI‐powered chat endpoint.
High‐Level File Structure Analysis
• src/app/ – Next.js App Router pages and API routes:
• /api/ – Serverless endpoints for AI chat, payments (create/cancel sessions), credits, email, Stripe webhooks
• /auth/ – Auth pages (login, reset/update password), callback routes
• /dashboard/ – Protected dashboard pages (analytics, billing, profile)
• Top-level pages (/, /pricing, /features, /docs)
• src/components/ – Reusable UI components for auth flows, dashboard, common UI cards.
• src/lib/ & src/utils/ – Business‐logic helpers: email templates & sending, Supabase client/server wrappers.
• supabase/migrations/ – SQL scripts to build your Postgres schema (users, profiles, subscriptions, credits).
• configuration files – Next.js (next.config.js), Tailwind (tailwind.config.js), ESLint, TypeScript, environment (.env.example).
Key Architecture Insights from README
• Front‐end: React/Tailwind/shadcn UI served by Next.js; fully responsive, SEO optimized, dark mode.
• Back‐end (Server Actions & API Routes): Next.js serverless functions handle all dynamic business logic.
• Database: Supabase (Postgres) for auth, user profiles, subscriptions, credits.
• Payments: Stripe API for checkout sessions and webhooks.
• Emails: Resend API sends welcome/reset password emails.
• External AI: An AI chat endpoint (likely calls OpenAI or similar).
a. Main Components
• Web Client (Next.js React pages + assets)
• Next.js Server (Server Actions & API Routes)
• Supabase (Auth + Postgres DB)
• Stripe (Checkout, Webhook events)
• Resend (Email service)
• AI Service (external LLM endpoint)
b. Data Flow & Interactions
1. User → Web Client: requests pages, submits auth/login forms.
2. Web Client → Next.js API: calls /auth, /api/create-checkout-session, /api/ai/chat, etc.
3. Next.js API → Supabase: user sign‐up, session management, CRUD on profiles/subscriptions/credits.
4. Next.js API → Stripe: create checkout sessions, cancel subscriptions; Stripe → Next.js webhook for events.
5. Next.js API → Resend: send welcome/reset emails via library in src/lib/email.
6. Next.js API → AI Service: proxy chat requests and return LLM responses.
c. Architectural Patterns
• Serverless Microservices: each endpoint is an isolated function.
• Layered Pattern: UI layer → API layer → Service layer (lib/utils) → Data/External Services.
• Third‐Party Integration Layer: clean wrappers in lib/email and utils/supabase-*.
d. Technologies & Frameworks
• Next.js 15 (App Router, Server Actions)
• React + TypeScript + Tailwind CSS + shadcn/ui
• Supabase (Auth + Postgres)
• Stripe API & webhooks
• Resend API (email)
• Node.js runtime (serverless)
Detail Is Key – Don’t Overthink
• Break out the project into all logical components: pages, API domains (auth, billing, AI, email), service libraries, data stores, webhook listeners.
• Core workflows: signup → welcome email, login → dashboard, purchase → webhook updates credit.