How vikasingh0897/drawly works
1. High-level shape
- Drawly is a two-process full-stack app: a React/Vite frontend and a Node.js/Express backend.
- The primary architecture boundary is HTTP for initial app delivery and Socket.IO for all live game interaction.
2. Frontend application boundary
- The frontend is a single-page app under frontend/src.
- main.tsx boots the app, App.tsx owns top-level page selection, and the UI splits into a landing flow and an in-game flow.
3. Client-side navigation and screens
- pages/LandingPage.tsx is the entry point for creating or joining a room.
- pages/GamePage.tsx is the active gameplay screen and aggregates the real-time game widgets: canvas, chat, and leaderboard.
4. Frontend component subsystem
- components/Canvas.tsx handles drawing interactions and rendering.
- components/Chat.tsx handles message entry and guess display.
- components/Leaderboard.tsx shows live scores.
- Header.tsx, Footer.tsx, and HowToPlay.tsx provide shared chrome and onboarding.
5. Client real-time transport
- src/socket.ts centralizes the Socket.IO client connection.
- The UI components and pages likely consume this shared socket instance to emit events and subscribe to server broadcasts, keeping transport logic separate from presentation.
6. Backend application boundary
- backend/src/index.ts is the bootstrapper; app.ts sets up the Express server layer.
- The backend is structured around Socket.IO event handlers rather than REST APIs, which is consistent with a real-time multiplayer game engine.
7. Backend event-handling subsystem
- socketHandlers/roomHandler.ts manages room creation, joining, and lifecycle changes.
- socketHandlers/gameHandler.ts drives round state, turn progression, and game flow.
- socketHandlers/canvasHandler.ts relays drawing events across clients.
- socketHandlers/chatHandler.ts handles messages, guess validation, and scoring-related chat behavior.
8. In-memory state subsystem
- store/room.ts holds active room state, player rosters, rounds, and related runtime state.
- store/words.ts provides the guessable word set used during rounds.
- The architecture suggests server-side ephemeral state, not a persistent database: rooms and scores live in memory for the duration of the server process.
9. Core data flow
- A player enters the landing page, creates or joins a room, and the frontend sends socket events to the backend.
- The backend updates room state in store/room.ts, then broadcasts room/game updates to all connected clients.
- During play, canvas strokes and chat/guess events flow from one client to the server and back out to all room members.
10. Game synchronization model
- Drawing is treated as a shared live event stream, not as saved images.
- Guessing is server-authoritative: the backend decides whether a chat message is a valid guess and then updates scores and visibility accordingly.
- This makes the server the single source of truth for gameplay state.
11. Room isolation and multiplayer boundaries
- Each room is an isolated session with its own players and current round state.
- The backend enforces separation between rooms so gameplay events only fan out to participants in the same room.
12. Frontend build and styling boundary
- The frontend uses Vite for development/build tooling and React for UI composition.
- index.css and the Vite setup indicate a utility-first styling approach, but these are presentation concerns rather than architectural drivers.
13. External service/infrastructure implications
- The only clear runtime dependency that materially shapes architecture is Socket.IO for low-latency duplex messaging.
- No database, cache, or message broker appears in the tree, so the system is intentionally lightweight and process-local on the backend.
14. What an architecture diagram should emphasize
- Drawly should be diagrammed as:
- a browser SPA,
- a Socket.IO real-time channel,
- a Node/Express server,
- modular socket handlers,
- and in-memory game/room stores.
- The key flow is: UI interaction -> socket event -> server state update -> broadcast -> synchronized UI update.
Main entry points: GamePage.tsx Game · app.ts app.ts · room.ts room store · App.tsx App
Components 19
Frontend
React/Vite browser app
- main.tsx · Bootstraps the SPA
frontend/src/main.tsx - App · Top-level page and flow selection
frontend/src/App.tsx - Landing · Room create/join entry point
frontend/src/pages/LandingPage.tsx - Game · Active gameplay screen
frontend/src/pages/GamePage.tsx - Canvas · Drawing surface and interactions
frontend/src/components/Canvas.tsx - Chat · Messages and guess input
frontend/src/components/Chat.tsx - Leaderboard · Live score display
frontend/src/components/Leaderboard.tsx - Header · Shared top-level chrome
frontend/src/components/Header.tsx - Footer · Shared footer chrome
frontend/src/components/Footer.tsx - HowToPlay · Gameplay instructions
frontend/src/components/HowToPlay.tsx
Backend
Node/Express real-time server
- index.ts · Server bootstrapper
backend/src/index.ts - app.ts · Express server setup
backend/src/app.ts - Room handler · Room creation and lifecycle events
backend/src/socketHandlers/roomHandler.ts - Game handler · Round and turn progression
backend/src/socketHandlers/gameHandler.ts - Canvas handler · Broadcasts drawing events
backend/src/socketHandlers/canvasHandler.ts - Chat handler · Guess checks and chat scoring
backend/src/socketHandlers/chatHandler.ts
Shared runtime
Cross-cutting transport and state
- socket.ts · Central Socket.IO client connection
frontend/src/socket.ts - room store · Active rooms, players, and rounds
backend/src/store/room.ts - words store · Guessable round words
backend/src/store/words.ts
Connections 22
- main.tsx → App: mounts · Bootstraps the app shell
- App → Landing: lobby flow · Shows room entry experience
- App → Game: game flow · Switches into active play
- Landing → socket.ts: emit room events · Creates or joins rooms over Socket.IO
- Game → socket.ts: subscribe/emit · Coordinates live gameplay traffic
- Game → Canvas: renders · Hosts drawing interactions
- Game → Chat: renders · Hosts chat and guesses
- Game → Leaderboard: renders · Shows live scores
- Game → Header: shared chrome · Uses common header
- Game → Footer: shared chrome · Uses common footer
- Game → HowToPlay: onboarding · Provides play instructions
- socket.ts → index.ts: Socket.IO · Real-time client-server channel
- index.ts → app.ts: starts · Bootstraps the HTTP and socket server
- app.ts → Room handler: registers · Attaches room event logic
- app.ts → Game handler: registers · Attaches game flow logic
- app.ts → Canvas handler: registers · Attaches drawing event logic
- app.ts → Chat handler: registers · Attaches chat and guess logic
- Room handler → room store: reads/writes · Maintains session state in memory
- Game handler → room store: updates · Advances rounds and turns
- Game handler → words store: selects words · Chooses round prompts
- Canvas handler → room store: broadcasts via room · Fans drawing events to room members
- Chat handler → room store: updates scores · Applies authoritative game state changes