# osdagscreeningtasks/prismshapeviewer architecture

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

- Interactive diagram: https://gitdiagram.com/osdagscreeningtasks/prismshapeviewer
- Repository: https://github.com/osdagscreeningtasks/prismshapeviewer

## Overview

##### Project type and purpose
- Prism Viewer is a cross-platform, full-stack 3D visualization application.
- It consists of:
- A shared core library (business logic, data models, plugin system)
- A desktop client (PySide2 + pythonOCC)
- A web client (React) + RESTful backend (Django)

##### File structure
- Top-level “src/” splits into three areas:
- core/ – business logic, database interface, plugin manager + default plugins
- desktop/ – PySide2 UI and CAD renderer
- web/ – React frontend (src/web/frontend) and Django backend (src/web/backend)
- Configuration & CI: pyproject.toml, requirements.txt, pytest.ini, GitHub Actions CI
- Build scripts: run_desktop.py, PyInstaller instructions in README

##### Pull additional insights from README
- Architecture overview confirms the three-layer layout and plugin mechanism
- Tech stack: Python 3.8+, PySide2, pythonOCC, Django + Django REST Framework, React, Node.js
- CI/CD: automated testing, builds via GitHub Actions

a. Main components:
- Shared Core Library
– Models & database adapter
– Plugin interface & manager
- Desktop Application
– Main Window (PySide2)
– CAD Renderer (pythonOCC)
– Plugin loader → Core.PluginManager → Core.Plugins
– Local SQLite database (via Core.Database)
- Web Application
– Backend (Django REST API)
· URL router → Views → Serializers → Core.Models → Database (PostgreSQL/MySQL)
· Management commands (populate_prisms)
– Frontend (React)
· Component tree (PrismSelector, PrismViewer, ThreeDViewer)
· Fetches REST endpoints for listing, detail, compute, CAD data
- External services & CI/CD
– GitHub Actions for tests & builds
– PyInstaller build for desktop
– Gunicorn + Nginx for serving Django & static React build

b. Relationships & interactions:
- Desktop UI ↔ Core (invokes business logic, plugin resolution, CAD data)
- Web Frontend → HTTP calls → Django REST API → Core → Database

c. Architectural patterns & principles:
- Modular layering: presentation (UI), domain (core), data (DB)
- Plugin architecture (inversion of control)
- MVC (Django) and component-based UI (React)
- Single responsibility and separation of concerns

d. Key technologies/frameworks:
– Python / PySide2 / pythonOCC
– Django & Django REST Framework
– React / Webpack / Node.js
– SQLite (desktop), PostgreSQL/MySQL (web)
– GitHub Actions, PyInstaller, Gunicorn, Nginx

