🏗️ Architecture
ThermX system design, components, and data flow.
High-Level Overview
ThermX uses a modular design separating concerns into distinct layers:
- UI Layer (
src/ui/) — Canvas-based geometry editor and visualization - Model Layer (
src/model/) — Data structures for geometry, materials, boundary conditions, and physics - Solver Layer (
src/solver/) — FEM and specialized calculation engines - I/O Layer (
src/io/) — File import/export (THMX, DXF, DWG via libopencad WASM, PDF, CSV) - API Layer (
src/api/) — Authentication and backend integration - Auth Layer (
src/auth/) — Token management and credential storage
Core Components
Model (src/model/)
Project — Root data structure containing:
grid— Snap-to-grid settingslayers— Drawable layers (geometry organization)regions— 2D polygonal regions with material assignmentsboundaryConditions— Temperature/convection edgesmaterials— Material library with thermal propertiesmeshSettings— FEM mesh refinement parameterssolverSettings— Solver algorithm selectionresultsDisplay— Visualization preferencescircularPipes— Underfloor heating pipespsiComponents— Thermal bridge calculations (PSI values)sheets— PDF layout viewport definitionsviewSettings— Per-tab visibility toggles
Physics (physics.ts) — Constants and utilities:
- Stefan-Boltzmann constant (thermal radiation)
- Gravitational acceleration (convection)
- Universal gas constant
- Thermophysical property helpers
Solver (src/solver/)
- Core Solver — 2D FEM (Cholesky, CG, WebGPU algorithms)
- ISO 15099 (
iso15099.ts) — Glazing system calculations- Multi-pane window analysis
- Gas gap properties (air, argon, krypton, xenon)
- Nusselt number for natural convection
- Center-of-glass U-value
- Underfloor Heating
pipes.ts— Circular pipe modelpipeMesh.ts— Mesh generation for pipespipeConvective.ts— Convective heat transfer coefficientsunderfloor.ts— Full system calculations
Authentication (src/auth/)
tokenStore — localStorage-based token management:
saveToken()— Persist license tokenloadToken()— Retrieve stored tokenclearToken()— Remove token on logout
API (src/api/)
auth.ts — Backend integration:
login()— Email/password authenticationloginWithLicence()— License key validationvalidateToken()— Verify token validitylogout()— Clear token and session
Data Flow
Project Model
↓
Geometry + Materials + BCs
↓
Mesh Generation
↓
FEM Solver (2D) OR ISO 15099 (glazing) OR Pipe Heat Transfer
↓
Temperature & Heat Flux Results
↓
Visualization (color maps, isotherms, arrows)
↓
Export (PDF, CSV, DXF)
Build & Dependencies
- Vite — Module bundler for browser
- Tauri — Desktop app wrapper (Rust)
- PixiJS — Canvas rendering via WebGL
- spade WASM — Constrained Delaunay triangulation
- Immer — Immutable state updates
- Vitest — Unit testing framework
- TypeScript — Type safety
Testing
All modules include unit tests in tests/ directory. Run tests with:
npm test