How parthib007/miro_whiteboard works
Project type and purpose
• This is a full-stack web application that provides a real-time collaborative whiteboard.
• Frontend: React + Next.js for server-side rendering and static export.
• Backend: Node.js + Express, using Socket.IO for real-time communication.
• Database: MongoDB for persisting sessions, drawings, chat messages, user profiles.
• Authentication: JWT and OAuth for user login and role management.
File structure
• Top-level “pages” and “modules” directories contain all the Next.js pages and feature modules (home page, room page, chat, drawing board, toolbar, etc.).
• “common” directory holds shared utilities, components (modal, portal), styles, hooks, recoil state atoms/selectors, and socket helper.
• “server/index.ts” is the custom Express + Socket.IO server that sets up HTTP, WebSocket endpoints, and connects to MongoDB.
• Configuration files: next.config.js, tsconfig.json, tailwind.config.js, postcss.config.js, linter configs.
• Build artifacts in “.next” and “build” show the two deployment modes: Next.js SSR/static output and compiled server code.
README for additional insights
• Features list confirms real-time collaboration, drawing tools, chat, image upload, save/load, export, integrations.
• Scripts show separate build pipelines: “build:server” compiles server, “build:next” builds Next.js, “start” launches production server.
a. Main components
• Browser / Client (User’s web browser)
• Next.js server (handles SSR, static asset serve, REST API routes if any)
• Express + Socket.IO server (real-time event broker)
• MongoDB database
• External Auth providers (OAuth services: Google, GitHub, Slack)
• (Optional) CDN for static assets and image hosting
b. Relationships & interactions
• Browser ←HTTP(S)→ Next.js server for initial page render, static assets, REST API calls (e.g., fetch saved sessions).
• Browser ↔WebSocket (Socket.IO)↔ Express server for real-time drawing events, chat messages, user presence.
• Express server ↔MongoDB for persisting drawing data, chat logs, session metadata.
• Next.js server ↔Express server may share auth middleware or proxy socket connections.
• Browser ↔OAuth provider for login flows (redirect → callback).
c. Architectural patterns & design principles
• Separation of concerns:
• Presentation layer (Next.js + React modules)
• Application layer (Express controllers, Socket.IO event handlers)
• Persistence layer (MongoDB)
• Publish-subscribe pattern (Socket.IO rooms for separate whiteboard sessions).
• Modular frontend structure (feature modules under “modules/room”, “modules/home”; shared code in “common”).
• State management with Recoil for local UI state; server sync via WebSocket.
d. Key technologies & frameworks
• Frontend: Next.js, React, Recoil, Tailwind CSS
• Real-time: Socket.IO
• Backend: Node.js, Express
• DB: MongoDB (Mongoose or native driver)
• Auth: JWT, OAuth2 flows
• Build & Deploy: ts-node, nodemon, GitHub Pages (static export), custom server for production