How andreaswt/figma-clone works
Project type and purpose
• This is a full-stack, real-time collaborative “Figma clone” built with Next.js 13 (app router), React 18, TypeScript, Prisma (Postgres), NextAuth.js for authentication, and Liveblocks for live collaboration.
File structure
• Top-level:
• src/app – Next.js pages and layout
• src/app/api – NextAuth routes and Liveblocks auth endpoint
• src/server – database and auth server logic
• prisma/schema.prisma – database schema
• public – static assets (e.g., thumbnail)
• components & hooks – React UI and custom hooks
• Patterns:
• App Router → React Server/Client Components
• API Routes for auth and liveblocks token generation
• Prisma ORM for DB access
• Liveblocks handles WebSocket-style real-time sync
• NextAuth.js for session management
• Tailwind CSS/postCSS for styling
README for additional insights
• Confirms stack: Next.js, React, TypeScript, Liveblocks, Prisma/Postgres, Vercel.
• Outlines features and flow: user signs up/in → lands on dashboard → creates/joins drawing rooms → real-time collaboration.
• Use clear labels: e.g., “Browser (React Client)”, “Next.js Serverless Functions”, “PostgreSQL (Prisma)”, “Liveblocks Service”.
• Blue = frontend components
• Green = backend/API
• Orange = database
• Purple = external real-time service
Detailed capture of essential elements
• Break the system into at least these layers:
• Presentation (React components: canvas, toolbars, sidebars, dashboard)
• API & business logic (Next.js app router, src/server, NextAuth config)
• Data (Prisma, Postgres)
• Real-time collaboration (Liveblocks auth + live service)
• Deployment (Vercel hosting static + serverless)
• Don’t omit utility modules (src/utils.ts, src/schemas.ts), middleware, or hooks—they support the data flow and UI logic.
[Browser: React UI]
| (HTTP GET/POST) ──> [Next.js App Router + API Routes]
| ├─ /api/auth ←── NextAuth.js
| ├─ /api/liveblocks-auth ──> Liveblocks Server
| └─ Prisma Client ──> Postgres DB
└─(WebSocket) ──> Liveblocks Real-time Service