Skip to content

Latest commit

Β 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Vitralis

Stained Glass & Tiffany Studio Cost Calculator

Vitralis Logo
Comprehensive Cost Accounting, Quotation Generator, and Progressive Web App (PWA) for Stained Glass Artisans and Tiffany Technique Workshops.
React 19 TypeScript Vite 8 Tailwind CSS PWA Ready Vitest GitHub Actions Release Please MIT License

πŸ“‘ Table of Contents


πŸ’Ž Overview & Vision

Vitralis is a zero-latency, offline-first Progressive Web App (PWA) specifically engineered for stained glass artisans, Tiffany lamp creators, and architectural leaded glass studios.

Crafting stained glass involves layered and volatile material costs (colored cathedral/opal sheets, copper foil rolls, high-grade tin-lead solders, toxic patina chemicals), high-wear diamond tools (grinders, cutter heads, soldering tips), intensive electrical consumption, and meticulous multi-stage labor.

Vitralis replaces guesswork and spreadsheets with:

  • Exact Mathematical Cost Modeling: Instant recalculation across glass geometries, consumables, tool wear, and kWh electricity.
  • Craftsman Ergonomics: Anti-AI-slop atelier design language, 8-state tactile inputs, and responsive dark/light themes.
  • Client-Ready Commercial Outputs: Formal print/PDF quotation sheets, WhatsApp text summaries, and JSON backup portability.
  • 100% Client-Side Privacy: No external backend required; all project and studio records are securely stored locally via schema-versioned LocalStorage.

✨ Key Features

Category Highlights
🎨 Multi-Glass Geometry Engine Rectangles ($W \times H$), Circles ($\varnothing$), custom polygons ($\text{cm}^2 / \text{m}^2$), per-$\text{m}^2$, per-$\text{cm}^2$, or whole-sheet costing.
🧡 Consumables Accounting Black/Copper/Silver backed foils, 60/40 & 50/50 solder alloys, flux, black/copper patina, zinc came, brass rods, hanging rings & chains.
⏳ 8-Stage Artisan Labor Cartooning/design, scoring/breaking, grinding/fitting, foiling, soldering & beading, patina/waxing, framing, shockproof packaging.
βš™οΈ Tool Depreciation Proportional wear on grinder machines, diamond cutter heads, soldering stations, running pliers, and LED workbenches.
⚑ Energy & Power Metering Aggregates active tool wattages and calculates exact kilowatt-hour (kWh) utility expenses based on regional studio rates.
πŸ›‘οΈ Waste & Breakage Insurance Configurable glass breakage risk factor (%) applied to materials or entire base cost.
πŸ“ˆ Commercial Margin & Analytics Target profit markup (%), discount deduction, VAT/Sales tax toggle, effective hourly studio yield ($\text{β‚Ί/hr}$ or $$ /\text{hr}$).
πŸ“„ Quotation & Export Engine Formal printable certificate/quote document (@media print), PDF generation, one-click WhatsApp text format, JSON import/export.
🧰 Artisan Utility Modals Solder weight estimator based on linear foil and bead profile, circular area calculator, glass piece perimeter estimator.
🌍 Localization & Currencies Full Turkish (TR) and English (EN) translations with native support for TRY (β‚Ί), USD ($), EUR (€), GBP (Β£), CAD (CA$), AUD (A$), CHF.
πŸ“± Offline PWA Architecture Standalone home screen installation, service worker precaching, and instant offline boot.

πŸ“Š System Architecture & Diagrams

1. High-Level System Architecture

