How anayatkhan1/fuzora works
Project Type and Purpose
• Fuzora is a full-stack SaaS web application built with Next.js (app router).
• It exposes a rich React-Flow-based UI for building automation workflows, routes API endpoints for OAuth and webhooks, and persists data in a Postgres database via Prisma.
• It integrates with multiple external services (Google Drive, Slack, Discord, Notion, Stripe, Uploadcare, Clerk) to deliver triggers, actions, and billing.
File Structure
• src/app ─ React pages (Auth zone vs. Main zone) plus API routes under src/app/api.
• prisma/schema.prisma ─ Defines your Postgres data model.
• src/lib & src/providers ─ Shared utility and context providers (db connection, theme, billing, connections, editor).
• Middleware.ts ─ Global requests (auth enforcement, logging).
• Public folder, global CSS, Tailwind config ─ Static assets and styling.
Extract Architectural Insights from README
• Next.js handles both client-side UI and serverless API routes.
• Authentication via Clerk (hosted).
• OAuth flows (Google, Slack, Discord, Notion) using Next.js API routes for callbacks.
• Google Drive push notifications handled in /api/drive-activity/notification.
• Stripe used for subscriptions and metered billing (credits).
Main Components & Relationships
A. Client Layer
– Web Browser / User’s Device
• Renders Next.js pages (React + React Flow + Shadcn UI + Tailwind).
• Initiates OAuth flows and invokes API endpoints.
B. Edge / CDN (optional)
– Vercel / CDN for page assets, static files, Uploadcare CDN.
C. Next.js Application (Serverless)
1. Frontend (SSR/ISR/CSR)
• app/(auth) – Sign-in/Sign-up UIs (Clerk).
• app/(main) – Dashboard, Workflows editor, Billing, Connections UI.
2. API Routes (Business Logic)
• /api/auth/callback/* – OAuth callbacks for Discord, Notion, Slack.
• /api/drive-activity/notification – Google Drive webhooks.
• /api/drive, /api/drive-activity – Poll or webhook triggers.
• /api/payment – Stripe webhooks & credit usage.
• /api/clerk-webhook – User lifecycle events.
3. Middleware
• Guards routes, injects user context, route rewrites.
4. Context Providers
• Theme, connections, billing, editor.
D. Database Layer
– Neon Postgres
• Accessed via Prisma client (src/lib/db.ts).
• Stores users, connections, workflows, node definitions, billing credits.
E. External Services
• Clerk – Hosted auth & session management.
• OAuth Providers – Google Drive, Slack, Discord, Notion.
• Stripe – Billing, subscriptions, metered credit usage.
• Uploadcare – Profile picture uploads.
• Ngrok – Local dev tunneling (for callbacks).
• Browser → Next.js Frontend (HTTP/HTTPS).
• Frontend → Next.js API (fetch / WebSocket if any).
• API → Database (Prisma/SQL).
• API → External Services (REST/OAuth, webhooks).
• External Services → Next.js Webhooks (/api/…/route.ts).
Architectural Patterns & Design Principles
• Layered (Presentation → API Business Logic → Data).
• File-based routing (Next.js App Router).
• Context-based state management (React Context via providers).
• Serverless functions for each API route (scalable, single-purpose).
• OAuth handshake flows and webhooks for event-driven integrations.
• Modular React components with shadcn/ui and custom domain folders.