How ketan-ag/smart-board works
Project type and purpose
• This is a full-stack, real-time collaborative whiteboard (“Miro clone”) built on Next.js 13’s App Router.
• The front end is React + Tailwind; real-time sync uses Liveblocks; persistent storage and business logic use Convex; authentication is handled by Clerk.
File structure
• app/ – Next.js “App Router” pages and layouts
• (dashboard)/ – dashboard UI (board listing, org sidebar, nav)
• board/[boardId]/ – live board page (canvas, tools, presence)
• api/liveblocks-auth/route.ts – serverless API route for Liveblocks authentication
• components/ – shared React components (modals, UI primitives, actions)
• providers/ – React context for Convex client and modal state
• convex/ – Convex function definitions, schema, and generated client/server bindings
• hooks/ – custom React hooks for API mutations, selection logic, scroll locks
• types/, lib/, public/ – utility types, helper functions, static assets
• config files: next.config.mjs, tailwind.config.ts, liveblocks.config.ts, convex/auth.config.js
Key insights from README
• Stack: Next.js, Tailwind, Liveblocks, Convex, Clerk
• Tutorial-driven “Real Time Miro Clone”
Main architectural components
a. Frontend (Browser)
• Next.js App Router pages (dashboard & board)
• React component tree under app/ and components/
• Providers (ConvexClientProvider, ModalProvider)
• Liveblocks SDK client for real-time events (cursors, objects)
• Convex client for data queries & mutations
• Clerk client for user authentication flows
b. Next.js Backend (Edge / Serverless Functions)
• SSR/SSG rendering of app/* pages
• API Route: /api/liveblocks-auth → issues Liveblocks auth tokens
• Middleware (middleware.ts) for routing, auth checks
c. Convex Platform
• Convex Functions (convex/board.ts, convex/boards.ts)
• Convex Database (schema.ts)
• Generated client/server bindings (convex/_generated)
d. Liveblocks Service
• Real-time WebSocket rooms for board presence & updates
• Authenticated via Next.js API route
e. Clerk (Authentication Service)
• User sign-in, session management
• Integrated via Convex auth.config.js for serverless functions
Relationships and data flows
• Browser ←→ Next.js pages (SSR fetch + hydration)
• Browser (Convex client) → Convex functions → Convex DB
• Browser (Liveblocks SDK) ↔ Liveblocks real-time servers
• Presence updates (cursors, participants)
• Browser ←→ /api/liveblocks-auth (Next.js) to obtain Liveblocks tokens
• Browser ←→ Clerk-hosted auth endpoints (login, session, user info)
• Next.js middleware enforces auth on protected routes
Architectural patterns & principles
• BFF (Backend-for-Frontend): Next.js serverless functions abstract Liveblocks auth and Convex calls
• Provider pattern in React for global state (Convex, modals)
• Separation of concerns:
• UI / presentation (components/, app/)
• State & side-effects (hooks/)
• Data & business logic (convex/)
• Event-driven real-time collaboration (Liveblocks) vs. persistent state (Convex)