An interactive 3D bin packing visualizer with FFD and Best Fit algorithms — runs entirely in the browser, no backend required.
- 🎯 Two Packing Algorithms: First Fit Decreasing (FFD) and Best Fit, implemented in JavaScript and run client-side
- 🎨 Interactive 3D Visualization: Rotate, zoom, and pan the 3D view
- 🌓 Dark/Light Mode: Toggle between themes with system-preference detection
- 📱 Responsive Design: Works on desktop and mobile
- 📊 Real-time Statistics: Space utilization, packed items count, unpacked items list
- 🎲 Quick Actions: Load sample items or clear the workspace in one click
The frontend runs the packing algorithms entirely in the browser — no backend needed.
cd frontend
npm install
npm run devOpen http://localhost:5173 in your browser.
A standalone FastAPI backend is also provided if you need the packing algorithms exposed as an API.
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000API docs available at http://localhost:8000/docs.
cd frontend
npm run deploy├── backend/
│ ├── main.py # FastAPI server (optional)
│ ├── models.py # Pydantic schemas
│ ├── algorithms/
│ │ ├── ffd.py # First Fit Decreasing
│ │ └── best_fit.py # Best Fit algorithm
│ └── requirements.txt
│
├── frontend/
│ ├── src/
│ │ ├── App.jsx # Main component
│ │ ├── components/
│ │ │ ├── Viewport3D.jsx
│ │ │ ├── BinConfig.jsx
│ │ │ ├── ItemForm.jsx
│ │ │ ├── ItemList.jsx
│ │ │ ├── Results.jsx
│ │ │ └── AlgorithmSelector.jsx
│ │ ├── lib/
│ │ │ └── binPacking.js # Client-side packing algorithms (JS)
│ │ ├── App.css
│ │ └── index.css
│ └── package.json
│
└── PRD.txt # Product Requirements Document
POST /api/pack
Request:
{
"bin": { "width": 10, "height": 10, "depth": 10 },
"items": [
{ "id": "1", "width": 3, "height": 2, "depth": 4 }
],
"algorithm": "ffd"
}Response:
{
"success": true,
"utilization": 68.5,
"packedItems": [...],
"unpackedItems": [],
"stats": { ... }
}GET /api/algorithms
- Frontend: React 18, Three.js, React Three Fiber, Vite
- Packing Logic: Pure JavaScript (client-side,
src/lib/binPacking.js) - Backend (optional): Python, FastAPI, Pydantic
- Styling: Custom CSS with CSS Variables
- Deploy: GitHub Pages (
npm run deploy)
MIT