How tusharchawre/week-22-excelidraw works
Project Type and Purpose
• The project is a full-stack/monorepo application dedicated to a collaborative drawing environment.
• The frontend (found under apps/excelidraw-frontend) is responsible for rendering the drawing canvas (see canvas/Canvas.tsx and RoomCanvas.tsx), user interfaces (components like Navbar, Footer, etc.) and manages interactive elements.
• Two backends are provided:
– The HTTP backend (apps/http-backend) likely handles RESTful API calls such as user authentication (login, register) and room management.
– The WebSocket backend (apps/ws-backend) facilitates real-time, bidirectional communication crucial for live drawing sessions.
• Shared packages include common utilities, type definitions, and a UI component library that are used across the different apps.
File Structure
• Top-level directories such as apps and packages clearly separate concerns: apps contains runtime code (frontend and backend services) while packages hold shared libraries, configurations, and UI components.
• The frontend app structure suggests a Next.js application with pages corresponding to features like signing in, signing up, room creation, and a dashboard.
• The presence of a prisma schema and migration scripts in packages/db indicates the use of an ORM to manage a database, likely storing user or session data.
• The use of Turborepo (turbo.json and pnpm-workspace.yaml) signifies strong build orchestration and modularization across components.
README and Assignment
• The README focuses on adding fine-grained interactive features (pencil functionality, panning, and zooming) — these will have implications on the frontend canvas component’s responsibilities and the data exchanged via WebSockets to synchronize drawing actions.
• Although minimal, the assignment implies that the canvas interaction and real-time collaboration are key architectural concerns.
a. Main Components to Include:
• Frontend Application:
– Next.js based, handling UI rendering and drawing interactions.
– Canvas module (for pencil, pan, and zoom functionality).
– Components for authentication, room management, and layout.
• HTTP Backend Service:
– API endpoints for authenticating users, handling room creation, and managing user data.
• WebSocket Backend Service:
– Real-time messaging server facilitating live updates on drawing sessions.
• Database Layer:
– Managed via Prisma (inside packages/db) responsible for persistence (user data, sessions, room data, etc.).
• Shared Packages:
– Common (for shared types and utilities).
– UI (for reusable components that standardize the look and feel across apps).
– Configuration packages (TS and ESLint configs that define the project code standards).
b. Relationships and Interactions:
• The frontend communicates with the HTTP backend for non-real-time operations such as login, register, and room management.
• Simultaneously, it establishes a WebSocket connection to the WS backend to send live drawing events (e.g., pencil strokes, panning, zooming).
• Both backend services can interact with the database to store and retrieve persisted information.
• Shared packages (common types, UI components) are referenced by all applications to ensure consistent behavior and appearance.
c. Architectural Patterns and Design Principles:
• Modular separation: Clear demarcation of responsibilities between frontend, HTTP REST operations, and live WebSocket communication.
• Monorepo management: Using Turborepo and pnpm workspaces to orchestrate builds and streamline dependencies.
• Use of component-based UI design promoting reusability.
• Real-time data flow design to handle collaborative drawing interactions.
d. Relevant Technologies/Frameworks:
• Next.js for the frontend, leveraging its file-based routing and server-side rendering capabilities.
• Node.js (with TypeScript) for both HTTP and WS backends.
• Prisma for database interactions.
• Turborepo/pnpm for build orchestration and dependency management.
• Tailwind CSS (indicated by tailwind.config.js) for styling.
• ESLint and TypeScript configuration packages to ensure code consistency.
Elements
• Each component (frontend, HTTP backend, WS backend, Database, and Shared Packages) should be clearly labeled.
– Client request and response flows between the frontend and the HTTP backend.
– Real-time, bidirectional data flow between the frontend and the WS backend.
– Data querying and updating between both backends and the Database layer.
• Annotations to highlight the assignment-specific areas (pencil, pan, zoom functionality) that affect the canvas.