How goatninja10/contentfuse works
This project is an AI SaaS platform built on Next.js 13 with a modern full‑stack architecture. It combines a rich user interface (React with TailwindCSS) with server-side API routes and database connectivity (via Prisma and MySQL on PlanetScale). In addition, it integrates several third‑party services for authentication (Clerk), payments (Stripe), and AI tools (OpenAI and Replicate for image, video, conversation, and music generation) while leveraging Crisp for live chat support.
Main Components
• Frontend/UI Layer:
• Next.js App: Contains groups for (landing), (auth), and (dashboard) pages.
• Reusable Components: Located in the “components” directory (e.g., Navbar, Sidebar, Modal, Loader, etc.) and UI sub-components.
• Styling: TailwindCSS-based UI design including animations and responsive layouts.
• API / Backend Layer:
• Route Handlers: Located in “app/api” (e.g., endpoints for code, conversation, image, music, video, stripe, and webhook).
• Server Components: Next.js Server-Side rendering that fetches data directly from the database.
• Authentication & User Management:
• Clerk Integration: Provides authentication flows between (auth) routes and protected resources (dashboard, account pages).
• Payment System:
• Stripe Integration: Manages monthly subscriptions and payment confirmations.
• Database & ORM:
• Prisma: Interfaces with the MySQL (PlanetScale) Database for persistent storage.
• AI & External Services:
• OpenAI APIs and Replicate AI: Implemented within API endpoints and lib modules to generate images, videos, conversation text, or music.
• Utilities & Middleware:
• Global utilities and subscriptions (in “lib”), API limits, and request error handling.
• Middleware used for authentication or request processing.
• Third-Party Chat:
• Crisp integration for live chat support.
Relationships and Interactions
• The User interacts with the Frontend UI (landing page, auth pages, dashboard).
• On authentication actions, the Clerk service is invoked, and routes in the (auth) group handle sign‑in/sign‑up flows.
• After authentication, the user navigates to the dashboard pages which render data fetched by server components (using Prisma) and call API routes for work (e.g., image generation or conversation generation).
• API route handlers (in “app/api”) act as mediation points between the Next.js server and external services (Stripe, OpenAI, Replicate).
• The API layer connects to the database via Prisma for persistent application state.
• Components in “lib” serve as the supporting infrastructure (e.g., stripe helpers, API limit checking, subscription management).
Architectural Patterns & Design Principles
• Next.js App Router Pattern: Modularized folder structure with group routes (e.g., (auth), (dashboard), (landing)), layouts, and nested pages.
• Separation of Concerns: Clearly separating UI (components), logic (hooks, lib), and API endpoints.
• Reusability and Composability: Use of reusable React components and layouts.
• External Service Integration: Encapsulating third‑party services (Stripe, Clerk, OpenAI, Replicate) within helper modules.
• Defensive Design: Error handling via middleware, toaster notifications and API rate limits.
b. Next.js application:
• Split it into sections: Landing, Authentication, and Dashboard.
• Inside the Dashboard group, include sub-modules for each API related feature (code, conversation, image, music, video, settings).
• Database Layer: Represent Prisma as the ORM and an underlying MySQL (PlanetScale) database.
e. Supportive elements for error handling, middleware, and shared libraries (lib, hooks, constants).