graph TB
    subgraph Client_App ["Vitralis PWA Application (Client-Side)"]
        direction TB
        UI["Atelier UI Layer (React 19 + Tailwind CSS v4)"]

        subgraph State_Management ["State Management Layer"]
            StudioCtx["StudioContext<br/>(Profile, Currency, Theme, Defaults)"]
            ProjectCtx["ProjectContext<br/>(Active Project, Saved Projects, Mutations)"]
        end

        subgraph Core_Engine ["Pure Mathematical Calculation Engine"]
            CalcGlass["Glass Geometry & Area Calculator"]
            CalcConsumables["Consumables & Chemical Aggregator"]
            CalcLabor["8-Stage Labor Matrix"]
            CalcWear["Equipment Depreciation & kWh Electricity"]
            CalcWaterfall["Waterfall Commercial Profit & Tax Engine"]
        end

        subgraph Persistence_Layer ["Local Storage & Cache"]
            LS[("Browser LocalStorage<br/>(Schema Versioned JSON)")]
            SW["Service Worker (Workbox)<br/>Precached App Shell & Assets"]
        end

        subgraph Output_Adapters ["Export & Presentation Adapters"]
            PrintDoc["Formal Print / PDF Quotation Sheet"]
            WhatsApp["Formatted Text Messenger Generator"]
            JSONExport["JSON Project Backup / Restore"]
        end
    end

    UI --> State_Management
    State_Management --> Core_Engine
    State_Management <--> Persistence_Layer
    Core_Engine --> Output_Adapters
Loading

2. Cost Calculation Waterfall Pipeline

flowchart TD
    G["1. Total Glass Cost<br/>Area Γ— Unit Price"] --> RawBase["Raw Base Cost"]
    C["2. Total Consumables<br/>Foil + Solder + Flux + Patina + Came"] --> RawBase
    L["3. Artisan Labor Cost<br/>8 Stages Γ— Hourly Rate"] --> RawBase
    E["4. Tool Depreciation<br/>Hourly Wear Rate Γ— Usage"] --> RawBase
    P["5. Electricity Cost<br/>Total kWh Γ— Energy Rate"] --> RawBase

    RawBase --> WasteCalc{"Waste Mode"}
    WasteCalc -->|Materials Only| W1["Waste Amount = Materials Γ— Waste%"]
    WasteCalc -->|Entire Base Cost| W2["Waste Amount = RawBase Γ— Waste%"]

    W1 --> CostWaste["Cost with Waste Risk"]
    W2 --> CostWaste

    CostWaste --> Profit["+ Target Profit Margin %"]
    Profit --> Subtotal["Subtotal Selling Price"]

    Subtotal --> Disc["- Special Client Discount %"]
    Disc --> NetPrice["Net Price After Discount"]

    NetPrice --> Tax["+ VAT / Sales Tax %"]
    Tax --> Final["🎯 Final Selling Price"]

    Final --> Analytics["Studio Analytics: Hourly Yield, Piece Cost, Material Ratio"]
Loading

3. Application State & Context Flow

sequenceDiagram
    autonumber
    actor Artisan as Artisan / User
    participant Header as UI Header / TabNav
    participant Comp as Calculator Sections
    participant PCtx as ProjectContext
    participant Engine as calculations.ts
    participant LS as LocalStorage
    Artisan ->> Header: Selects Currency / Theme / Tab
    Artisan ->> Comp: Inputs Glass Dimensions or Solder Grams
    Comp ->> PCtx: Dispatches updateGlassItem() / updateConsumables()
    PCtx ->> Engine: Calls calculateProjectCostBreakdown(project)
    Engine -->> PCtx: Returns updated immutable CostBreakdown
    PCtx ->> LS: Auto-persists active project state
    PCtx -->> Comp: Re-renders reactive QuickCostSummary & Charts
    Artisan ->> Header: Clicks "Print Quotation"
    Header ->> Comp: Displays PrintableQuote & triggers Window.print()
Loading

πŸ“ Mathematical Formulation & Cost Logic

Vitralis executes calculations using strict floating-point math verified with automated unit tests:

1. Glass Surface Area & Pricing

$$\text{Area}_{\text{Rect}} = \frac{W_{\text{cm}} \times H_{\text{cm}}}{10000}, \quad \text{Area}_{\text{Circle}} = \frac{\pi \times (D_{\text{cm}} / 2)^2}{10000}$$ $$\text{Total Glass Cost} = \sum_{i=1}^{N} \left (\text{Area}_i \times \text{Quantity}_i \times \text{UnitPrice}_i \right)$$

