# sining1989/wboard architecture

> Architecture diagram of the GitHub repository sining1989/wboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sining1989/wboard
- Repository: https://github.com/sining1989/wboard

## Overview

##### Project Type and Purpose
- This is a native desktop full-stack application written in C++/Qt (Qt 5.9.5) targeting Windows (VS2017).
- Purpose: an interactive whiteboard teaching tool (“WBoard”) with four major UIs—presentation board, web browser, document viewer, and desktop annotation.

##### High-Level File Structure Analysis
- Top-level: WBoard.sln, README.md, .vcxproj files.
- WBoard/Resources: static assets (fonts, images, CSS, HTML templates, config).
- WBoard/UI: Qt Designer .ui forms.
- WBoard/Source: core C++ code, subdivided into layers/modules:
- adaptors (import/export/PDF thumbnailing)
- api (widget & library APIs for plugins or JS widgets)
- board, document, desktop, web, gui, tools, network, podcast, pdf-merger, pdf
- core (application controller, persistence, document manager, settings, download manager, etc.)
- domain (graphics items, undo/redo commands)
- frameworks (utility functions, platform abstractions)
- globals (global constants)
- third-party (OpenSSL, QuaZip)
- TSResource: translation files.

##### Key Architecture Insights from README
- Four distinct UI modes mapped to four controllers/modules.
- Heavy use of Qt widget hierarchies, graphics or scene-graph domain objects.
- Import/export pipelines for documents, PDF, images, web content.
- Persistence to local file system (WBSceneCache, PersistenceManager).
- Networking for auto-save, file download, widget messaging (XMLHttpRequest API).

##### Main Components
A. UI Layer
- Source: WBoard/UI + gui/, web/browser/, document/, desktop/
B. Core Application
- WBApplicationController, DisplayManager, DocumentManager, PersistenceManager, DownloadManager
C. Domain Model
- GraphicsScene & items, Undo/Redo commands (domain/)
D. Adaptors & APIs
- ImportAdaptor, ExportAdaptor, ThumbnailAdaptor (adaptors/)
- Widget & Library APIs (api/)
E. Networking
- HTTP downloader, AutoSaver, XMLHttpRequest server (network/)
F. PDF Handling
- PDF renderer, merger components (pdf/, pdf-merger/)
G. Podcast/Media
- PodcastController, VideoEncoder, WaveRecorder (podcast/)
H. Framework Utilities
- CryptoUtils, FileSystemUtils, PlatformUtils, StringUtils (frameworks/)
I. Third-Party Libraries
- Qt5 Widgets & WebKit
- OpenSSL (security, network)
- QuaZip (ZIP/PDF)
J. Resources & Configuration
- Static assets (fonts, images, style.qss, HTML templates, config files)

##### Interactions and Data Flows
- UI Layer → Core Application: user events → application logic
- Core → Domain: create/manipulate GraphicsScene & items
- Core → PersistenceManager: save/load whiteboard files
- Core ↔ Network: fetch remote resources, auto-save sync
- Core ↔ Adaptors/APIs: import/export pipelines, plugin/widget messages
- Core ↔ PDF & Podcast modules: export sessions to PDF, record video/audio
- All modules → Frameworks & Third-Party libs for utility functions, crypto, zip, rendering

##### Architectural Patterns & Principles
- MVC/MVP-style separation: UI (View) / Core (Controller) / Domain (Model)
- Adapter pattern for import/export and plugin APIs
- Command pattern for undo/redo in domain
- Layered architecture: UI → Core → Domain → Frameworks → OS/Third-Party
- Single application instance enforcement via QtSingleApplication

