Skip to content

Prism Viewer is a modular 3D shape visualization and analysis application, developed as part of a recruitment screening assignment. The project demonstrates cross-platform development with a shared core, supporting both desktop and web interfaces, and a plugin system for extensibility.

Notifications You must be signed in to change notification settings

OsdagScreeningTasks/PrismShapeViewer

 
 

Repository files navigation

🔷 Prism Viewer

A cross-platform, modular application for 3D visualization of geometric shapes with plugin support.

🎯 Overview

Prism Viewer is a comprehensive application that provides:

  • Desktop Application → Python (PySide2) with 3D visualization
  • Web Application → Django (backend) + React (frontend)
  • Shared Core → Business logic, calculations, and database access
  • Plugin System → Install new shapes at runtime
  • 3D Visualization → Both desktop and web platforms
  • CI/CD Pipeline → Automated testing and deployment

🏗️ Architecture

/src/
├── core/                 # Shared business logic
│   ├── models.py        # Data models
│   ├── database.py      # Database management
│   ├── plugin_manager.py # Plugin system
│   └── plugins/         # Default plugins
├── desktop/             # PySide2 desktop app
│   ├── main_window.py   # Main application window
│   └── cad_renderer.py  # 3D rendering with pythonOCC
└── web/                 # Web application
    ├── backend/         # Django REST API
    └── frontend/        # React frontend

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • SQLite (for desktop) or PostgreSQL/MySQL (for web)

Desktop Application

# Install dependencies
pip install -r requirements.txt

# Run desktop application
python src/desktop/main_window.py

Web Application

Backend (Django)

cd src/web/backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Populate sample data
python manage.py populate_prisms

# Start development server
python manage.py runserver

Frontend (React)

cd src/web/frontend

# Install dependencies
npm install

# Start development server
npm start

The web application will be available at:

📦 API Endpoints

The Django backend provides the following REST API endpoints:

  • GET /api/prisms/ → List all prism designations
  • GET /api/prisms/<id>/ → Get prism dimensions and details
  • GET /api/prisms/<id>/compute/ → Get calculated volume and surface area
  • GET /api/prisms/<id>/cad/ → Get CAD model data for 3D visualization
  • POST /api/prisms/ → Create a new prism
  • PUT /api/prisms/<id>/ → Update an existing prism
  • DELETE /api/prisms/<id>/ → Delete a prism

🔌 Plugin System

The application supports a modular plugin system for adding new geometric shapes:

Creating a Plugin

  1. Inherit from ShapePlugin base class
  2. Implement required methods:
    • calculate_volume()
    • calculate_surface_area()
    • generate_cad_data()
    • get_parameters()

Example Plugin

from core.plugin_interface import ShapePlugin

class CylinderPlugin(ShapePlugin):
    @property
    def name(self):
        return "Cylinder"
    
    def calculate_volume(self, **parameters):
        radius = parameters['radius']
        height = parameters['height']
        return 3.14159 * radius * radius * height
    
    # ... implement other required methods

Installing Plugins

Plugins can be installed at runtime from GitHub repositories:

plugin_manager.install_plugin_from_repo(
    "https://github.com/user/cylinder-plugin",
    "CylinderPlugin"
)

🎨 UI Flow

  1. Home Screen → Select shape type (Rectangular Prism, or installed plugins)
  2. Shape Selection → Choose specific prism/shape instance
  3. Calculations → View volume and surface area
  4. 3D Visualization → Display interactive 3D model

🛠️ Development

Code Style

The project uses:

  • Black for Python code formatting
  • isort for import sorting
  • flake8 for linting
  • ESLint for JavaScript/React code
# Format Python code
black src/ tests/

# Sort imports
isort src/ tests/

# Lint Python code
flake8 src/ tests/

Building Desktop Application

# Install PyInstaller
pip install pyinstaller

# Build executable
pyinstaller --onefile --windowed --name PrismViewer src/desktop/main_window.py

🚀 Deployment

Web Application

The web application can be deployed using:

  • Backend: Django with Gunicorn + Nginx
  • Frontend: React build served by Nginx
  • Database: PostgreSQL or MySQL for production

Desktop Application

The desktop application can be packaged using:

  • PyInstaller for cross-platform executables
  • GitHub Actions for automated builds

About

Prism Viewer is a modular 3D shape visualization and analysis application, developed as part of a recruitment screening assignment. The project demonstrates cross-platform development with a shared core, supporting both desktop and web interfaces, and a plugin system for extensibility.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.1%
  • JavaScript 19.6%
  • CSS 2.7%
  • HTML 0.6%