DEV Community

Cover image for Tolerix: Catching Expensive Laser Cutting Mistakes on Device with Gemma
Jesus Chetia
Jesus Chetia

Posted on AI-assisted

Tolerix: Catching Expensive Laser Cutting Mistakes on Device with Gemma

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission đź’¸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Tolerix is a local-first preflight software built for laser cutting, CNC routing, and digital fabrication side hustles.

When running a custom fabrication side business (such as cutting acrylic wedding signs, personalized keychains, or wooden craft kits), customers send unstructured instructions via email, Etsy messages, or Instagram DMs. Along with these notes, they provide vector files (SVG or DXF).

Too often, there is an expensive mismatch:

  1. The customer requested a 120 x 80 mm tag, but the drawing file was exported at 100 x 60 mm.
  2. The vector design contains unclosed contours, causing the laser head to leave pieces half-cut.
  3. The file has duplicate overlapping vectors, causing the laser to trace the same line twice, which chars wood or melts acrylic.
  4. The file exceeds the physical laser bed boundaries.

In custom manufacturing, running a bad file ruins expensive sheet stock ($15 to $50 per panel) and burns billable machine time.

Tolerix solves this problem before the operator hits start on the machine. It pairs local, open-weight Gemma models with a deterministic vector geometry engine to compare what the customer asked for against what the vector file actually contains.

Demo

The Preflight Workflow

flowchart LR
    A[Customer Notes] --> B[Local Gemma Model]
    B --> C[Structured Job Spec]
    D[Customer Vector File] --> E[Deterministic Geometry Engine]
    E --> F[Exact Physical Dimensions & Contours]
    C --> G[Rule Auditor]
    F --> G
    G --> H[Evidence-Backed Preflight Report]

The operator pastes customer notes, drops the SVG design into the browser, and immediately receives a clear preflight audit highlighting discrepancies, open paths, duplicate lines, and dimensional mismatches.

Code

The complete source code is available on GitHub:

GitHub logo greenbugx / Tolerix

Precision before production.

Tolerix

Precision before production.

Tolerix is an AI-assisted manufacturing preflight web application designed for small laser-cutting businesses, acrylic and signage shops, custom-product makers, and fabrication workshops.

It bridges the gap between what a customer requests and the actual vector drawing file prepared for manufacturing, calculating geometric discrepancies deterministically and generating an evidence-backed pre-production audit report.

Screenshots

Landing Page

Tolerix Landing Page

Production Dashboard

Tolerix Production Dashboard

Machine Profile Configuration

Tolerix Machine Profiles

On-Device Model & Hardware Settings

Tolerix Workspace & Model Settings

Architecture

Tolerix operates on a strict local-first architecture. There is no remote backend, hosted database, cloud sync, or external API dependency.

  • Frontend & App Shell: React 19, Vite, TypeScript, Tailwind CSS v4, React Router, TanStack Query, Zod.
  • Persistent Data Layer: IndexedDB managed via Dexie for jobs, files, machine profiles, specifications, audit runs, and findings.
  • Local Model Storage: Browser Cache Storage API (tolerix-models-v1) for streaming and caching verified LiteRT-LM model weights.
  • Local AI Execution: On-device WebGPU inference using @litert-lm/core LiteRT-LM runtime…

Architecture Stack

  • Application Shell: React 19, TypeScript, Vite, Tailwind CSS v4
  • Local AI Inference: LiteRT-LM WebGPU runtime executing Gemma 2B and Gemma 4B on device
  • Vector Analysis: svg-pathdata, analytical BĂ©zier extrema calculus, affine transform matrix stack
  • Storage & State: Dexie (IndexedDB) for jobs, files, audit runs, and machine profiles; Cache Storage API for model weights

How I Built It

Tolerix separates generative reasoning from mathematical precision. AI extracts intended parameters from noisy human text, while deterministic algorithms inspect geometric vectors.

graph TD
    subgraph Browser Client [100% Local Browser Sandbox]
        subgraph AI Layer [LiteRT-LM WebGPU]
            M1[Gemma 2B / 4B Weights] --> M2[Requirement Extraction]
            M2 --> M3[Quantity, Dimensions, Material, Thickness, Operations]
        end
        subgraph Geometry Layer [Deterministic Engine]
            G1[SVG / Path Parser] --> G2[2D Affine Matrix Accumulation]
            G2 --> G3[Bézier Extrema & Arc Bounds Calculus]
            G3 --> G4[Normalized Path & Duplicate Detection]
        end
        subgraph Storage Layer [IndexedDB & Cache API]
            S1[(Dexie DB: Jobs, Files, Audits)]
            S2[(Cache API: Verified Model Weights)]
        end
        subgraph Audit Engine [Preflight Validation]
            M3 --> A1[Rule Auditor]
            G4 --> A1
            A1 --> A2[High / Med / Low Findings]
            A2 --> A3[Printable HTML & Structured JSON Reports]
        end
    end

Feature Matrix: What Works and What Does Not

