How harshitp002/saas-website-builder works
• Frontend Application: Represent the Next.js application that handles both server and client rendering. Break this section into:
• Page Routes and Layouts: Note that the application’s “src/app” directory is divided into different route segments (e.g., agency, subaccount, domain) that deliver different views. Clearly label separate modules for authentication (sign-in/sign-up), dashboards, funnel editor, and so on.
• Providers & Global State: Represent the reusable providers (theme, modal, editor) that wrap the application to manage state and share contextual data.
• Backend REST/Serverless API Endpoints: Identify the API endpoints under “src/app/api” which include Stripe integration endpoints (create-checkout-session, create-subscription, webhook), Uploadthing, etc. These endpoints represent the server-side logic called by the frontend.
• Database: Highlight the use of Prisma (with files in the “prisma” folder) that connects to a MySQL database. Mark how the application persists its data for agencies, subaccounts, funnels, user-generated content, etc.
• Third-Party Services: Show integrations with external systems:
• Stripe Connect for payment processing, subscriptions, and billing.
• Clerk for handling user authentication.
• Possibly others (e.g., Uploadthing for media uploads).
Relationships and Data Flow
• Next.js application interacting with server-side API endpoints (for example, the Stripe checkout session creation or webhook calls).
• External third-party integrations by drawing connections:
• API calls from Stripe endpoints to the Stripe Connect service.
• Authentication requests routed through Clerk.
Architectural Patterns and Design Principles
• Separation of Concerns: Emphasize the clear split between the Frontend (UI/UX) and Backend logic (API routes, database interactions).
• Modular Routing and Layouts: The use of dynamic directories like “[agencyId]” and “[subaccountId]” in the file tree implies a modular routing system using Next.js’s new app directory.
• Middleware & Providers: Don’t forget to show that global middleware (src/middleware.ts) and context providers (in src/providers) play roles in handling cross-cutting concerns such as authentication and state management.