2. Consumables Aggregation

$$\text{Foil Cost} = \text{Length}_{\text{m}} \times \left (\frac{\text{Roll Price}}{\text{Roll Length}_{\text{m}}} \right)$$ $$\text{Solder Cost} = \text{Weight}_{\text{g}} \times \left (\frac{\text{Spool Price}}{\text{Spool Weight}_{\text{g}}} \right)$$ $$\text{Total Consumables} = \text{Foil} + \text{Solder} + \text{Flux} + \text{Patina} + \text{Came} + \text{Reinforcement} + \text{Custom Consumables}$$

3. Equipment Depreciation & Utility Power

$$\text{Tool Wear Cost} = \sum \left (\frac{\text{Tool Purchase Price}}{\text{Expected Lifespan Hours}} \times \text{Project Usage Hours} \right)$$ $$\text{Electricity Cost} = \left (\sum \frac{\text{Device Watts} \times \text{Hours}}{1000} \right) \times \text{Electricity Rate per kWh}$$

4. Commercial Markup & Studio Yield

$$\text{Raw Base Cost} = \text{Glass} + \text{Consumables} + \text{Labor} + \text{Depreciation} + \text{Electricity}$$ $$\text{Cost with Waste} = \text{Raw Base Cost} + \text{Waste Amount}$$ $$\text{Subtotal Price} = \text{Cost with Waste} \times \left (1 + \frac{\text{Profit Margin %}}{100}\right)$$ $$\text{Final Selling Price} = (\text{Subtotal Price} - \text{Discount}) \times \left (1 + \frac{\text{Tax %}}{100}\right)$$ $$\text{Effective Hourly Yield} = \frac{\text{Net Profit Amount} + \text{Total Labor Cost}}{\text{Total Labor Hours}}$$


πŸ’‘ Artisan Rules of Thumb

Vitralis incorporates real-world workshop benchmarks collected from experienced stained glass artists:

  1. Solder to Foil Ratio:
    • For standard $7/32''$ ($5.5\text{mm}$) copper foil with balanced front and back bead lines: $$\text{Estimated Solder (g)} \approx \text{Foil Length (m)} \times 18\text{g to } 22\text{g}$$
  2. Foil Length Approximation from Piece Count:
    • For decorative organic panels with average piece perimeters of $18\text{cm}-24\text{cm}$: $$\text{Estimated Foil (m)} \approx \frac{\text{Piece Count} \times \text{Avg Perimeter (cm)}}{175}$$
  3. Glass Cutting Scrap & Breakage Margin:
    • Standard geometric designs: $10% - 12%$
    • Intricate curves, deep concave cuts, or mouth-blown antique glass: $20% - 25%$

πŸ›  Tech Stack & Libraries

  • Core Framework: React 19.2 (Functional Components, Hooks, Context API)
  • Type System: TypeScript 6.0 (Strict mode, full interface coverage)
  • Build Tool: Vite 8.2 (Lightning fast HMR, Rollup production bundles)
  • Styling & Design System: Tailwind CSS v4.3 with custom glassmorphism tokens and @custom-variant dark
  • Icons: Lucide React
  • Test Runner: Vitest 4.1 (Fast unit test suite)
  • PWA & Service Worker: vite-plugin-pwa + Google Workbox
  • Visual Effects: Canvas Confetti for project save celebrations

πŸ“‚ Project Architecture