Component What Works What Does Not Work (Current Limitations)
Gemma AI Extraction Runs Gemma 2B and Gemma 4B on device via WebGPU. Extracts target dimensions, material names, quantities, and cut/engrave operations. Includes regex heuristic fallback when offline without weights. Does not run on machines lacking WebGPU support or GPUs with under 4 GB VRAM.
Geometry Engine Computes exact mathematical bounds for quadratic and cubic Bézier curves and elliptical arcs. Correctly handles 2D affine transforms (nested groups, rotation, scale, skew) and non-zero viewBox origins. Does not deduce non-vector properties like actual sheet thickness or laser wattage from 2D coordinates; these remain flagged as unverified for human review.
Duplicate Path Detection Compares normalized coordinate sequences and reversal-invariant trajectories to catch duplicate cut paths. Does not automatically merge intersecting paths; it detects and flags them for the operator.
File Security Strict element allowlist. Rejects scripts, event handlers, foreignObject, iframe, external entity declarations (XXE), and remote HTTP references. Enforces 50 MB limits. DXF parsing currently supports basic 2D planar contours; complex 3D meshes or ACIS blocks are unsupported.
Reporting & Persistence Persists jobs, specs, vector Blobs, and findings in IndexedDB via Dexie. Exports printable HTML reports and JSON audit logs with strict HTML escaping. Does not sync across devices or offer cloud backup by design. All data stays local to the workstation.

Why Does Open Innovation Matter?

Open innovation is what makes Tolerix viable as a real tool for small shops.

  1. Zero Marginal Cost for Small Business: A small laser engraving business operating on Etsy or at weekend craft markets cannot afford recurring API subscription tiers or usage fees per preflight check. Open-weight models like Gemma run on hardware the maker already owns, costing zero dollars in cloud API bills.
  2. Total Workshop Privacy and IP Protection: Makers handle proprietary product designs, unreleased prototypes, and custom corporate logos. Sending these customer files to third-party proprietary AI cloud APIs introduces privacy risks and intellectual property concerns. With open-weight models and local execution, customer data never leaves the workshop workstation.
  3. Offline Reliability in the Garage: Laser cutters and CNC routers are frequently installed in garages, basements, or industrial park units where Wi-Fi is spotty or nonexistent. Tolerix runs completely offline from local cache, so production never halts because the internet went down.
  4. No Vendor Lock-In: Proprietary APIs change prices, alter deprecation schedules, and introduce rate limits. Open weights give builders stability and permanence.

My Agent Session

Building Tolerix: Local-First Preflight & AI Geometry Engine for Fabrication
You

Build Tolerix, a web application for manufacturing preflight checks. Build the UI following the visual design specifications and ensure responsive layouts.

Agent

Constructed the landing page, dashboard navigation, and 4-step job creation pipeline using React 19, TypeScript, and Tailwind CSS v4. Verified visual layout, clean asset rendering, and responsive behavior across screen sizes.

You

Implement the complete production-ready backend and local AI functionality for Tolerix on device with zero cloud dependencies.

Agent

Designed and implemented a 100% local-first architecture. 1) IndexedDB persistent layer via Dexie for jobs, files, audit runs, and machine profiles. 2) Local LiteRT-LM WebGPU runtime streaming and caching Gemma 2B and Gemma 4B open weights. 3) Deterministic SVG geometry engine calculating 2D affine transform stacks, closed path loops, and unit conversions.

You

Audit the implementation for mathematical correctness in SVG bounds, duplicate path detection, strict SVG sanitization, model cache byte integrity, and HTML report escaping.

Agent

Audited and refactored geometry and security components: 1) Analytical derivative extrema for quadratic/cubic Bézier curves and elliptical arcs. 2) 2D affine matrix multiplication order fixed for nested coordinate groups and non-zero viewBox origins. 3) Path duplicate comparison upgraded to normalized coordinate sequences with reversal invariance. 4) Strict SVG element and attribute allowlist blocking scripts, inline handlers, XXE entities, and external URLs. 5) Context-aware HTML escaping for print reports.

You

Remove placeholder jobs and reports, and draft the Hacktoberfest Side Hustle challenge submission.

Agent

Purged all mock seed jobs from the database and cleaned up form default states so every newly created job is real. Drafted post.md with architecture diagrams, feature matrix, side hustle business model, and Gemma partner category.

Developing Tolerix with an AI agent allowed rapid iteration across mathematically demanding components: implementing analytical Bézier curve derivative extrema, verifying 2D affine transform matrix multiplication, establishing DOM sanitization rules against SVG-based exploits, and engineering zero-cloud IndexedDB workflows.

My First User

I showed Tolerix to Uncle, a maker who runs a custom wooden signage and acrylic badge side business out of his workshop using an 80W CO2 laser.

He tested the app by pasting an actual customer email request ("Please cut 25 frosted acrylic badges, 75 x 45 mm, with rounded corners and our logo engraved") along with the customer's uploaded SVG file.

Tolerix immediately caught two problems:

  1. The SVG geometry was drawn at 60 x 36 mm instead of the requested 75 x 45 mm (a scaling error from the customer's design software).
  2. The outer perimeter was split into two unjoined path segments rather than a single continuous closed contour.

He said: "Catching that scale error before cutting saved me an entire 12 x 24 inch acrylic sheet ($18) and thirty minutes of re-cutting. Having this run right on my shop laptop without logging into a cloud service makes it a no-brainer."

Prize Categories

Best Use of Gemma

Tolerix enters the Best Use of Gemma category.

It directly integrates Google's open-weight Gemma models (gemma-4-E2B-it-litert-lm and gemma-4-E4B-it-litert-lm) executing on device via the LiteRT-LM WebGPU runtime:

  • On-Device Inference: Downloads verified weights into the browser Cache Storage API (tolerix-models-v1) with full byte-level integrity verification.
  • Structured Parsing: Gemma parses ambiguous natural language instructions into structured manufacturing specifications (quantity, bounding box dimensions, physical units, material type, thickness, and cutting/engraving operations).
  • Graceful Degradation: Users can switch between Gemma 2B (for lightweight laptop GPUs) and Gemma 4B (for high-precision extraction), with deterministic heuristics serving as a fallback.

Best Use of Render

Tolerix is deployed in Render

Top comments (0)