##### Elements
- Data flow (e.g., React → API → DB)
- Dependencies (e.g., Desktop → Core; Django → Core)
- Another for desktop components
- A third for web backend
- A fourth for web frontend

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "Shared Core Library"
        direction TB
        CoreModels["Models & Database Adapter"]:::core
        CoreDB["Database Adapter"]:::core
        PluginInterface["Plugin Interface"]:::core
        PluginManager["Plugin Manager"]:::core
        subgraph "Default Plugins"
            direction TB
            CylinderPlugin["Cylinder Plugin"]:::core
            RectPrismPlugin["Rectangular Prism Plugin"]:::core
        end
    end

    subgraph "Desktop Application" 
        direction TB
        DesktopLauncher["Desktop Launcher (run_desktop.py)"]:::desktop
        MainWindow["Main Window (PySide2 UI)"]:::desktop
        CADRenderer["CAD Renderer (pythonOCC)"]:::desktop
        LocalDB["SQLite Database"]:::desktop
    end

    subgraph "Web Application"
        direction TB
        subgraph "Backend (Django REST API)"
            direction TB
            ManageScript["manage.py"]:::backend
            URLRouter["URL Router"]:::backend
            Views["Views"]:::backend
            Serializers["Serializers"]:::backend
            DjangoModels["Django ORM Models"]:::backend
            ManagementCmds["populate_prisms Command"]:::backend
            Entrypoints["WSGI/ASGI Entrypoints"]:::backend
            WebDB["PostgreSQL/MySQL Database"]:::backend
        end
        subgraph "Frontend (React)"
            direction TB
            IndexJS["index.js"]:::frontend
            AppJS["App.js"]:::frontend
            PrismSelector["PrismSelector"]:::frontend
            PrismViewer["PrismViewer"]:::frontend
            ThreeDViewer["ThreeDViewer"]:::frontend
            StaticHTML["public/index.html"]:::frontend
            PackageJSON["package.json"]:::frontend
            GitIgnore[".gitignore"]:::frontend
        end
    end

    subgraph "CI/CD & Build Tools"
        direction TB
        GitHubActions["GitHub Actions CI"]:::ci
        PytestConf["pytest.ini"]:::ci
        PyProject["pyproject.toml"]:::ci
        ReqRoot["requirements.txt"]:::ci
        ReqBackend["src/web/backend/requirements.txt"]:::ci
        PyInstallerOut["PrismViewer.exe"]:::ci
        README["README.md"]:::ci
        Docs["DELIVERY_SUMMARY.md"]:::ci
    end

    %% Relationships
    DesktopLauncher -->|launches| MainWindow
    MainWindow -->|invokes| PluginManager
    MainWindow -->|renders| CADRenderer
    CADRenderer -->|loads| PluginInterface
    PluginManager -->|manages| CylinderPlugin
    PluginManager -->|manages| RectPrismPlugin
    CoreModels -->|stores data in| LocalDB

    IndexJS -->|loads| AppJS
    AppJS -->|renders| PrismSelector
    AppJS -->|renders| PrismViewer
    AppJS -->|renders| ThreeDViewer
    PrismSelector -->|fetches| URLRouter
    PrismViewer -->|fetches| URLRouter
    ThreeDViewer -->|fetches| URLRouter

    URLRouter -->|routes to| Views
    Views -->|use| Serializers
    Views -->|use| DjangoModels
    Serializers -->|serialize| DjangoModels
    DjangoModels -->|persist to| WebDB
    ManagementCmds -->|use| DjangoModels
    Entrypoints -->|serve| URLRouter
    ManageScript -->|executes| Entrypoints

    GitHubActions -->|runs tests| PytestConf
    GitHubActions -->|builds desktop| PyInstallerOut
    GitHubActions -->|builds web| PackageJSON
    GitHubActions -->|uses| PyProject
    GitHubActions -->|uses| ReqRoot
    GitHubActions -->|uses| ReqBackend
    GitHubActions -->|publishes docs| README
    GitHubActions -->|publishes docs| Docs

    %% Core reused by web backend
    PluginInterface -->|shared| Views
    PluginManager -->|shared| Views
    CoreModels -->|shared| DjangoModels

    %% Click Events
    click CoreModels "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/models.py"
    click CoreDB "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/database.py"
    click PluginInterface "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/plugin_interface.py"
    click PluginManager "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/plugin_manager.py"
    click CylinderPlugin "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/plugins/cylinder_plugin.py"
    click RectPrismPlugin "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/core/plugins/rectangular_prism_plugin.py"

    click DesktopLauncher "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/run_desktop.py"
    click MainWindow "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/desktop/main_window.py"
    click CADRenderer "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/desktop/cad_renderer.py"

    click ManageScript "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/manage.py"
    click URLRouter "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prism_viewer_api/urls.py"
    click Views "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prisms/views.py"
    click Serializers "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prisms/serializers.py"
    click DjangoModels "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prisms/models.py"
    click ManagementCmds "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prisms/management/commands/populate_prisms.py"
    click Entrypoints "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prism_viewer_api/asgi.py"
    click Entrypoints "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/prism_viewer_api/wsgi.py"

    click IndexJS "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/src/index.js"
    click AppJS "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/src/App.js"
    click PrismSelector "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/src/components/PrismSelector.js"
    click PrismViewer "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/src/components/PrismViewer.js"
    click ThreeDViewer "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/src/components/ThreeDViewer.js"
    click StaticHTML "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/public/index.html"
    click PackageJSON "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/package.json"
    click GitIgnore "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/frontend/.gitignore"

    click GitHubActions "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/.github/workflows/ci.yml"
    click PytestConf "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/pytest.ini"
    click PyProject "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/pyproject.toml"
    click ReqRoot "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/requirements.txt"
    click ReqBackend "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/src/web/backend/requirements.txt"
    click PyInstallerOut "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/PrismViewer.exe"
    click README "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/README.md"
    click Docs "https://github.com/osdagscreeningtasks/prismshapeviewer/blob/main/DELIVERY_SUMMARY.md"

    %% Styles
    classDef core fill:#ffe699,stroke:#b58900,color:#000
    classDef desktop fill:#c6e2ff,stroke:#2b5797,color:#000
    classDef backend fill:#d5f5e3,stroke:#196f3d,color:#000
    classDef frontend fill:#f9d5e5,stroke:#c2185b,color:#000
    classDef ci fill:#e8eaf6,stroke:#303f9f,color:#000
```