vitralis/
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ dependabot.yml               # Automated weekly dependency updates
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml                   # CI: Lint, Typecheck, Test, Build
β”‚       β”œβ”€β”€ deploy.yml               # CD: Automated deployment to GitHub Pages
β”‚       β”œβ”€β”€ release-please.yml       # Release Please: Semantic release & CHANGELOG
β”‚       └── dependabot-auto-merge.yml# Auto-merge for non-major dependabot PRs
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ favicon.svg                  # SVG vector favicon
β”‚   β”œβ”€β”€ favicon-96x96.png            # High-res desktop favicon
β”‚   β”œβ”€β”€ favicon.ico                  # Legacy browser favicon
β”‚   β”œβ”€β”€ apple-touch-icon.png         # iOS touch icon
β”‚   β”œβ”€β”€ web-app-manifest-192x192.png # PWA 192x192 icon
β”‚   β”œβ”€β”€ web-app-manifest-512x512.png # PWA 512x512 icon
β”‚   └── site.webmanifest             # Web application manifest
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”œβ”€β”€ project.ts               # Stained glass data models & cost structures
β”‚   β”‚   └── studio.ts                # Studio profile, currencies & defaults
β”‚   β”œβ”€β”€ constants/
β”‚   β”‚   β”œβ”€β”€ defaults.ts              # Currencies, default tools, fallback project
β”‚   β”‚   └── templates.ts             # Pre-configured templates (Suncatcher, Lamp, Panel)
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ StudioContext.tsx        # Studio settings, theme & language state
β”‚   β”‚   └── ProjectContext.tsx       # Live calculations, storage & project actions
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ calculations.ts          # Pure mathematical cost engine
β”‚   β”‚   β”œβ”€β”€ calculations.test.ts     # Automated unit test suite
β”‚   β”‚   β”œβ”€β”€ formatters.ts            # Currency, area, time, and percentage formatters
β”‚   β”‚   └── exportUtils.ts           # JSON export/import & WhatsApp quote copy
β”‚   β”œβ”€β”€ i18n/
β”‚   β”‚   β”œβ”€β”€ tr.ts                    # Turkish localization dictionary
β”‚   β”‚   β”œβ”€β”€ en.ts                    # English localization dictionary
β”‚   β”‚   └── index.ts                 # Translation helper
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx           # Atelier header, currency/language selectors
β”‚   β”‚   β”‚   β”œβ”€β”€ TabNavigation.tsx    # Responsive segmented navigation
β”‚   β”‚   β”‚   β”œβ”€β”€ QuickCostSummary.tsx # Sticky live calculation ledger
β”‚   β”‚   β”‚   β”œβ”€β”€ CustomSelect.tsx     # Custom accessible tactile dropdown popover
β”‚   β”‚   β”‚   β”œβ”€β”€ GlassCard.tsx        # Accordion-enabled glass container
β”‚   β”‚   β”‚   β”œβ”€β”€ NumberInput.tsx      # Spinner-free number input with units
β”‚   β”‚   β”‚   └── Modal.tsx            # Accessible modal dialog
β”‚   β”‚   β”œβ”€β”€ calculator/
β”‚   β”‚   β”‚   β”œβ”€β”€ GlassSection.tsx     # Multi-glass items & shape calculators
β”‚   β”‚   β”‚   β”œβ”€β”€ ConsumablesSection.tsx # Foil, solder, chemicals & came
β”‚   β”‚   β”‚   β”œβ”€β”€ LaborSection.tsx     # 8-stage artisan labor breakdown
β”‚   β”‚   β”‚   β”œβ”€β”€ EquipmentSection.tsx # Tool wear & machine depreciation
β”‚   β”‚   β”‚   β”œβ”€β”€ ElectricitySection.tsx # Wattage & kWh electricity consumption
β”‚   β”‚   β”‚   β”œβ”€β”€ MarginWasteSection.tsx # Waste risk, profit margin & taxes
β”‚   β”‚   β”‚   └── CostBreakdownChart.tsx # SVG donut visualization & studio KPIs
β”‚   β”‚   β”œβ”€β”€ projects/
β”‚   β”‚   β”‚   β”œβ”€β”€ ProjectManager.tsx   # Saved project search, filter & backup
β”‚   β”‚   β”‚   └── TemplateSelector.tsx # Pre-built stained glass starter presets
β”‚   β”‚   β”œβ”€β”€ quote/
β”‚   β”‚   β”‚   └── PrintableQuote.tsx   # Formal print/PDF quotation document
β”‚   β”‚   β”œβ”€β”€ studio/
β”‚   β”‚   β”‚   └── StudioSettings.tsx   # Workshop hourly rates & default prices
β”‚   β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”‚   └── ArtisanToolsModal.tsx# Solder estimator & geometry helpers
β”‚   β”‚   └── pwa/
β”‚   β”‚       └── PWAInstallBanner.tsx # PWA install prompt & offline status
β”‚   β”œβ”€β”€ App.tsx                      # Root workbench view & layout
β”‚   β”œβ”€β”€ index.css                    # Tailwind CSS v4 & custom design tokens
β”‚   └── main.tsx                     # Application bootstrapping
β”œβ”€β”€ .release-please-manifest.json    # Release Please version manifest
β”œβ”€β”€ release-please-config.json       # Release Please configuration
β”œβ”€β”€ eslint.config.js                 # ESLint flat config
β”œβ”€β”€ package.json                     # Scripts & project dependencies
β”œβ”€β”€ tsconfig.json                    # TypeScript compiler options
β”œβ”€β”€ vite.config.ts                   # Vite & PWA bundler configuration
└── README.md                        # Documentation

