# siddiq-2034/pyside-whiteboard architecture

> Architecture diagram of the GitHub repository siddiq-2034/pyside-whiteboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siddiq-2034/pyside-whiteboard
- Repository: https://github.com/siddiq-2034/pyside-whiteboard

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#000,stroke-width:1px
    classDef fs fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef main fill:#EEEEEE,stroke:#000,stroke-width:1px

    subgraph "Client"
        direction TB
        UI1["board.ui"]:::client
        UI2["board.py"]:::client
        Logic["client_mg.py"]:::client
        Login["login.py"]:::client
        TCPC["TcpClient.py"]:::client
        TCPNet["TcpClientNet.py"]:::client
    end

    subgraph "Server"
        direction TB
        ServerListener["tcpServer.py"]:::server
        ServerNet["tcpServerNet.py"]:::server
        Router["netManage.py"]:::server
        GetIP["getip.py"]:::server
        Test["testServer.py"]:::server
    end

    Main["main.py"]:::main

    Redis[(Redis)]:::storage
    FS[(File System)]:::fs

    Main -->|"launches UI"| UI2
    UI2 -->|"loads board UI"| UI1
    UI2 -->|"on start →"| Login
    UI2 -->|"draw events →"| Logic
    Logic -->|"SAVE/LOAD"| FS
    Logic -->|"DRAW_EVENT"| TCPC
    TCPC -->|"frame packet"| TCPNet
    TCPNet -->|"TCP"| ServerListener
    ServerListener -->|"receive TCP"| ServerNet
    ServerNet -->|"parse message"| Router
    Router -->|"broadcast STATE_SYNC"| ServerNet
    ServerNet -->|"TCP"| TCPNet
    TCPNet -->|"deliver"| TCPC
    TCPC -->|"update canvas"| Logic

    Router -->|"GET sessionMembers\nSET boardState"| Redis
    Redis -->|"session data"| Router

    class Main main
    class UI1,UI2,Logic,Login,TCPC,TCPNet client
    class ServerListener,ServerNet,Router,GetIP,Test server
    class Redis storage
    class FS fs

    click UI1 "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/UI/board.ui"
    click UI2 "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/UI/board.py"
    click Logic "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Client/client_mg.py"
    click Login "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Client/login.py"
    click TCPC "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Client/TcpClient.py"
    click TCPNet "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Client/TcpClientNet.py"
    click ServerListener "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Server/tcpServer.py"
    click ServerNet "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Server/tcpServerNet.py"
    click Router "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Server/netManage.py"
    click GetIP "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Server/getip.py"
    click Test "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/Server/testServer.py"
    click Main "https://github.com/siddiq-2034/pyside-whiteboard/blob/master/WhiteboardApplication/main.py"
```