##### Final Advice
- Four main user work-flows (board, web, doc, desktop) to show how the same core services are reused.
- Review with domain experts to ensure completeness of key interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        style UI fill:#e0f7fa,stroke:#006064
        PresentationBoardUI["PresentationBoardUI"]:::ui
        WebBrowserUI["WebBrowserUI"]:::ui
        DocumentViewerUI["DocumentViewerUI"]:::ui
        DesktopAnnotationUI["DesktopAnnotationUI"]:::ui
    end

    %% Core Application Layer
    subgraph "Core Application" 
        style Core fill:#e8f5e9,stroke:#1b5e20
        WBApplicationController["WBApplicationController"]:::core
        DisplayManager["DisplayManager"]:::core
        DocumentManager["DocumentManager"]:::core
        PersistenceManager["PersistenceManager"]:::core
        DownloadManager["DownloadManager"]:::core
    end

    %% Domain Model Layer
    subgraph "Domain Model"
        style Domain fill:#fff3e0,stroke:#e65100
        GraphicsScene["GraphicsScene"]:::domain
        UndoRedo["Undo/Redo Commands"]:::domain
    end

    %% Adaptors & APIs Layer
    subgraph "Adaptors & APIs"
        style Adapters fill:#f3e5f5,stroke:#4a148c
        ImportAdaptor["ImportAdaptor"]:::adapter
        ExportAdaptor["ExportAdaptor"]:::adapter
        ThumbnailAdaptor["ThumbnailAdaptor"]:::adapter
        LibraryAPI["LibraryAPI"]:::api
        WidgetAPI["WidgetAPI"]:::api
        WidgetMessageAPI["WidgetMessageAPI"]:::api
    end

    %% Networking Layer
    subgraph "Networking"
        style Network fill:#e1f5fe,stroke:#01579b
        HTTPDownloader["HTTPDownloader"]:::network
        AutoSaver["AutoSaver"]:::network
        XMLHttpRequestServer["XMLHttpRequestServer"]:::network
    end

    %% PDF Handling Layer
    subgraph "PDF Handling"
        style PDF fill:#fbe9e7,stroke:#bf360c
        PDFRenderer["PDFRenderer"]:::pdf
        Merger["PDF Merger"]:::pdf
    end

    %% Podcast/Media Layer
    subgraph "Podcast/Media"
        style Podcast fill:#fffde7,stroke:#f57f17
        PodcastController["PodcastController"]:::podcast
        VideoEncoder["VideoEncoder"]:::podcast
        WaveRecorder["WaveRecorder"]:::podcast
    end

    %% Framework Utilities
    subgraph "Framework Utilities"
        style Framework fill:#eceff1,stroke:#455a64
        CryptoUtils["CryptoUtils"]:::framework
        FileSystemUtils["FileSystemUtils"]:::framework
        PlatformUtils["PlatformUtils"]:::framework
        StringUtils["StringUtils"]:::framework
    end

    %% Third-Party Libraries
    subgraph "Third-Party Libraries"
        style ThirdParty fill:#f5f5f5,stroke:#9e9e9e
        Qt5["Qt5 Widgets & WebKit"]:::third
        OpenSSL["OpenSSL"]:::third
        QuaZip["QuaZip"]:::third
    end

    %% Resources & Configuration
    Resources["Resources & Config"]:::resources

    %% Connections
    PresentationBoardUI -->|user events| WBApplicationController
    WebBrowserUI -->|user events| WBApplicationController
    DocumentViewerUI -->|user events| WBApplicationController
    DesktopAnnotationUI -->|user events| WBApplicationController

    WBApplicationController -->|controls| DisplayManager
    WBApplicationController -->|manages| DocumentManager
    WBApplicationController -->|persists| PersistenceManager
    WBApplicationController -->|downloads| DownloadManager

    WBApplicationController -->|creates| GraphicsScene
    WBApplicationController -->|issues| UndoRedo

    WBApplicationController -->|uses| ImportAdaptor
    WBApplicationController -->|uses| ExportAdaptor
    WBApplicationController -->|uses| ThumbnailAdaptor
    WBApplicationController -->|exposes| LibraryAPI
    WBApplicationController -->|exposes| WidgetAPI
    WBApplicationController -->|exposes| WidgetMessageAPI

    WBApplicationController -->|network| HTTPDownloader
    WBApplicationController -->|network| AutoSaver
    WBApplicationController -->|network| XMLHttpRequestServer

    WBApplicationController -->|pdf export| PDFRenderer
    WBApplicationController -->|pdf merge| Merger

    WBApplicationController -->|podcast| PodcastController
    PodcastController -->|encode| VideoEncoder
    PodcastController -->|record| WaveRecorder

    %% Utility & Third-Party
    WBApplicationController -->|crypto| CryptoUtils
    WBApplicationController -->|fs| FileSystemUtils
    WBApplicationController -->|platform| PlatformUtils
    WBApplicationController -->|string| StringUtils

    GraphicsScene -->|draw| Qt5
    ImportAdaptor -->|zip/pdf| QuaZip
    HTTPDownloader -->|ssl| OpenSSL

    %% Resources link
    PresentationBoardUI --> Resources
    WebBrowserUI --> Resources
    WBApplicationController --> Resources

    %% Click Events
    click PresentationBoardUI "https://github.com/sining1989/wboard/blob/main/WBoard/UI/mainWindow.ui"
    click WebBrowserUI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/web/browser/WBBrowserWindow.cpp"
    click DocumentViewerUI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/document/WBDocumentController.cpp"
    click DesktopAnnotationUI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/desktop/WBDesktopAnnotationController.cpp"
    click WBApplicationController "https://github.com/sining1989/wboard/blob/main/WBoard/Source/core/WBApplicationController.cpp"
    click DisplayManager "https://github.com/sining1989/wboard/blob/main/WBoard/Source/core/WBDisplayManager.cpp"
    click DocumentManager "https://github.com/sining1989/wboard/blob/main/WBoard/Source/core/WBDocumentManager.cpp"
    click PersistenceManager "https://github.com/sining1989/wboard/blob/main/WBoard/Source/core/WBPersistenceManager.cpp"
    click DownloadManager "https://github.com/sining1989/wboard/blob/main/WBoard/Source/core/WBDownloadManager.cpp"
    click GraphicsScene "https://github.com/sining1989/wboard/blob/main/WBoard/Source/domain/WBGraphicsScene.cpp"
    click UndoRedo "https://github.com/sining1989/wboard/blob/main/WBoard/Source/domain/WBUndoCommand.cpp"
    click ImportAdaptor "https://github.com/sining1989/wboard/blob/main/WBoard/Source/adaptors/WBImportAdaptor.cpp"
    click ExportAdaptor "https://github.com/sining1989/wboard/blob/main/WBoard/Source/adaptors/WBExportAdaptor.cpp"
    click ThumbnailAdaptor "https://github.com/sining1989/wboard/blob/main/WBoard/Source/adaptors/WBThumbnailAdaptor.cpp"
    click LibraryAPI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/api/WBLibraryAPI.cpp"
    click WidgetAPI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/api/WBW3CWidgetAPI.cpp"
    click WidgetMessageAPI "https://github.com/sining1989/wboard/blob/main/WBoard/Source/api/WBWidgetMessageAPI.cpp"
    click HTTPDownloader "https://github.com/sining1989/wboard/blob/main/WBoard/Source/network/UBHttpFileDownloader.cpp"
    click AutoSaver "https://github.com/sining1989/wboard/blob/main/WBoard/Source/network/WBAutoSaver.cpp"
    click XMLHttpRequestServer "https://github.com/sining1989/wboard/blob/main/WBoard/Source/network/UBServerXMLHttpRequest.cpp"
    click PDFRenderer "https://github.com/sining1989/wboard/blob/main/WBoard/Source/pdf/PDFRenderer.cpp"
    click Merger "https://github.com/sining1989/wboard/blob/main/WBoard/Source/pdf-merger/Merger.cpp"
    click PodcastController "https://github.com/sining1989/wboard/blob/main/WBoard/Source/podcast/WBPodcastController.cpp"
    click VideoEncoder "https://github.com/sining1989/wboard/blob/main/WBoard/Source/podcast/WBAbstractVideoEncoder.cpp"
    click WaveRecorder "https://github.com/sining1989/wboard/blob/main/WBoard/Source/podcast/windowsmedia/WBWaveRecorder.cpp"
    click CryptoUtils "https://github.com/sining1989/wboard/blob/main/WBoard/Source/frameworks/WBCryptoUtils.cpp"
    click FileSystemUtils "https://github.com/sining1989/wboard/blob/main/WBoard/Source/frameworks/WBFileSystemUtils.cpp"
    click PlatformUtils "https://github.com/sining1989/wboard/blob/main/WBoard/Source/frameworks/WBPlatformUtils.cpp"
    click StringUtils "https://github.com/sining1989/wboard/blob/main/WBoard/Source/frameworks/WBStringUtils.cpp"
    click OpenSSL "https://github.com/sining1989/wboard/tree/main/WBoard/ThirdParty/openssl"
    click QuaZip "https://github.com/sining1989/wboard/tree/main/WBoard/ThirdParty/quazip"
    click Resources "https://github.com/sining1989/wboard/tree/main/WBoard/Resources"

    %% Styles
    classDef ui fill:#e0f7fa,stroke:#006064
    classDef core fill:#e8f5e9,stroke:#1b5e20
    classDef domain fill:#fff3e0,stroke:#e65100
    classDef adapter fill:#f3e5f5,stroke:#4a148c
    classDef api fill:#f3e5f5,stroke:#4a148c
    classDef network fill:#e1f5fe,stroke:#01579b
    classDef pdf fill:#fbe9e7,stroke:#bf360c
    classDef podcast fill:#fffde7,stroke:#f57f17
    classDef framework fill:#eceff1,stroke:#455a64
    classDef third fill:#f5f5f5,stroke:#9e9e9e
    classDef resources fill:#ffffff,stroke:#000000,stroke-dasharray: 5 5
```