πŸš€ Getting Started & Local Development

Prerequisites

  • Node.js: v18.0.0 or newer (v22 recommended)
  • Package Manager: npm, pnpm, or yarn

Quick Installation

# 1. Clone the repository
git clone https://github.com/your-username/vitralis.git
cd vitralis

# 2. Install dependencies
npm ci

# 3. Start local development server
npm run dev

Open http://localhost:5173 in your browser.


πŸ§ͺ Testing & Quality Assurance

Vitralis includes a full suite of automated unit tests covering all core calculation formulas and formatting utilities:

Command Description
npm test Runs the Vitest automated test suite
npm run lint Performs static code analysis with ESLint
npm run typecheck Validates TypeScript types (tsc -b --noEmit)
npm run validate Runs Lint + Typecheck + Tests + Build in one step
npm run build Builds the production bundle & PWA service worker
$ npm run validate

βœ“ ESLint: 0 errors
βœ“ TypeScript: Clean type check
βœ“ Vitest: 4/4 calculation unit tests passed
βœ“ Vite: Production bundle generated (dist/)

πŸ”§ CI/CD & DevOps Automation

Vitralis utilizes fully automated GitHub Actions workflows for continuous integration, zero-downtime deployment, and automated semantic releases:

1. Continuous Integration (CI)

  • Workflow: .github/workflows/ci.yml
  • Triggers: Push & Pull Request on main, master, develop.
  • Checks: npm ci βž” npm run lint βž” npm run typecheck βž” npm test βž” npm run build βž” Artifact Verification.

2. Continuous Deployment (CD)

3. Dependabot Dependency Management

4. Automated Releases with Release Please

  • Workflow: .github/workflows/release-please.yml
  • Powered by: Google's release-please-action.
  • Automatically analyzes Conventional Commits, maintains CHANGELOG.md, bumps package.json semver, and tags GitHub Releases.

πŸ“± Progressive Web App (PWA) Capabilities

Vitralis is engineered as a modern Progressive Web App:

  • Offline Reliability: Service Worker precaches all HTML, CSS, JavaScript, web fonts, and manifest assets.
  • App Installation: Native "Add to Home Screen" prompt for iOS Safari, Android Chrome, macOS, and Windows.
  • Fast Startup: Sub-100ms startup times without network roundtrips.

🀝 Contributing & Community

Contributions are warmly welcome! Please read our guidelines before submitting pull requests:


πŸ“œ License

This project is licensed under the MIT License β€” feel free to use, modify, and distribute for personal, studio, or commercial purposes.


Crafted with precision for stained glass artisans & studios worldwide. πŸͺŸβœ¨

About

Comprehensive Cost Accounting, Quotation Generator, and Progressive Web App for Stained Glass Artisans and Tiffany Technique Workshops.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages