feat: Introduce 3D model viewing and upload capabilities, refine cost calculation, and simplify Docker setup.
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -16,7 +16,7 @@ COPY . .
|
|||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM oven/bun:1-slim AS production
|
FROM oven/bun:1 AS production
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -43,16 +43,5 @@ ENV PORT=3000
|
|||||||
# Expose the port
|
# Expose the port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Create a non-root user
|
|
||||||
RUN addgroup --system --gid 1001 nodejs && \
|
|
||||||
adduser --system --uid 1001 filaprint && \
|
|
||||||
chown -R filaprint:nodejs /app
|
|
||||||
|
|
||||||
USER filaprint
|
|
||||||
|
|
||||||
# Health check
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
||||||
CMD curl -f http://localhost:3000/ || exit 1
|
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["bun", "run", "start"]
|
CMD ["bun", "run", "start"]
|
||||||
|
|||||||
144
README.md
144
README.md
@@ -1,6 +1,8 @@
|
|||||||
# Filaprint
|
# Filaprint
|
||||||
|
|
||||||
Filaprint is a modern, premium web application designed to help 3D printing enthusiasts manage their filament inventory, track print jobs, and calculate costs and energy usage.
|
Filaprint is a modern, premium web application designed to help 3D printing enthusiasts manage their filament inventory, track print jobs, view 3D models, and calculate costs and energy usage.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## 🛠️ Technology Stack
|
## 🛠️ Technology Stack
|
||||||
|
|
||||||
@@ -9,10 +11,12 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
- **Styling:** Tailwind CSS v4 (Cerberus Theme)
|
- **Styling:** Tailwind CSS v4 (Cerberus Theme)
|
||||||
- **State Management:** Svelte 5 Runes
|
- **State Management:** Svelte 5 Runes
|
||||||
- **Build Tool:** Vite
|
- **Build Tool:** Vite
|
||||||
|
- **3D Rendering:** Three.js (STL & OBJ loaders)
|
||||||
- **Data Visualization:** Chart.js
|
- **Data Visualization:** Chart.js
|
||||||
- **Icons:** Iconify (@iconify/svelte)
|
- **Icons:** Iconify (@iconify/svelte)
|
||||||
- **Database:** MongoDB with Mongoose
|
- **Database:** MongoDB with Mongoose
|
||||||
- **Authentication:** JWT with bcrypt password hashing
|
- **Authentication:** JWT with bcrypt password hashing
|
||||||
|
- **Container:** Docker with Docker Compose
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
|
|
||||||
@@ -37,23 +41,39 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
|
|
||||||
- **Log Prints:**
|
- **Log Prints:**
|
||||||
- Link to specific Printer and Filament Spool.
|
- Link to specific Printer and Filament Spool.
|
||||||
- Duration (minutes) and Weight used (g).
|
- Duration input with hours and minutes fields.
|
||||||
- Calculated Cost (auto-calculated or manual override).
|
- Weight used (g) and calculated cost (auto or manual).
|
||||||
- Status: Success, Fail, Cancelled, **In Progress**.
|
- Status: Success, Fail, Cancelled, **In Progress**.
|
||||||
|
- **3D Model Upload:** Attach STL or OBJ files to prints.
|
||||||
- **In Progress Tracking:**
|
- **In Progress Tracking:**
|
||||||
- Assign printer and spool to active jobs.
|
- Assign printer and spool to active jobs.
|
||||||
- Specify elapsed time for accurate dashboard countdown.
|
- Specify elapsed time for accurate dashboard countdown.
|
||||||
- Real-time progress display on dashboard.
|
- Real-time progress display on dashboard.
|
||||||
|
- **Cost Calculation:**
|
||||||
|
- Filament cost based on spool price and weight used.
|
||||||
|
- Electricity cost based on printer power consumption and duration.
|
||||||
|
- User-configurable electricity rate ($/kWh).
|
||||||
- **Edit/Delete:** Full CRUD operations for print history.
|
- **Edit/Delete:** Full CRUD operations for print history.
|
||||||
- **History:** Clickable entries with detailed information.
|
- **History:** Clickable entries with detailed information.
|
||||||
|
|
||||||
### 4. Printer Configuration
|
### 4. 3D Model Library
|
||||||
|
|
||||||
|
- **Model Gallery:** Browse all uploaded 3D models in a grid layout.
|
||||||
|
- **Interactive 3D Viewer:**
|
||||||
|
- Support for STL and OBJ file formats.
|
||||||
|
- Orbit controls (rotate, pan, zoom).
|
||||||
|
- Touch support for mobile devices.
|
||||||
|
- Auto-rotation with stop on interaction.
|
||||||
|
- **Upload Progress:** Progress bar with percentage for model uploads.
|
||||||
|
- **Full-Screen View:** Click to view models in an immersive full-screen viewer.
|
||||||
|
|
||||||
|
### 5. Printer Configuration
|
||||||
|
|
||||||
- **Profiles:** Manage multiple printers with custom names.
|
- **Profiles:** Manage multiple printers with custom names.
|
||||||
- **Specs:** Model name, Power consumption (Watts), Nozzle diameter (mm).
|
- **Specs:** Model name, Power consumption (Watts), Nozzle diameter (mm).
|
||||||
- **Configure Button:** Edit or delete printer profiles.
|
- **Configure Button:** Edit or delete printer profiles.
|
||||||
|
|
||||||
### 5. Analytics
|
### 6. Analytics
|
||||||
|
|
||||||
- **Daily Filament Usage:** Line chart showing filament consumption over time.
|
- **Daily Filament Usage:** Line chart showing filament consumption over time.
|
||||||
- **Daily Electricity Usage:** Bar chart showing power consumption in kWh.
|
- **Daily Electricity Usage:** Bar chart showing power consumption in kWh.
|
||||||
@@ -61,10 +81,13 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
- **Material Distribution:** Doughnut chart showing material breakdown.
|
- **Material Distribution:** Doughnut chart showing material breakdown.
|
||||||
- **Stats Summary:** Total prints, success rate, total electricity used.
|
- **Stats Summary:** Total prints, success rate, total electricity used.
|
||||||
|
|
||||||
### 6. User Management
|
### 7. User Management
|
||||||
|
|
||||||
- **Authentication:** Secure login/registration with JWT tokens.
|
- **Authentication:** Secure login/registration with JWT tokens.
|
||||||
- **User Settings:** Profile editing and password change.
|
- **User Settings:**
|
||||||
|
- Profile editing (username, location).
|
||||||
|
- Electricity rate configuration ($/kWh).
|
||||||
|
- Password change.
|
||||||
- **Admin Panel:** Manage users (Admin role only).
|
- **Admin Panel:** Manage users (Admin role only).
|
||||||
- **Role-Based Access:** Admin and User roles with appropriate permissions.
|
- **Role-Based Access:** Admin and User roles with appropriate permissions.
|
||||||
|
|
||||||
@@ -74,9 +97,11 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
|
|
||||||
- `_id`: ObjectId
|
- `_id`: ObjectId
|
||||||
- `username`: String (Required, Unique)
|
- `username`: String (Required, Unique)
|
||||||
- `email`: String
|
|
||||||
- `password`: String (Hashed with bcrypt)
|
- `password`: String (Hashed with bcrypt)
|
||||||
- `role`: String (Enum: User, Admin)
|
- `role`: String (Enum: User, Admin)
|
||||||
|
- `location`: String
|
||||||
|
- `electricity_rate`: Number (Default: 0.12 $/kWh)
|
||||||
|
- `currency`: String (Default: USD)
|
||||||
- `createdAt`: Date
|
- `createdAt`: Date
|
||||||
|
|
||||||
### Spool Schema
|
### Spool Schema
|
||||||
@@ -110,9 +135,11 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
- `name`: String
|
- `name`: String
|
||||||
- `duration_minutes`: Number
|
- `duration_minutes`: Number
|
||||||
- `filament_used_g`: Number
|
- `filament_used_g`: Number
|
||||||
- `calculated_cost_filament`: Number
|
- `calculated_cost_filament`: Number (Total cost including electricity)
|
||||||
|
- `calculated_cost_energy`: Number (Electricity cost only)
|
||||||
- `status`: String (Enum: Success, Fail, Cancelled, In Progress)
|
- `status`: String (Enum: Success, Fail, Cancelled, In Progress)
|
||||||
- `started_at`: Date (For In Progress jobs)
|
- `started_at`: Date (For In Progress jobs)
|
||||||
|
- `stl_file`: String (Path to uploaded 3D model)
|
||||||
- `date`: Date (Default: Date.now)
|
- `date`: Date (Default: Date.now)
|
||||||
|
|
||||||
## 🚀 Getting Started
|
## 🚀 Getting Started
|
||||||
@@ -121,8 +148,9 @@ Filaprint is a modern, premium web application designed to help 3D printing enth
|
|||||||
|
|
||||||
- Node.js 18+ or Bun
|
- Node.js 18+ or Bun
|
||||||
- MongoDB instance (local or Atlas)
|
- MongoDB instance (local or Atlas)
|
||||||
|
- Docker (optional, for containerized deployment)
|
||||||
|
|
||||||
### Installation
|
### Local Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone the repository
|
# Clone the repository
|
||||||
@@ -138,36 +166,79 @@ cp .env.example .env
|
|||||||
|
|
||||||
# Run development server
|
# Run development server
|
||||||
bun run dev
|
bun run dev
|
||||||
|
|
||||||
|
# Build for production
|
||||||
|
bun run build
|
||||||
|
|
||||||
|
# Start production server
|
||||||
|
bun run start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker Deployment
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copy environment file
|
||||||
|
cp .env.example .env
|
||||||
|
# Edit .env with secure values
|
||||||
|
|
||||||
|
# Build and start containers
|
||||||
|
docker compose up -d --build
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker compose logs -f filaprint
|
||||||
|
|
||||||
|
# Stop containers
|
||||||
|
docker compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
```env
|
```env
|
||||||
|
# MongoDB Connection
|
||||||
MONGODB_URI=mongodb://localhost:27017/filaprint
|
MONGODB_URI=mongodb://localhost:27017/filaprint
|
||||||
|
|
||||||
|
# JWT Secret (use a secure random string in production)
|
||||||
JWT_SECRET=your-super-secret-jwt-key
|
JWT_SECRET=your-super-secret-jwt-key
|
||||||
|
|
||||||
|
# Application Origin (required for CSRF protection)
|
||||||
|
ORIGIN=http://localhost:3000
|
||||||
|
|
||||||
|
# Docker MongoDB Settings
|
||||||
|
MONGO_USER=admin
|
||||||
|
MONGO_PASSWORD=changeme
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📁 Project Structure
|
## 📁 Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
src/
|
filaprint/
|
||||||
├── lib/
|
├── src/
|
||||||
│ ├── components/
|
│ ├── lib/
|
||||||
│ │ ├── ui/ # Base UI components (Button, Card, Input, Modal)
|
│ │ ├── components/
|
||||||
│ │ ├── prints/ # Print-specific components (LogPrintModal, EditPrintModal)
|
│ │ │ ├── ui/ # Base UI components (Button, Card, Input, Modal)
|
||||||
│ │ └── Navbar.svelte
|
│ │ │ ├── prints/ # Print-specific components (LogPrintModal, EditPrintModal)
|
||||||
│ ├── models/ # Mongoose schemas
|
│ │ │ ├── STLViewer.svelte # 3D model viewer (STL & OBJ)
|
||||||
│ └── server/ # Server utilities (db connection, auth)
|
│ │ │ └── Navbar.svelte
|
||||||
├── routes/
|
│ │ ├── models/ # Mongoose schemas
|
||||||
│ ├── admin/users/ # Admin user management
|
│ │ └── server/ # Server utilities (db connection, auth)
|
||||||
│ ├── analytics/ # Analytics dashboard
|
│ ├── routes/
|
||||||
│ ├── login/ # Authentication
|
│ │ ├── admin/users/ # Admin user management
|
||||||
│ ├── printers/ # Printer management
|
│ │ ├── analytics/ # Analytics dashboard
|
||||||
│ ├── prints/ # Print job logging
|
│ │ ├── api/upload-stl/ # 3D model upload endpoint
|
||||||
│ ├── register/ # User registration
|
│ │ ├── library/ # 3D model library
|
||||||
│ ├── settings/ # User settings
|
│ │ ├── login/ # Authentication
|
||||||
│ └── spools/ # Filament inventory
|
│ │ ├── printers/ # Printer management
|
||||||
└── app.css # Global styles (Cerberus theme)
|
│ │ ├── prints/ # Print job logging
|
||||||
|
│ │ ├── register/ # User registration
|
||||||
|
│ │ ├── settings/ # User settings
|
||||||
|
│ │ └── spools/ # Filament inventory
|
||||||
|
│ └── app.css # Global styles (Cerberus theme)
|
||||||
|
├── static/
|
||||||
|
│ └── uploads/models/ # Uploaded 3D model files
|
||||||
|
├── server/ # Production server
|
||||||
|
├── Dockerfile # Container build instructions
|
||||||
|
├── docker-compose.yml # Container orchestration
|
||||||
|
└── package.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## ✅ Completed Features
|
## ✅ Completed Features
|
||||||
@@ -177,18 +248,23 @@ src/
|
|||||||
- [x] Spool management (CRUD)
|
- [x] Spool management (CRUD)
|
||||||
- [x] Printer management (CRUD)
|
- [x] Printer management (CRUD)
|
||||||
- [x] Print job logging with "In Progress" support
|
- [x] Print job logging with "In Progress" support
|
||||||
- [x] Cost calculation (auto and manual)
|
- [x] Duration input with hours/minutes fields
|
||||||
|
- [x] Cost calculation (filament + electricity)
|
||||||
|
- [x] User-configurable electricity rate
|
||||||
- [x] Filament deduction on print completion
|
- [x] Filament deduction on print completion
|
||||||
- [x] Analytics with Chart.js (filament, electricity, materials)
|
- [x] Analytics with Chart.js (filament, electricity, materials)
|
||||||
- [x] User settings (profile, password change)
|
- [x] 3D Model Library with interactive viewer
|
||||||
|
- [x] STL and OBJ file upload with progress bar
|
||||||
|
- [x] Mobile hamburger menu (solid background)
|
||||||
|
- [x] User settings (profile, location, electricity rate, password)
|
||||||
- [x] Admin user management panel
|
- [x] Admin user management panel
|
||||||
- [x] Browser notifications for completed prints
|
- [x] Browser notifications for completed prints
|
||||||
- [x] Iconify icon library integration
|
- [x] Iconify icon library integration
|
||||||
- [x] Responsive design
|
- [x] Responsive design
|
||||||
|
- [x] Docker containerization
|
||||||
|
|
||||||
## 🔮 Future Enhancements
|
## 🔮 Future Enhancements
|
||||||
|
|
||||||
- [ ] 3D spool visualization with Threlte
|
|
||||||
- [ ] QR/Barcode scanning for quick spool lookup
|
- [ ] QR/Barcode scanning for quick spool lookup
|
||||||
- [ ] Photo uploads for print jobs
|
- [ ] Photo uploads for print jobs
|
||||||
- [ ] Export data (CSV/PDF reports)
|
- [ ] Export data (CSV/PDF reports)
|
||||||
@@ -196,3 +272,9 @@ src/
|
|||||||
- [ ] Dark/Light theme toggle
|
- [ ] Dark/Light theme toggle
|
||||||
- [ ] Email notifications
|
- [ ] Email notifications
|
||||||
- [ ] Print job templates
|
- [ ] Print job templates
|
||||||
|
- [ ] 3D printer integration (OctoPrint, Klipper)
|
||||||
|
- [ ] Thumbnail generation for 3D models
|
||||||
|
|
||||||
|
## 📄 License
|
||||||
|
|
||||||
|
MIT License - See LICENSE file for details.
|
||||||
|
|||||||
Reference in New Issue
Block a user