Spaces:
Running
Running
NaturalCAD Architecture Plan
Current State (2026-04-12)
We successfully pivoted away from a complex (and broken) Fly.io worker and Hugging Face Docker setup, replacing the backend engine entirely with Modal.
What's Working
- β
LLM Code Generation: Using
Qwen/Qwen2.5-Coder-32B-Instructvia Hugging Face Serverless Inference API inside Modal. - β
CAD Execution Engine: Modal spins up a
python:3.10-slimcontainer with proper Linux OpenGL libraries (libgl1,libglib2.0-0, etc).build123druns locally on the T4 GPU container. - β
Artifact Upload: Modal container runs CAD, creates STL, STEP, and a browser-ready GLB using
trimesh, and uploads directly to Supabase Storage, returning public URLs. - β HF Spaces UI: Front-end UI remains on Hugging Face Spaces.
What's Deprecated
- β Fly.io backend routing and worker loops (too much complexity/overhead for MVP).
- β Hugging Face native Docker CAD execution (lacks host graphics libs for VTK).
Target Architecture
βββββββββββββββ
β User ββββββΆ HF Spaces (Gradio UI)
β Prompt β
βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Modal Web Endpoint β
β β
β 1. Calls HF Inference API (Qwen 2.5) β
β 2. LLM writes build123d Python script β
β 3. Executes script on Modal Container β
β 4. Generates STL + STEP + GLB preview β
β 5. Uploads files to Supabase β
β 6. Returns 3 URLs back to HF Space β
βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Supabase β
β Storage β
ββββββββββββββββ
Services
| Service | Role | Cost | Status |
|---|---|---|---|
| HF Spaces | UI/Frontend | Free tier | β Ready |
| Modal | Web API + LLM call + CAD Execution | Pay-per-use GPU | β Ready |
| HF Inference API | LLM (textβcode) | Free within limits | β Ready |
| Supabase | DB + Storage | Free tier | β Ready |
Implementation Order
- β Create Modal function for CAD execution
- β Add LLM generation via HF to the Modal container
- β Add Supabase Artifact Upload returning public URL
- π² Deploy Modal Web Endpoint to get a live URL
- π² Wire HF Spaces to hit the Modal endpoint, parsing out the STL, STEP, and GLB urls into the Gradio UI.
Updated: 2026-04-12