Ken-u/3DViewer

★ 0Forks 0PythonGitHub ↗Compare

README

CadQuery 3D Model Generator

A LAN-accessible web application that allows users to interact with AI through natural language to generate CadQuery Python code, execute it to create 3D models, and preview them in real-time in the browser.

Tech Stack

Module Technology
Frontend Framework React 18
3D Preview model-viewer
Code Editor Monaco Editor
Backend Framework FastAPI
3D Modeling CadQuery
Database SQLite
AI Models Claude / OpenAI / Ollama (user configurable)

Development

Prerequisites

  • Python 3.12+
  • Node.js 18+
  • uv (Python package manager)

Platform Notice:

⚠️ CadQuery's OCP kernel (cadquery-ocp) does not have wheels for Linux ARM64 (aarch64). The application runs on:

  • x86_64 Linux
  • macOS (Intel/ARM)
  • Windows

Quick Start

One-click startup (automatically installs dependencies):

./start.sh

This will:

  1. Install backend dependencies via uv sync
  2. Install frontend dependencies via npm install
  3. Start backend on port 8000
  4. Start frontend on port 5173

Press Ctrl+C to stop all services.

Manual Start

Backend

cd backend
uv sync
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Frontend

cd frontend
npm install
npm run dev -- --host 0.0.0.0 --port 5173

Environment Variables

Copy backend/.env.example to backend/.env and configure:

Variable Description Default
APP_NAME Application name CadQuery 3D Generator
API_PREFIX API route prefix /api
DATABASE_URL SQLite database URL sqlite:///./app.db
MODEL_OUTPUT_DIR Directory for generated GLB files models
CORS_ORIGINS Allowed CORS origins http://localhost:5173
DEFAULT_PROVIDER Default AI provider openai

Architecture

Frontend (React)
    |
    | REST API / SSE
    v
Backend (FastAPI)
    |-- API Layer: /api/chat, /api/execute, /api/models, /api/config
    |-- Service Layer: AIService, CodeExecutor, ModelConverter
    |-- Data Layer: SQLite (config, conversations, models)

Features

  • Natural language to CadQuery code generation via AI
  • Real-time 3D model preview with model-viewer
  • Monaco code editor with syntax highlighting
  • Support for multiple AI providers (OpenAI, Claude, Ollama)
  • Model history management
  • GLB file download

Contributors

Ken-u

Issues