How siddiq-2034/pyside-whiteboard works
Project Type and Purpose
• This is a full‐stack, networked whiteboard application written in Python.
• The backend is a custom TCP server that synchronizes drawing events across multiple clients in real time, with Redis used for session management.
High‐Level Components
a. Client
• UI Layer (board.ui → board.py)
• Login module (login.py)
• Networking (TcpClient.py + TcpClientNet.py: QTcpSocket wrapper, framing, send/receive)
b. Server
• TCP Server (tcpServer.py + tcpServerNet.py: listening socket, connection handling)
• Session/State Manager (netManage.py: decode messages, route events to clients)
• Utility (getip.py: retrieve host IP, testServer.py for dev testing)
c. Data Stores
• Redis (session info: active boards, host/client lists)
• File system (save/load whiteboard files on disk)
d. External Dependencies
• PySide6 (GUI toolkit)
• redis-py (Redis client)
Core Interactions and Data Flows
• On startup: client → login → credentials validated (optional DB or Redis check)
• Server receives packet → netManage parses it → updates session state (in Redis) → broadcasts packet to all connected clients in same session
• Clients receive broadcast → update local canvas in real time
• Save/Load: client logic reads/writes .wbd files on local FS
• Undo/Redo: tracked purely on client side with state stacks
Important Architectural Patterns
• Separation of Concerns: UI, business logic, networking are distinct modules on the client side
• Message Framing: custom framing layer (TcpClientNet / tcpServerNet) to handle message boundaries over TCP
• Publish/Subscribe Pattern: server forwards events from one client to all others in a session
• Stateless Server Logic + External Session Store: core server code does not keep heavy in‐memory state; Redis holds session metadata