How shahzan01/excali-sketch works
Main Components Identification
• Backend Application – An Express server featuring REST APIs (via controllers, routes, and services directories) and WebSocket handling (e.g., wsHandler.ts) for real-time collaboration. It includes middleware for authentication and input validation.
• Database – Managed by Prisma via schema definitions and migrations. This component will store user info, room data, and session information.
• Shared Packages – There are several packages (e.g., packages/ui, packages/typescript-config, packages/tailwind-config, and eslint-config) that provide configuration, reusable UI components, and shared utilities that support both frontend and backend components.
• Deployment & Infrastructure – The README notes that the frontend is deployed on Vercel and the backend on Render. This is an important aspect for the overall architecture.
Relationships and Interactions
• The Frontend communicates with the Backend using HTTP APIs for room management, authentication, and configuration (the ‘authRoutes’, ‘roomRoutes’, and ‘userRoutes’ under apps/backend).
• Real-time drawing and collaboration are achieved via WebSocket connections between the frontend (using hooks like useSocket.ts) and the backend’s WebSocket handler.
• The Backend interacts with the Database through Prisma, executing migrations and data operations as defined in the Prisma schema and through service layers.
• Shared utilities and UI components from the “packages/ui” ensure consistency across the application, so include a group for “Shared/Reusable Components & Configurations.”
Architectural Patterns & Design Principles
• Modular Architecture – Clear separation between frontend and backend code with explicit directories for controllers, routes, models, and services indicating adherence to separation of concerns.
• Real-time communication by leveraging WebSockets.
• Use of middleware for authorization and input validation enhances security and data integrity.
• Monorepo management with Turborepo facilitates reuse of configuration and UI components across projects.
a. Components:
• Frontend (Next.js/React):
• UI Components (Canvas, Toolbar, Auth pages, etc.)
• Pages and Routes (auth, canvas/[roomId], dashboard)
• State management and hooks (e.g., useSocket)
• Backend (Express):
• Controllers (roomController, userController)
• Routes (authRoutes, roomRoutes, userRoutes)
• Middlewares (authentication, input validation)
• Services (roomService, userService)
• WebSocket Handler (wsHandler.ts)
• Database:
• Prisma-managed PostgreSQL database (as configured in the backend)
• Shared Packages and Configuration:
• UI components, eslint-config, tailwind-config, typescript-config
b. Relationships/Interactions:
• From the Frontend to the Backend for REST API calls (for authentication, room creation, etc.)
• From the Backend to the Database (indicating data CRUD operations via Prisma)
• Optionally, show interactions from the configuration/shared packages feeding into both the Frontend and Backend setups.
c. Design Details: