A web-based Computer-Aided Design application built with a modern three-tier architecture. Dimes CAD provides sketch-based 3D modeling capabilities similar to professional CAD software like SolidWorks, accessible through a browser interface.
Dimes CAD enables users to create 3D models through a sketch-and-extrude workflow:
- Create a sketch plane (XY, XZ, or YZ orientation)
- Draw 2D geometry on the sketch plane (lines, circles, rectangles, arcs, polygons)
- Apply sketch modifications (fillet, chamfer, trim, extend, mirror, offset, copy, move)
- Extrude 2D profiles into 3D solid geometry
- Export models to standard CAD formats (STEP, STL, OBJ, IGES)
The application also supports AI-driven CAD operations through the Daydreams framework, allowing natural language interaction for model creation.
Dimes CAD uses a three-tier architecture that separates concerns for security, scalability, and maintainability:
┌─────────────────┐ WebSocket/HTTP ┌─────────────────┐ HTTP ┌─────────────────┐
│ │ ─────────────────────>│ │ ───────────────>│ │
│ Frontend │ │ API Server │ │ CAD Backend │
│ Next.js/Three.js│ │ Node.js/Express│ │ Python/pythonOCC│
│ Port 3001 │ <─────────────────────│ Port 3000 │ <───────────────│ Port 8080 │
└─────────────────┘ (viz updates) └─────────────────┘ (response) └─────────────────┘
The client layer built with Next.js and Three.js handles:
- 3D viewport rendering and camera controls
- User input for drawing tools and sketch operations
- Real-time geometry visualization via WebSocket
- Session management and state
Key components:
CADApplication- Main orchestrator for state and UICADRenderer- Three.js scene management and raycastingCADClient- HTTP and WebSocket communicationCADControls- Drawing tools and input handling
The Node.js middleware layer provides:
- Request validation and sanitization
- Session management
- Rate limiting and security headers
- Protocol translation between web and Python backend
- WebSocket management for real-time updates
- AI agent integration via Daydreams framework
The Python backend powered by pythonOCC (OpenCASCADE bindings) handles:
- Geometric kernel operations (shape creation, boolean operations)
- 2D sketch management and element storage
- Tessellation for mesh generation
- Export to CAD file formats
The application follows a strict request-response pattern where the client never communicates directly with the Python backend. For detailed documentation of data flow patterns, see Docs/data-flow.md.
- User performs an action in the viewport (e.g., draws a rectangle)
- Frontend converts screen coordinates to sketch plane coordinates
CADClientsends HTTP request to API Server with session ID- API Server validates request and flattens parameters
- API Server forwards request to Python backend
- Python backend creates geometry and generates visualization data
- API Server broadcasts visualization data via WebSocket
- API Server returns HTTP response to client
- Frontend renders the new geometry in Three.js scene
Real-time updates use these message types:
| Type | Purpose |
|---|---|
visualization_data |
2D sketch element created (plane, sketch, element) |
geometry_update |
3D mesh data from extrusion or boolean operation |
connection_established |
Initial WebSocket connection confirmed |
agent_message |
AI agent response |
- Python 3.9 or higher with pythonOCC
- Node.js 18 or higher
- Docker (recommended for Python backend)
cd serverpy/app
# Using Docker (recommended)
docker-compose up -d
# Or run locally
pip install -r requirements.txt
python src/main.pycd api-server
npm install
cp env.example .env
npm run devcd client
npm install
npm run devNavigate to http://localhost:3001 in your browser.
The API Server uses these environment variables (see api-server/env.example):
| Variable | Default | Description |
|---|---|---|
PORT |
3000 | API server port |
CAD_BACKEND_HOST |
127.0.0.1 | Python backend hostname |
CAD_BACKEND_PORT |
8080 | Python backend port |
CAD_BACKEND_TIMEOUT |
30000 | Request timeout in milliseconds |
CORS_ORIGIN |
http://localhost:3001 | Allowed CORS origins |
WS_HEARTBEAT_INTERVAL |
30000 | WebSocket ping interval |
For Railway deployment, use internal networking:
CAD_BACKEND_HOST=cad-backend.railway.internal
| Key | Tool |
|---|---|
| L | Line |
| C | Circle |
| R | Rectangle |
| A | Arc |
| P | Polygon |
| Key | Tool |
|---|---|
| F | Fillet |
| H | Chamfer |
| T | Trim |
| W | Extend |
| M | Mirror |
| O | Offset |
| D | Duplicate/Copy |
| G | Move |
| Key | Action |
|---|---|
| Escape | Return to select tool / Exit sketch |
| X or Delete | Delete selected element |
| E | Extrude selected element |
dimes/
├── client/ # Next.js frontend
│ └── src/
│ ├── components/ # React components
│ └── lib/cad/ # CAD client library
│ ├── api/ # HTTP/WebSocket client
│ ├── controls/ # Input handling
│ ├── renderer/ # Three.js rendering
│ └── mesh/ # Mesh management
├── api-server/ # Node.js API layer
│ └── src/
│ ├── routes/ # API endpoints
│ ├── services/ # Backend client, WebSocket
│ ├── middleware/ # Validation, session
│ └── agent/ # Daydreams AI integration
├── serverpy/ # Python CAD backend
│ └── app/src/
│ ├── geometry_engine.py # Core CAD engine
│ ├── api_server.py # FastAPI endpoints
│ └── session_manager.py # Session storage
└── Docs/ # Documentation
├── data-flow.md # Detailed data flow
├── openapi.yaml # API specification
└── known-issues.md # Issue tracking
See Docs/openapi.yaml for the complete OpenAPI specification.
| Endpoint | Method | Description |
|---|---|---|
/api/v1/cad/sketch-planes |
POST | Create a sketch plane |
/api/v1/cad/sketches |
POST | Create a sketch on a plane |
/api/v1/cad/sketch-elements |
POST | Add element to sketch |
/api/v1/cad/extrude |
POST | Extrude sketch to 3D |
/api/v1/cad/fillets |
POST | Add fillet between lines |
/api/v1/cad/chamfers |
POST | Add chamfer between lines |
/api/v1/cad/sessions/{id}/export/{format} |
GET | Export model |
/api/v1/health |
GET | Health check |
See Docs/known-issues.md for current issues and their status.
Key limitations:
- No undo/redo functionality
- No parametric constraint system
- Sessions are not persisted (in-memory only)
- Sketch-on-face limited to axis-aligned planes
Verify the Python backend is running:
curl http://localhost:8080/api/v1/healthCheck environment variables match between API server and backend.
Ensure the session ID format is valid and the WebSocket URL uses the correct protocol (ws:// for local, wss:// for production).
Update CORS_ORIGIN in the API server environment to include your frontend URL.
MIT License - see LICENSE file for details.