Compare commits
1 Commits
agent/sket
...
agent/hex/
| Author | SHA1 | Date | |
|---|---|---|---|
| a5a9f42d06 |
7
backend/go.mod
Normal file
7
backend/go.mod
Normal file
@@ -0,0 +1,7 @@
|
||||
module github.com/CubeCraft-Creations/Extrudex/backend
|
||||
|
||||
go 1.24
|
||||
|
||||
require (
|
||||
github.com/jackc/pgx/v5 v5.7.4
|
||||
)
|
||||
162
backend/internal/models/models.go
Normal file
162
backend/internal/models/models.go
Normal file
@@ -0,0 +1,162 @@
|
||||
// Package models defines the Extrudex domain model structs.
|
||||
// These map 1:1 to PostgreSQL tables with snake_case JSON serialization.
|
||||
// Nullable fields use pointer types; all timestamps are time.Time.
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// ============================================================================
|
||||
// Lookup Tables
|
||||
// ============================================================================
|
||||
|
||||
// PrinterType represents a printer technology category (fdm, resin, etc.).
|
||||
type PrinterType struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// JobStatus represents a print job lifecycle state.
|
||||
type JobStatus struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// MaterialBase represents a base material type (PLA, PETG, ABS, etc.).
|
||||
// Density and temperature ranges are stored here for grams-calculation and slicing guidance.
|
||||
type MaterialBase struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DensityGCm3 float64 `json:"density_g_cm3"`
|
||||
ExtrusionTempMin *int `json:"extrusion_temp_min,omitempty"`
|
||||
ExtrusionTempMax *int `json:"extrusion_temp_max,omitempty"`
|
||||
BedTempMin *int `json:"bed_temp_min,omitempty"`
|
||||
BedTempMax *int `json:"bed_temp_max,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// MaterialFinish represents the visual/texture finish (Basic, Silk, Matte, etc.).
|
||||
type MaterialFinish struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// MaterialModifier represents an additive property (Carbon Fiber, Wood-Filled, etc.).
|
||||
type MaterialModifier struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Core Entity Tables
|
||||
// ============================================================================
|
||||
|
||||
// Printer represents a 3D printer in the fleet.
|
||||
type Printer struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PrinterTypeID int `json:"printer_type_id"`
|
||||
PrinterType *PrinterType `json:"printer_type,omitempty"` // populated on JOIN queries
|
||||
Manufacturer *string `json:"manufacturer,omitempty"`
|
||||
Model *string `json:"model,omitempty"`
|
||||
MoonrakerURL *string `json:"moonraker_url,omitempty"`
|
||||
MoonrakerAPIKey *string `json:"moonraker_api_key,omitempty"`
|
||||
MQTTBrokerHost *string `json:"mqtt_broker_host,omitempty"`
|
||||
MQTTTopicPrefix *string `json:"mqtt_topic_prefix,omitempty"`
|
||||
MQTTTLSEnabled bool `json:"mqtt_tls_enabled"`
|
||||
IsActive bool `json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// FilamentSpool represents a physical filament spool in inventory.
|
||||
// material_finish_id defaults to 1 ("Basic"); material_modifier_id is optional.
|
||||
// Grams are always physically measured values — grams_used is derived, not stored.
|
||||
type FilamentSpool struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
MaterialBaseID int `json:"material_base_id"`
|
||||
MaterialBase *MaterialBase `json:"material_base,omitempty"` // JOIN
|
||||
MaterialFinishID int `json:"material_finish_id"`
|
||||
MaterialFinish *MaterialFinish `json:"material_finish,omitempty"` // JOIN
|
||||
MaterialModifierID *int `json:"material_modifier_id,omitempty"`
|
||||
MaterialModifier *MaterialModifier `json:"material_modifier,omitempty"` // JOIN
|
||||
ColorHex string `json:"color_hex"`
|
||||
Brand *string `json:"brand,omitempty"`
|
||||
DiameterMM float64 `json:"diameter_mm"`
|
||||
InitialGrams int `json:"initial_grams"`
|
||||
RemainingGrams int `json:"remaining_grams"`
|
||||
SpoolWeightGrams *int `json:"spool_weight_grams,omitempty"`
|
||||
CostUSD *float64 `json:"cost_usd,omitempty"`
|
||||
LowStockThresholdGrams int `json:"low_stock_threshold_grams"`
|
||||
Notes *string `json:"notes,omitempty"`
|
||||
Barcode *string `json:"barcode,omitempty"`
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// PrintJob represents a single print on a specific printer.
|
||||
// The filament_spool_id is a convenience reference; multi-spool jobs track usage in usage_logs.
|
||||
type PrintJob struct {
|
||||
ID int `json:"id"`
|
||||
PrinterID int `json:"printer_id"`
|
||||
Printer *Printer `json:"printer,omitempty"` // JOIN
|
||||
FilamentSpoolID *int `json:"filament_spool_id,omitempty"`
|
||||
FilamentSpool *FilamentSpool `json:"filament_spool,omitempty"` // JOIN
|
||||
JobName string `json:"job_name"`
|
||||
FileName *string `json:"file_name,omitempty"`
|
||||
JobStatusID int `json:"job_status_id"`
|
||||
JobStatus *JobStatus `json:"job_status,omitempty"` // JOIN
|
||||
StartedAt *time.Time `json:"started_at,omitempty"`
|
||||
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
||||
DurationSeconds *int `json:"duration_seconds,omitempty"`
|
||||
EstimatedDurationSeconds *int `json:"estimated_duration_seconds,omitempty"`
|
||||
TotalMMExtruded *float64 `json:"total_mm_extruded,omitempty"`
|
||||
TotalGramsUsed *float64 `json:"total_grams_used,omitempty"`
|
||||
TotalCostUSD *float64 `json:"total_cost_usd,omitempty"`
|
||||
Notes *string `json:"notes,omitempty"`
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// UsageLog records filament consumption for a specific spool during a print job.
|
||||
// This is the atomic unit of filament tracking — grams are derived from mm_extruded.
|
||||
type UsageLog struct {
|
||||
ID int `json:"id"`
|
||||
PrintJobID int `json:"print_job_id"`
|
||||
PrintJob *PrintJob `json:"print_job,omitempty"` // JOIN
|
||||
FilamentSpoolID int `json:"filament_spool_id"`
|
||||
FilamentSpool *FilamentSpool `json:"filament_spool,omitempty"` // JOIN
|
||||
MMExtruded float64 `json:"mm_extruded"`
|
||||
GramsUsed float64 `json:"grams_used"`
|
||||
CostUSD *float64 `json:"cost_usd,omitempty"`
|
||||
LoggedAt time.Time `json:"logged_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Application Settings
|
||||
// ============================================================================
|
||||
|
||||
// Setting represents a key-value application configuration entry.
|
||||
// The value is stored as JSONB in PostgreSQL, allowing flexible typed config.
|
||||
type Setting struct {
|
||||
ID int `json:"id"`
|
||||
Key string `json:"key"`
|
||||
Value []byte `json:"value"` // raw JSON — marshalled/unmarshalled by caller
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
19
backend/migrations/000001_initial_schema.down.sql
Normal file
19
backend/migrations/000001_initial_schema.down.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Migration: 000001_initial_schema (rollback)
|
||||
-- Description: Drop all tables and indexes created in the initial schema migration
|
||||
-- Author: Hex
|
||||
-- Date: 2026-05-06
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE IF EXISTS usage_logs CASCADE;
|
||||
DROP TABLE IF EXISTS print_jobs CASCADE;
|
||||
DROP TABLE IF EXISTS filament_spools CASCADE;
|
||||
DROP TABLE IF EXISTS printers CASCADE;
|
||||
DROP TABLE IF EXISTS settings CASCADE;
|
||||
DROP TABLE IF EXISTS material_modifiers CASCADE;
|
||||
DROP TABLE IF EXISTS material_finishes CASCADE;
|
||||
DROP TABLE IF EXISTS material_bases CASCADE;
|
||||
DROP TABLE IF EXISTS job_statuses CASCADE;
|
||||
DROP TABLE IF EXISTS printer_types CASCADE;
|
||||
|
||||
COMMIT;
|
||||
231
backend/migrations/000001_initial_schema.up.sql
Normal file
231
backend/migrations/000001_initial_schema.up.sql
Normal file
@@ -0,0 +1,231 @@
|
||||
-- Migration: 000001_initial_schema
|
||||
-- Description: Create initial Extrudex schema — lookup tables, core entities, and settings
|
||||
-- Author: Hex
|
||||
-- Date: 2026-05-06
|
||||
--
|
||||
-- Design decisions:
|
||||
-- - Lookup tables for material_base, material_finish, material_modifier (no free-text enums)
|
||||
-- - Lookup tables for printer_type and job_status (extensible, no hard-coded enum values)
|
||||
-- - FK ON DELETE: RESTRICT on critical parents (material_base, material_finish, printer),
|
||||
-- SET NULL on optional parents (modifier, spool on print_jobs),
|
||||
-- CASCADE for usage_logs when parent job is deleted
|
||||
-- - Soft-delete (deleted_at) on spools and print_jobs for safety
|
||||
-- - JSONB config column on settings for flexible app-wide configuration
|
||||
-- - All identifiers snake_case per project convention
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- ============================================================================
|
||||
-- Lookup Tables
|
||||
-- ============================================================================
|
||||
|
||||
-- Printer types (fdm, resin, etc.) — extensible, not a raw enum
|
||||
CREATE TABLE printer_types (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL UNIQUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Job statuses (pending, printing, paused, completed, failed, cancelled)
|
||||
CREATE TABLE job_statuses (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL UNIQUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Material base types (PLA, PETG, ABS, TPU, ASA, Nylon, PC)
|
||||
CREATE TABLE material_bases (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL UNIQUE,
|
||||
density_g_cm3 DECIMAL(5,3) NOT NULL,
|
||||
extrusion_temp_min INT,
|
||||
extrusion_temp_max INT,
|
||||
bed_temp_min INT,
|
||||
bed_temp_max INT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Material finishes (Basic, Silk, Matte, Glossy, Satin)
|
||||
CREATE TABLE material_finishes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL UNIQUE,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Material modifiers (Wood-Filled, Carbon Fiber, Glow-in-Dark, Marble)
|
||||
CREATE TABLE material_modifiers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL UNIQUE,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- ============================================================================
|
||||
-- Core Entity Tables
|
||||
-- ============================================================================
|
||||
|
||||
-- 3D printers in the fleet
|
||||
CREATE TABLE printers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
printer_type_id INT NOT NULL,
|
||||
manufacturer VARCHAR(255),
|
||||
model VARCHAR(255),
|
||||
moonraker_url VARCHAR(512),
|
||||
moonraker_api_key VARCHAR(512),
|
||||
mqtt_broker_host VARCHAR(255),
|
||||
mqtt_topic_prefix VARCHAR(255),
|
||||
mqtt_tls_enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT fk_printers_printer_type
|
||||
FOREIGN KEY (printer_type_id) REFERENCES printer_types(id)
|
||||
ON DELETE RESTRICT
|
||||
);
|
||||
|
||||
-- Filament spools — the core inventory item
|
||||
CREATE TABLE filament_spools (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
material_base_id INT NOT NULL,
|
||||
material_finish_id INT NOT NULL DEFAULT 1, -- "Basic" (seed data populates this first)
|
||||
material_modifier_id INT,
|
||||
color_hex VARCHAR(7) NOT NULL CHECK (color_hex ~ '^#[0-9A-Fa-f]{6}$'),
|
||||
brand VARCHAR(255),
|
||||
diameter_mm DECIMAL(4,2) NOT NULL DEFAULT 1.75,
|
||||
initial_grams INT NOT NULL CHECK (initial_grams > 0),
|
||||
remaining_grams INT NOT NULL CHECK (remaining_grams >= 0),
|
||||
spool_weight_grams INT, -- measured empty-spool weight (tare), nullable
|
||||
cost_usd DECIMAL(10,2),
|
||||
low_stock_threshold_grams INT NOT NULL DEFAULT 50,
|
||||
notes TEXT,
|
||||
barcode VARCHAR(255) UNIQUE,
|
||||
deleted_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT fk_spools_material_base
|
||||
FOREIGN KEY (material_base_id) REFERENCES material_bases(id)
|
||||
ON DELETE RESTRICT,
|
||||
|
||||
CONSTRAINT fk_spools_material_finish
|
||||
FOREIGN KEY (material_finish_id) REFERENCES material_finishes(id)
|
||||
ON DELETE RESTRICT,
|
||||
|
||||
CONSTRAINT fk_spools_material_modifier
|
||||
FOREIGN KEY (material_modifier_id) REFERENCES material_modifiers(id)
|
||||
ON DELETE SET NULL
|
||||
);
|
||||
|
||||
-- Print jobs — each job is one print on one printer
|
||||
CREATE TABLE print_jobs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
printer_id INT NOT NULL,
|
||||
filament_spool_id INT, -- nullable: a job may use multiple spools (captured in usage_logs)
|
||||
job_name VARCHAR(255) NOT NULL,
|
||||
file_name VARCHAR(512),
|
||||
job_status_id INT NOT NULL DEFAULT 1, -- "pending"
|
||||
started_at TIMESTAMPTZ,
|
||||
completed_at TIMESTAMPTZ,
|
||||
duration_seconds INT,
|
||||
estimated_duration_seconds INT,
|
||||
total_mm_extruded DECIMAL(12,2),
|
||||
total_grams_used DECIMAL(10,2),
|
||||
total_cost_usd DECIMAL(10,4),
|
||||
notes TEXT,
|
||||
deleted_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT fk_print_jobs_printer
|
||||
FOREIGN KEY (printer_id) REFERENCES printers(id)
|
||||
ON DELETE RESTRICT,
|
||||
|
||||
CONSTRAINT fk_print_jobs_spool
|
||||
FOREIGN KEY (filament_spool_id) REFERENCES filament_spools(id)
|
||||
ON DELETE SET NULL,
|
||||
|
||||
CONSTRAINT fk_print_jobs_status
|
||||
FOREIGN KEY (job_status_id) REFERENCES job_statuses(id)
|
||||
ON DELETE RESTRICT
|
||||
);
|
||||
|
||||
-- Usage logs — granular tracking of filament consumed per job, per spool
|
||||
CREATE TABLE usage_logs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
print_job_id INT NOT NULL,
|
||||
filament_spool_id INT NOT NULL,
|
||||
mm_extruded DECIMAL(12,2) NOT NULL CHECK (mm_extruded > 0),
|
||||
grams_used DECIMAL(10,2) NOT NULL CHECK (grams_used > 0),
|
||||
cost_usd DECIMAL(10,4),
|
||||
logged_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
|
||||
CONSTRAINT fk_usage_logs_print_job
|
||||
FOREIGN KEY (print_job_id) REFERENCES print_jobs(id)
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT fk_usage_logs_spool
|
||||
FOREIGN KEY (filament_spool_id) REFERENCES filament_spools(id)
|
||||
ON DELETE RESTRICT
|
||||
);
|
||||
|
||||
-- ============================================================================
|
||||
-- Application Settings
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE settings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
key VARCHAR(255) NOT NULL UNIQUE,
|
||||
value JSONB NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- ============================================================================
|
||||
-- Indexes
|
||||
-- ============================================================================
|
||||
|
||||
-- Filament spools — query patterns: lookup by material, low-stock scans, barcode scans
|
||||
CREATE INDEX ix_spools_material_base_id ON filament_spools(material_base_id);
|
||||
CREATE INDEX ix_spools_material_finish_id ON filament_spools(material_finish_id);
|
||||
CREATE INDEX ix_spools_material_modifier_id ON filament_spools(material_modifier_id);
|
||||
CREATE INDEX ix_spools_remaining_grams ON filament_spools(remaining_grams)
|
||||
WHERE deleted_at IS NULL; -- partial index: only active spools for low-stock queries
|
||||
CREATE INDEX ix_spools_barcode ON filament_spools(barcode)
|
||||
WHERE barcode IS NOT NULL AND deleted_at IS NULL;
|
||||
CREATE INDEX ix_spools_deleted_at ON filament_spools(deleted_at)
|
||||
WHERE deleted_at IS NOT NULL; -- small index for soft-delete filtering
|
||||
|
||||
-- Printers
|
||||
CREATE INDEX ix_printers_printer_type_id ON printers(printer_type_id);
|
||||
CREATE INDEX ix_printers_is_active ON printers(is_active)
|
||||
WHERE is_active = TRUE; -- partial index for fleet dashboard queries
|
||||
|
||||
-- Print jobs — query by printer, status, date range, and soft-delete filter
|
||||
CREATE INDEX ix_print_jobs_printer_id ON print_jobs(printer_id);
|
||||
CREATE INDEX ix_print_jobs_spool_id ON print_jobs(filament_spool_id)
|
||||
WHERE filament_spool_id IS NOT NULL;
|
||||
CREATE INDEX ix_print_jobs_status_id ON print_jobs(job_status_id);
|
||||
CREATE INDEX ix_print_jobs_created_at ON print_jobs(created_at DESC);
|
||||
CREATE INDEX ix_print_jobs_deleted_at ON print_jobs(deleted_at)
|
||||
WHERE deleted_at IS NOT NULL;
|
||||
|
||||
-- Usage logs — always queried by job or spool
|
||||
CREATE INDEX ix_usage_logs_print_job_id ON usage_logs(print_job_id);
|
||||
CREATE INDEX ix_usage_logs_spool_id ON usage_logs(filament_spool_id);
|
||||
CREATE INDEX ix_usage_logs_logged_at ON usage_logs(logged_at DESC);
|
||||
|
||||
-- Settings — key lookups
|
||||
CREATE INDEX ix_settings_key ON settings(key);
|
||||
|
||||
COMMIT;
|
||||
15
backend/migrations/000002_seed_data.down.sql
Normal file
15
backend/migrations/000002_seed_data.down.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Migration: 000002_seed_data (rollback)
|
||||
-- Description: Remove seed data inserted in 000002
|
||||
-- Author: Hex
|
||||
-- Date: 2026-05-06
|
||||
|
||||
BEGIN;
|
||||
|
||||
DELETE FROM settings WHERE key IN ('default_low_stock_threshold_grams', 'default_diameter_mm', 'filament_cross_section_area_mm2');
|
||||
DELETE FROM material_modifiers WHERE id IN (1, 2, 3, 4);
|
||||
DELETE FROM material_finishes WHERE id IN (1, 2, 3, 4, 5);
|
||||
DELETE FROM material_bases WHERE id IN (1, 2, 3, 4, 5, 6, 7);
|
||||
DELETE FROM job_statuses WHERE id IN (1, 2, 3, 4, 5, 6);
|
||||
DELETE FROM printer_types WHERE id IN (1, 2);
|
||||
|
||||
COMMIT;
|
||||
95
backend/migrations/000002_seed_data.up.sql
Normal file
95
backend/migrations/000002_seed_data.up.sql
Normal file
@@ -0,0 +1,95 @@
|
||||
-- Seed Data: Extrudex common reference data
|
||||
-- Author: Hex
|
||||
-- Date: 2026-05-06
|
||||
--
|
||||
-- IMPORTANT: IDs are explicitly assigned to satisfy the DEFAULT constraints:
|
||||
-- - filament_spools.material_finish_id DEFAULT 1 ("Basic")
|
||||
-- - print_jobs.job_status_id DEFAULT 1 ("pending")
|
||||
--
|
||||
-- Density values sourced from common manufacturer specifications.
|
||||
-- Temperature ranges are conservative/typical; users can override per-spool.
|
||||
|
||||
BEGIN;
|
||||
|
||||
-- ============================================================================
|
||||
-- Printer Types
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO printer_types (id, name) VALUES
|
||||
(1, 'fdm'),
|
||||
(2, 'resin')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- Reset the sequence so future inserts start after our explicit IDs
|
||||
SELECT setval('printer_types_id_seq', GREATEST(2, (SELECT MAX(id) FROM printer_types)));
|
||||
|
||||
-- ============================================================================
|
||||
-- Job Statuses
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO job_statuses (id, name) VALUES
|
||||
(1, 'pending'),
|
||||
(2, 'printing'),
|
||||
(3, 'paused'),
|
||||
(4, 'completed'),
|
||||
(5, 'failed'),
|
||||
(6, 'cancelled')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
SELECT setval('job_statuses_id_seq', GREATEST(6, (SELECT MAX(id) FROM job_statuses)));
|
||||
|
||||
-- ============================================================================
|
||||
-- Material Bases (common filament types)
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO material_bases (id, name, density_g_cm3, extrusion_temp_min, extrusion_temp_max, bed_temp_min, bed_temp_max) VALUES
|
||||
(1, 'PLA', 1.24, 190, 220, 0, 60),
|
||||
(2, 'PETG', 1.27, 230, 250, 70, 90),
|
||||
(3, 'ABS', 1.04, 230, 260, 90, 110),
|
||||
(4, 'TPU', 1.21, 220, 250, 0, 60),
|
||||
(5, 'ASA', 1.07, 240, 260, 90, 110),
|
||||
(6, 'Nylon', 1.14, 240, 280, 70, 100),
|
||||
(7, 'PC', 1.20, 260, 310, 90, 120)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
SELECT setval('material_bases_id_seq', GREATEST(7, (SELECT MAX(id) FROM material_bases)));
|
||||
|
||||
-- ============================================================================
|
||||
-- Material Finishes
|
||||
-- ============================================================================
|
||||
-- ID 1 = "Basic" is the default for new spools (DEFAULT 1 constraint)
|
||||
|
||||
INSERT INTO material_finishes (id, name, description) VALUES
|
||||
(1, 'Basic', 'Standard solid-color filament with no special finish'),
|
||||
(2, 'Silk', 'Glossy silk-like sheen, often used for decorative prints'),
|
||||
(3, 'Matte', 'Flat non-reflective surface finish'),
|
||||
(4, 'Glossy', 'High-shine reflective surface'),
|
||||
(5, 'Satin', 'Semi-gloss between matte and glossy')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
SELECT setval('material_finishes_id_seq', GREATEST(5, (SELECT MAX(id) FROM material_finishes)));
|
||||
|
||||
-- ============================================================================
|
||||
-- Material Modifiers
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO material_modifiers (id, name, description) VALUES
|
||||
(1, 'Wood-Filled', 'Contains wood fibers for natural wood-like appearance and texture'),
|
||||
(2, 'Carbon Fiber', 'Reinforced with carbon fibers for increased stiffness and strength'),
|
||||
(3, 'Glow-in-Dark', 'Phosphorescent additive that glows after exposure to light'),
|
||||
(4, 'Marble', 'Contains specks for a stone-like marble appearance')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
SELECT setval('material_modifiers_id_seq', GREATEST(4, (SELECT MAX(id) FROM material_modifiers)));
|
||||
|
||||
-- ============================================================================
|
||||
-- Default Application Settings
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO settings (key, value, description) VALUES
|
||||
('default_low_stock_threshold_grams', '50', 'Default grams threshold for low-stock alerts on new spools'),
|
||||
('default_diameter_mm', '1.75', 'Default filament diameter for new spools (1.75mm is the modern standard)'),
|
||||
('filament_cross_section_area_mm2', '2.405', 'Cross-sectional area for 1.75mm filament: π × (1.75/2)²')
|
||||
ON CONFLICT (key) DO NOTHING;
|
||||
|
||||
COMMIT;
|
||||
@@ -1,517 +0,0 @@
|
||||
# Extrudex Mobile-First Design System
|
||||
|
||||
> **Project:** CUB-71 — Mobile-First Touch-Optimized UI Design
|
||||
> **Parent:** CUB-67 — Extrudex Mobile-First PWA Implementation
|
||||
> **Date:** 2026-05-01
|
||||
> **Author:** Sketch
|
||||
> **Status:** In Progress
|
||||
|
||||
---
|
||||
|
||||
## 1. Design Philosophy
|
||||
|
||||
### Mobile-First, Touch-Always
|
||||
- **Minimum touch target:** 44×44px (Apple HIG) / 48×48dp (Material Design)
|
||||
- **Thumb-friendly zones:** Primary actions in bottom 25% of screen
|
||||
- **Gesture support:** Swipe, pull-to-refresh, pinch-to-zoom on relevant screens
|
||||
- **One-handed use:** All critical actions reachable within thumb zone
|
||||
|
||||
### Workshop-Ready
|
||||
- **High contrast:** WCAG AA minimum (4.5:1) — workshop lighting varies
|
||||
- **Large text:** 16sp minimum body, 20sp+ for primary info
|
||||
- **Glanceable:** Key info visible at arm's length (3ft)
|
||||
- **Glove-compatible:** Larger tap targets for operators wearing work gloves
|
||||
|
||||
### Speed Over Complexity
|
||||
- **Sub-second load:** Cached assets, skeleton screens
|
||||
- **Minimal taps:** Every flow optimized for fewest interactions
|
||||
- **Smart defaults:** Pre-filled forms based on context
|
||||
|
||||
---
|
||||
|
||||
## 2. Color System
|
||||
|
||||
### Primary Palette (Dark Theme — Default)
|
||||
|
||||
| Token | Hex | Usage |
|
||||
|-------|-----|-------|
|
||||
| `surface` | `#1C1B1F` | Screen background |
|
||||
| `onSurface` | `#E6E1E5` | Primary text |
|
||||
| `surfaceContainer` | `#211F26` | Cards, app bar |
|
||||
| `surfaceContainerHigh` | `#2B2930` | Elevated cards |
|
||||
| `primary` | `#A8CEDA` | FAB, active states, links |
|
||||
| `onPrimary` | `#00303E` | Text on primary |
|
||||
| `primaryContainer` | `#004D63` | Chip fills, tonal buttons |
|
||||
| `onPrimaryContainer` | `#A8CEDA` | Text on primary container |
|
||||
| `secondary` | `#B1CCC7` | Secondary actions |
|
||||
| `error` | `#F2B8B5` | Critical stock, errors |
|
||||
| `errorContainer` | `#8C1D18` | Error backgrounds |
|
||||
| `warning` | `#FFD580` | Low stock warning |
|
||||
| `warningContainer` | `#5D4200` | Warning backgrounds |
|
||||
| `success` | `#8BD0A0` | Available, success states |
|
||||
| `successContainer` | `#00522E` | Success backgrounds |
|
||||
| `outline` | `#938F99` | Borders, dividers |
|
||||
| `outlineVariant` | `#49454F` | Subtle borders |
|
||||
|
||||
### Light Theme (Optional)
|
||||
|
||||
| Token | Hex | Usage |
|
||||
|-------|-----|-------|
|
||||
| `surface` | `#F8FAFC` | Screen background |
|
||||
| `surfaceContainer` | `#FFFFFF` | Cards |
|
||||
| `primary` | `#2563EB` | Primary actions |
|
||||
| `onSurface` | `#0F172A` | Primary text |
|
||||
|
||||
---
|
||||
|
||||
## 3. Typography Scale
|
||||
|
||||
### Mobile Type Scale
|
||||
|
||||
| Role | Token | Size | Weight | Line Height | Letter Spacing |
|
||||
|------|-------|------|--------|-------------|----------------|
|
||||
| Display Large | `displayLarge` | 57sp | 400 | 64sp | -0.25px |
|
||||
| Display Medium | `displayMedium` | 45sp | 400 | 52sp | 0 |
|
||||
| Headline Large | `headlineLarge` | 32sp | 400 | 40sp | 0 |
|
||||
| Headline Medium | `headlineMedium` | 28sp | 400 | 36sp | 0 |
|
||||
| Headline Small | `headlineSmall` | 24sp | 400 | 32sp | 0 |
|
||||
| Title Large | `titleLarge` | 22sp | 400 | 28sp | 0 |
|
||||
| Title Medium | `titleMedium` | 16sp | 500 | 24sp | 0.15px |
|
||||
| Title Small | `titleSmall` | 14sp | 500 | 20sp | 0.1px |
|
||||
| Body Large | `bodyLarge` | 16sp | 400 | 24sp | 0.5px |
|
||||
| Body Medium | `bodyMedium` | 14sp | 400 | 20sp | 0.25px |
|
||||
| Label Large | `labelLarge` | 14sp | 500 | 20sp | 0.1px |
|
||||
| Label Medium | `labelMedium` | 12sp | 500 | 16sp | 0.5px |
|
||||
| Label Small | `labelSmall` | 11sp | 500 | 16sp | 0.5px |
|
||||
|
||||
### Font Stack
|
||||
```css
|
||||
--font-sans: 'Inter', 'Roboto', system-ui, -apple-system, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Spacing System
|
||||
|
||||
### 8dp Grid Base
|
||||
|
||||
| Token | Value | Usage |
|
||||
|-------|-------|-------|
|
||||
| `space-1` | 4dp | Tight padding, icon gaps |
|
||||
| `space-2` | 8dp | Default gap, small padding |
|
||||
| `space-3` | 12dp | Card padding (compact) |
|
||||
| `space-4` | 16dp | Standard padding, section gaps |
|
||||
| `space-5` | 20dp | Large padding |
|
||||
| `space-6` | 24dp | Section margins, hero padding |
|
||||
| `space-8` | 32dp | Large section gaps |
|
||||
| `space-10` | 40dp | Major section spacing |
|
||||
| `space-12` | 48dp | Touch target minimum |
|
||||
| `space-16` | 64dp | App bar height |
|
||||
|
||||
### Border Radius
|
||||
|
||||
| Token | Value | Usage |
|
||||
|-------|-------|-------|
|
||||
| `radius-sm` | 4dp | Small buttons, chips |
|
||||
| `radius-md` | 8dp | Cards, inputs |
|
||||
| `radius-lg` | 12dp | Modals, bottom sheets |
|
||||
| `radius-xl` | 16dp | Large cards, dialogs |
|
||||
| `radius-full` | 9999px | Pills, circular elements |
|
||||
|
||||
---
|
||||
|
||||
## 5. Component Specifications
|
||||
|
||||
### 5.1 Bottom Navigation Bar
|
||||
|
||||
**Height:** 80dp
|
||||
**Background:** `surfaceContainer` with 1dp top outline
|
||||
**Layout:** 4-5 icon+label items, evenly distributed
|
||||
**Active state:** Icon filled + `primary` color, label `primary`
|
||||
**Inactive state:** Icon outlined + `onSurfaceVariant` color
|
||||
**Touch target:** Full 80dp height, icon+label centered
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────┐
|
||||
│ 📦 🖨️ 📋 ⚙️ │
|
||||
│Inventory Printers Jobs Settings │
|
||||
└─────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Destinations:**
|
||||
- Inventory (spools list) — default active
|
||||
- Printers (printer fleet status)
|
||||
- Jobs (print job history)
|
||||
- Settings (app configuration)
|
||||
|
||||
---
|
||||
|
||||
### 5.2 QR Scanner Interface
|
||||
|
||||
**Layout:** Full-bleed camera viewport with overlay
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────┐
|
||||
│ ✕ Scan Spool [⚡] │ ← App Bar (56dp)
|
||||
├─────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────┐ │ │
|
||||
│ │ │ ╔═══════════════╗ │ │ │
|
||||
│ │ │ ║ ▄▄▄▄▄▄▄▄▄▄▄ ║ │ │ │
|
||||
│ │ │ ║ █ VIEWPORT █ ║ │ │ │
|
||||
│ │ │ ║ █ FRAME █ ║ │ │ │
|
||||
│ │ │ ║ ▀▀▀▀▀▀▀▀▀▀▀ ║ │ │ │
|
||||
│ │ │ ║ (scan line) ║ │ │ │
|
||||
│ │ └───────────────────┘ │ │
|
||||
│ │ │ │
|
||||
│ │ LIVE CAMERA FEED │ │
|
||||
│ │ │ │
|
||||
│ └─────────────────────────────┘ │
|
||||
│ │
|
||||
│ [Last scan: 8901234567890] │
|
||||
│ │
|
||||
│ Can't scan? Enter manually │
|
||||
│ │
|
||||
└─────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Elements:**
|
||||
- **Camera viewport:** Full width, 60% screen height, `surfaceContainerHighest` background before camera starts
|
||||
- **Scanning frame:** 200dp × 120dp centered, corner brackets (3dp stroke, `primary`)
|
||||
- **Scan line:** Horizontal 2dp line, sweeps top→bottom (2s cycle), `primary` at 40% opacity
|
||||
- **Scan result chip:** Appears below viewport, monospace text, auto-advances in 1.5s
|
||||
- **Manual entry:** Text button fallback
|
||||
|
||||
**States:**
|
||||
| State | Visual |
|
||||
|-------|--------|
|
||||
| Initializing | Shimmer loading + "Starting camera…" |
|
||||
| Ready | Live feed + animated scan line |
|
||||
| Scanning | Frame flashes `success` green |
|
||||
| No match | Frame flashes `warning` yellow |
|
||||
| Camera denied | Error card + "Enter manually" button |
|
||||
|
||||
---
|
||||
|
||||
### 5.3 Spool Detail View (Mobile)
|
||||
|
||||
**Layout:** Scrollable vertical stack
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────┐
|
||||
│ ← PLA Basic — Matte Black [✏] │ ← App Bar
|
||||
├─────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌──────┐ │
|
||||
│ │SWATCH│ PLA Basic — Matte │
|
||||
│ │ 80dp │ Black [Avail] │
|
||||
│ └──────┘ Bambu Lab │
|
||||
│ │
|
||||
│ ◉ 842g / 1000g (67%) │ ← Circular progress
|
||||
│ │
|
||||
├─────────────────────────────────────┤
|
||||
│ Total Weight │ Remaining │
|
||||
│ 1,000g │ 842g (67%) │
|
||||
├─────────────────────────────────────┤
|
||||
│ Diameter │ Density │
|
||||
│ 1.75mm │ 1.24 g/cm³ │
|
||||
├─────────────────────────────────────┤
|
||||
│ Date Added │ Last Used │
|
||||
│ Mar 12, 2026 │ Apr 18, 2026 │
|
||||
├─────────────────────────────────────┤
|
||||
│ 📍 AMS Unit 2, Slot A3 [Move] │
|
||||
├─────────────────────────────────────┤
|
||||
│ ┌──────────┐ │
|
||||
│ │ QR CODE │ │
|
||||
│ │ 160dp │ EXT-2026-PLA-0042 │
|
||||
│ └──────────┘ [Reprint] │
|
||||
├─────────────────────────────────────┤
|
||||
│ Recent Usage │
|
||||
│ Print #1847 — Benchy -32g │
|
||||
│ Print #1842 — Housing -18g │
|
||||
│ [View Full History →] │
|
||||
├─────────────────────────────────────┤
|
||||
│ │
|
||||
│ [Depleted] [Move] [Print] │ ← Sticky action row
|
||||
│ │
|
||||
├─────────────────────────────────────┤
|
||||
│ 📦 🖨️ 📋 ⚙️ │ ← Bottom nav
|
||||
└─────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Hero Section:**
|
||||
- Color swatch: 80dp circle, `outlineVariant` border
|
||||
- Material name: `headlineMedium` (28sp)
|
||||
- Brand: `bodyLarge` (16sp), `onSurfaceVariant`
|
||||
- Status badge: Tonal chip
|
||||
- Circular progress: 96dp diameter, dynamic color based on percentage
|
||||
|
||||
**Metrics Grid:**
|
||||
- 2-column grid on mobile, 3-column on kiosk
|
||||
- Label: `labelMedium` (12sp)
|
||||
- Value: `titleMedium` (16sp)
|
||||
|
||||
**Action Row (Sticky):**
|
||||
- Height: 64dp minimum
|
||||
- Buttons: 48dp height minimum
|
||||
- Deplete: Outlined, `error` color
|
||||
- Move: Tonal, `secondary` color
|
||||
- Print: Filled, `primary` color
|
||||
|
||||
---
|
||||
|
||||
### 5.4 Print-Log Form (Quick Entry)
|
||||
|
||||
**Layout:** Bottom sheet or full-screen
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────┐
|
||||
│ ✕ Log Print Usage │
|
||||
├─────────────────────────────────────┤
|
||||
│ │
|
||||
│ Spool: PLA Basic — Matte Black │
|
||||
│ Remaining: 842g │
|
||||
│ │
|
||||
│ Weight Used │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ [−] 32 [+] grams │ │ ← Stepper
|
||||
│ └─────────────────────────────┘ │
|
||||
│ │
|
||||
│ Quick: [10] [25] [50] [100] │
|
||||
│ │
|
||||
│ Print Job (optional) │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ Select or enter job name... │ │
|
||||
│ └─────────────────────────────┘ │
|
||||
│ │
|
||||
│ Notes (optional) │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ ... │ │
|
||||
│ └─────────────────────────────┘ │
|
||||
│ │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ ✓ Log Print (842→810g) │ │
|
||||
│ └─────────────────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Design Principles:**
|
||||
- **Number pad first:** Show numeric keyboard by default
|
||||
- **Quick-select chips:** Common values (10g, 25g, 50g, 100g)
|
||||
- **Stepper control:** ± buttons flanking input
|
||||
- **Live preview:** Show remaining weight after deduction
|
||||
- **Single-tap complete:** Primary action always visible
|
||||
|
||||
---
|
||||
|
||||
### 5.5 Status Badges
|
||||
|
||||
| Status | Background | Text | Icon |
|
||||
|--------|-----------|------|------|
|
||||
| Available | `successContainer` | `success` | check_circle |
|
||||
| In Use | `primaryContainer` | `primary` | print |
|
||||
| Low Stock | `warningContainer` | `warning` | warning |
|
||||
| Critical | `errorContainer` | `error` | error |
|
||||
| Depleted | `errorContainer` | `error` | remove_circle |
|
||||
|
||||
---
|
||||
|
||||
### 5.6 Touch Targets & Accessibility
|
||||
|
||||
**Minimum Sizes:**
|
||||
- Interactive elements: 48×48dp
|
||||
- List items: 56dp height minimum
|
||||
- Buttons: 48dp height, 88dp minimum width
|
||||
- Chips: 32dp height, 48dp minimum width
|
||||
- Input fields: 56dp height
|
||||
|
||||
**Focus States:**
|
||||
- 2dp outline, `primary` color, 2dp offset
|
||||
- Visible on keyboard navigation
|
||||
|
||||
**Motion:**
|
||||
- Respect `prefers-reduced-motion`
|
||||
- Disable animations when set
|
||||
- Use opacity fades instead of transforms
|
||||
|
||||
---
|
||||
|
||||
## 6. Responsive Breakpoints
|
||||
|
||||
| Breakpoint | Width | Target |
|
||||
|-----------|-------|--------|
|
||||
| Compact | 0-599dp | Mobile phones |
|
||||
| Medium | 600-839dp | Large phones, small tablets |
|
||||
| Expanded | 840-1199dp | Tablets, small desktops |
|
||||
| Large | 1200dp+ | Desktops, kiosks |
|
||||
|
||||
### Layout Adaptations
|
||||
|
||||
| Property | Compact (Mobile) | Large (Kiosk) |
|
||||
|----------|-----------------|---------------|
|
||||
| Navigation | Bottom bar (80dp) | Rail (80dp, left) |
|
||||
| Content padding | 16dp | 24dp |
|
||||
| Grid columns | 1-2 | 2-3 |
|
||||
| Card padding | 16dp | 20dp |
|
||||
| Typography scale | Standard | +10% for distance viewing |
|
||||
| Touch targets | 48dp | 56dp (glove-friendly) |
|
||||
|
||||
---
|
||||
|
||||
## 7. Animation & Motion
|
||||
|
||||
### Principles
|
||||
- **Purposeful:** Every animation guides attention or provides feedback
|
||||
- **Fast:** 200-300ms standard duration
|
||||
- **Easing:** `ease-out` for entrances, `ease-in-out` for transitions
|
||||
|
||||
### Patterns
|
||||
|
||||
| Animation | Duration | Easing | Use Case |
|
||||
|-----------|----------|--------|----------|
|
||||
| Slide in | 300ms | ease-out | Screen transitions |
|
||||
| Fade | 200ms | ease-in-out | Modal/dialog |
|
||||
| Scale | 200ms | ease-out | Button presses |
|
||||
| Shimmer | 1.5s | linear | Loading skeletons |
|
||||
| Pulse | 2s | ease-in-out | Scan line, critical alerts |
|
||||
| Progress | 600ms | ease-out | Circular progress fill |
|
||||
|
||||
### Interaction Feedback
|
||||
- **Button press:** Scale to 0.96, 100ms
|
||||
- **Chip select:** Background color transition, 150ms
|
||||
- **List item tap:** Ripple effect, `primary` at 12% opacity
|
||||
- **Success:** Green flash + haptic (mobile)
|
||||
- **Error:** Red flash + shake animation
|
||||
|
||||
---
|
||||
|
||||
## 8. Assets & Icons
|
||||
|
||||
### Icon Set
|
||||
- **Library:** Material Symbols (rounded)
|
||||
- **Size:** 24dp default, 20dp in dense areas
|
||||
- **Weight:** 400 (regular), filled for active states
|
||||
|
||||
### Required Icons
|
||||
| Icon | Name | Usage |
|
||||
|------|------|-------|
|
||||
| 📦 | inventory_2 | Inventory nav |
|
||||
| 🖨️ | print | Printers nav |
|
||||
| 📋 | assignment | Jobs nav |
|
||||
| ⚙️ | settings | Settings nav |
|
||||
| ✕ | close | Close/dismiss |
|
||||
| ← | arrow_back | Navigate back |
|
||||
| ✏ | edit | Edit action |
|
||||
| 🔍 | search | Search toggle |
|
||||
| + | add | Add/create |
|
||||
| 🗑 | delete | Delete action |
|
||||
| 📷 | photo_camera | Scan action |
|
||||
| ⚠ | warning | Warning states |
|
||||
| ✓ | check_circle | Success states |
|
||||
| 📍 | location_on | Location |
|
||||
| 📶 | signal_cellular_alt | SignalR status |
|
||||
|
||||
---
|
||||
|
||||
## 9. Developer Handoff Checklist
|
||||
|
||||
- [x] Color tokens defined (dark theme)
|
||||
- [x] Typography scale specified
|
||||
- [x] Spacing system documented
|
||||
- [x] Component specifications written
|
||||
- [x] Touch targets validated (≥48dp)
|
||||
- [x] Responsive breakpoints defined
|
||||
- [x] Animation patterns documented
|
||||
- [x] Icon set specified
|
||||
- [ ] Mockup images generated (blocked — image generation unavailable)
|
||||
- [ ] Figma/Sketch file created (optional)
|
||||
- [ ] Design tokens exported to CSS/SCSS
|
||||
|
||||
---
|
||||
|
||||
## 10. Implementation Notes for Rex
|
||||
|
||||
### Priority Order
|
||||
1. Bottom navigation component
|
||||
2. QR scanner interface (camera + overlay)
|
||||
3. Spool detail view (scrollable)
|
||||
4. Print-log form (bottom sheet)
|
||||
5. Status badges and indicators
|
||||
|
||||
### Angular Material Components Needed
|
||||
```typescript
|
||||
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
```
|
||||
|
||||
### QR Scanning Libraries
|
||||
- **Mobile:** `html5-qrcode` or `@zxing/browser`
|
||||
- **Camera access:** `navigator.mediaDevices.getUserMedia({ facingMode: 'environment' })`
|
||||
|
||||
### Key Files to Create
|
||||
```
|
||||
frontend/src/app/
|
||||
├── components/
|
||||
│ ├── bottom-nav/
|
||||
│ │ ├── bottom-nav.component.ts
|
||||
│ │ ├── bottom-nav.component.html
|
||||
│ │ └── bottom-nav.component.scss
|
||||
│ ├── qr-scanner/
|
||||
│ │ ├── qr-scanner.component.ts
|
||||
│ │ ├── qr-scanner.component.html
|
||||
│ │ └── qr-scanner.component.scss
|
||||
│ ├── spool-detail/
|
||||
│ │ ├── spool-detail.component.ts
|
||||
│ │ ├── spool-detail.component.html
|
||||
│ │ └── spool-detail.component.scss
|
||||
│ └── print-log-form/
|
||||
│ ├── print-log-form.component.ts
|
||||
│ ├── print-log-form.component.html
|
||||
│ └── print-log-form.component.scss
|
||||
├── design-system/
|
||||
│ ├── _colors.scss
|
||||
│ ├── _typography.scss
|
||||
│ ├── _spacing.scss
|
||||
│ └── _mixins.scss
|
||||
└── models/
|
||||
└── mobile-ui.model.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 11. File Locations
|
||||
|
||||
| File | Path | Purpose |
|
||||
|------|------|---------|
|
||||
| Design System | `design/mobile-design-system.md` | This document |
|
||||
| Inventory Spec | `design/01-filament-inventory-list.md` | Existing — inventory screen |
|
||||
| Spool Detail Spec | `design/02-spool-detail-view.md` | Existing — detail screen |
|
||||
| Smart Intake Spec | `design/03-smart-intake-workflow.md` | Existing — intake flow |
|
||||
| Identify Spec | `design/smart-intake-identify-spec.md` | Existing — identify state |
|
||||
| Mockup Images | `design/mockup-*.png/jpg` | Visual references |
|
||||
|
||||
---
|
||||
|
||||
**Next Steps:**
|
||||
1. Review design system with stakeholders
|
||||
2. Generate mockup images (when image generation is available)
|
||||
3. Export design tokens to SCSS
|
||||
4. Hand off to Rex for implementation
|
||||
5. Create interactive prototype (optional)
|
||||
|
||||
**Status:** Design system document complete. Ready for implementation handoff.
|
||||
Reference in New Issue
Block a user