How chunkangwong/miro-clone works
Main Components
• Client (Frontend): Represented by the Next.js application. There are two primary pages to highlight:
• Dashboard: Found under app/(dashboard) which includes components for navigation, board cards, sidebars, and various states (empty boards, search, etc.).
• Board: Located in app/boards/[boardId] which contains interactive components related to the board, such as the canvas, drawing tools (ellipse, rectangle, text, cursor, etc.), toolbars, and selection controls.
• API/Authentication: The app/api/liveblocks-auth component indicates a dedicated authentication/API endpoint which likely handles Liveblocks authentication for real-time features.
• Real-Time & Data Backends:
• Liveblocks: Configured by liveblocks.config.ts and plays a role in enabling real-time, collaborative editing.
• Convex: The convex folder (with its generated APIs, server schema, and configuration) is used to manage the data model and server-side logic for persistent data and business operations.
• Supporting Components:
• Shared UI Components: The components directory (with various UI elements like buttons, dialogs, input, etc.) builds on shadcn/ui for a cohesive design system.
• Custom Hooks & Utilities: The hooks folder (and others like lib/utils.ts) encapsulates reusable logic for API mutations, layer deletion, scroll bounce, etc.
• Providers: The providers (or “provders” in the tree) such as convexClientProvider and modalProvider, which handle context and state management across the app.
Relationships and Interactions
• The User’s Browser interacts with the Next.js client, which is rendered through the Dashboard and Board pages.
• From the Dashboard, users can navigate into specific boards. This routing is controlled by Next.js’s file-system routing (e.g., page.tsx files) and layouts.
• Within a Board, the various components (canvas, tools, user avatar, etc.) interact to provide a rich drawing and collaboration experience.
• API calls and real-time events: The frontend communicates with:
• Liveblocks endpoints (via app/api/liveblocks-auth) to ensure real-time collaboration.
• Convex functions (through the convex folder’s API and schema) to persist changes and manage collaboration state.
• Custom hooks and providers are used to manage state and side effects, linking the UI components with backend services.
Architectural Patterns and Design Principles
• Modular Design: The project is partitioned into a clear separation between the “dashboard” (overview, board listings, navigation) and individual “board” pages (interactive drawing canvas).
• Component Reusability: The extensive use of subdirectories and components (especially under app/(dashboard) and app/boards/[boardId]) shows a high level of component reuse.
• API and Service Separation: Dedicated folders for API endpoints, real-time authentication, and backend logic (Convex) indicate clean separation of concerns.
• Integration of Real-Time and Persistent Data: The use of Liveblocks (for real-time state) alongside Convex (for persistent data) should be clearly indicated.