Architecture¶
Runtime shape¶
The browser/server edition is one local process pair in development and one local process in production-style mode:
Desktop browser
├─ React + TypeScript editor (Vite during development)
├─ React Three Fiber / Three.js viewport
└─ Canvas/SVG PNG + PDF renderers and JSZip batch packaging
│ localhost REST/JSON
▼
Express server on 127.0.0.1:4280
│ prepared statements + transactions
▼
SQLite file at .data/casa.sqlite
│ validated per-project mirror
▼
.data/projects/<project UUID>/{project.json,assets/,exports/}
Vite proxies /api to the Express server in development. After npm run build,
Express serves both dist/ and /api from 127.0.0.1:4280. Every application
listener stays on the loopback interface, and the runtime uses local
integrations.
The Windows desktop edition wraps the same built React client with Tauri:
Tauri WebView (neutral executable icon)
├─ bundled React/Three.js client
└─ local-only icon override in WebView storage
│ REST/JSON on 127.0.0.1:4281
▼
Bundled Node.js sidecar + bundled Express API
│ prepared statements + transactions
▼
Tauri application-data directory
├─ house-infrastructure.sqlite
└─ projects/<project UUID>/{project.json,assets/,exports/}
scripts/prepare-desktop.mjs bundles server/desktop.ts, copies the current
Node.js 24 runtime as a target-triple Tauri sidecar, and obtains the matching
official Node.js license for the installer resources. Tauri marks that process
as the single desktop entry, while the client waits for /api/health before
loading project data. Tauri embeds the neutral Windows icons and WebView2
bootstrapper, then produces a current-user NSIS installer. Generated sidecars,
licenses, Rust targets, and installers are ignored.
Client¶
src/App.tsxcoordinates project state, Edit/View workspaces, independent sidebars, selection, creation tools, autosave, in-memory undo/redo, shortcuts, capture, backup/import, and project management.src/editor/HouseViewport.tsxrenders schematic walls, rooms, devices, physically scaled route widths, measurement lines, the metric grid, and predictable orbit/pan/zoom controls. Rendering-only wall splitting assigns overlapping corner, crossing, and collinear volumes to one stable wall while persisted wall records stay separate.src/components/LeftSidebar.tsxcontains the active-level selector, full-house scope, compact Services and Rooms popovers, spatial photo controls, layered-wall defaults, creation tools, the extensible device catalogue, and route setup.src/components/LevelManagerDialog.tsxowns ordered floor editing and local image-blueprint upload, zoomable persisted two-point calibration, saved-status display, project-origin display, cross-floor registration anchors, transform, opacity, and visibility. Pure registration transforms live insrc/lib/blueprint.ts.src/components/FurnitureDialog.tsxselects schematic appliance/reference presets with useful default services, mounting backs, and ports.src/components/PropertiesPanel.tsxexposes exact wall geometry, compact technical-device placement, cable, pipe, duct, route-point, installation, display-colour, and custom-property fields. Device mounting-face and connection-point authoring is centralized in Settings and the route endpoint workflow. UI coordinates use X/Y on plan and Z vertically while stored Three.js boundary data remains{x,y,z}withyvertical.src/components/ElevationDialog.tsxprovides an A2/A3/A4 paper preview, editable caption, granular per-class/per-object content visibility, fixed 5× PNG/PDF generation, and deterministic PNG/PDF ZIP batches. Duplicate wall names are disambiguated before ZIP creation.src/components/ViewSnapshotDialog.tsxprepares a scalable A2/A3/A4 landscape paper master with the current north orientation and exports fixed 5× PNG/PDF files.src/lib/viewExport.tscomposes the SVG-based print sheet around a high-resolution Three.js scene capture, whilesrc/lib/pdf.tswrites the single-page image PDF without a remote service.src/components/OverviewPage.tsxcomputes interactive whole-house MEP reports directly from the current local project snapshot, including filtered asset inventory and room/zone organization.src/lib/lightingNetwork.tsderives switch-to-light continuity from cable endpoints plus explicit junction, panel, and riser correspondences. The dedicated Light view renders only that network on the active floor and reports incomplete continuity.PhotoMarkerDialog.tsxmanages local project photographs, while the editor's Services popup controls marker visibility, category filters, and point placement. Marker visibility starts off for each opened project. Marker metadata is part of the immutable project snapshot; JPEG/PNG/WebP bytes are uploaded only to the matching project workspace underassets/photos/.src/components/SettingsDialog.tsxuses expandable sections and reusable hover-help targets for route tiers, a 15 cm default cable reference below the floor, configurable pipe/cable/duct vertical order and spacing, pipe/duct gravity grades, lateral clearances, IEC-aligned project naming conventions, drafting preferences, category colours, and every device/furniture type's size, mounting back, association, and positioned default ports. Its project diagnostics aggregate 3D route clashes, cable runs beyond the 10 m target plus 1 m tolerance, incomplete riser links/flow, invalid panel/junction correspondence, and devices with no route attachment.RackSettingsPanel.tsx,RackPreview3D.tsx, the sharedRackModel3D.tsx, andsrc/lib/rack.tsadd capacity-scaled 800 × 1000 mm per-rack U layouts, open-frame 3D equipment, exact service-coloured front/back port grids, configurable numbered/brush patch panels, patch-panel front/rear pairs, reciprocal internal leads, normalized house endpoints, and live connected-route inventories.src/lib/appBranding.tsowns the neutral icon fallback and validates the optional private icon override. The override uses local WebView/browser storage only and is deliberately absent fromProjectSnapshot, SQLite, exports, and backups. Settings exposes it in the Administration section.src/components/RoutePortDialog.tsxmakes endpoint selection explicit in a compact two-column grid. Port occupancy is derived from route endpoint relationships; reassigning the previous route releases an occupied physical port. When the compatible endpoint list is empty, an embedded 3D device editor creates a precisely positioned instance port and resumes the pending route with its draft intact. Junction boxes and electrical panels expose the same editor continuously;src/lib/devicePorts.tsderives their minimum enclosure dimensions from each port's required termination area.src/components/CustomDeviceTypeDialog.tsxcreates extensible catalogue entries with category, schematic shape, exact centimetre dimensions, display colour, and a local preview.src/i18n/en.tsandsrc/i18n/it.tsare the two local UI dictionaries.src/lib/i18n.tsxstores the EN/IT choice in browser-local storage, with English as the default. Translation stays inside these bundled dictionaries.src/lib/italianColors.tscontains Italy-oriented conductor, Ethernet pair, conduit, pipe-identification, container, and project display defaults. Regulatory/reserved meaning, physical product colour, and user/project display colour are deliberately separate fields.src/lib/geometry.tsis the integer-millimetre geometry boundary. Three.js receives metre values only at render time. Wall paths remain wall-local and orthogonal in plan; floor and ceiling paths use a direct visibility-graph route around equipment, pipe/duct runs receive a flow-oriented gravity grade, and crossings use bounded raised-cosine clearance hills that remain outside the editable turn list.src/lib/routeLayout.tsperforms bounded floor-level route-cluster analysis: it detects one run imposing detours on nearby services, rebuilds eligible concealed floor/ceiling alternatives, resolves the affected set in a coordinated order, and exposes before/after conflict, bend, and length metrics for an atomic 3D preview/apply workflow.src/lib/elevation.tsrenders technical wall schemes directly to a local canvas and usessrc/lib/labelLayout.tsto place annotation blocks without collisions while retaining leader lines to their measured or modelled anchors.src/lib/riser.tsvalidates one-to-one, same-service cross-floor route links and groups linked floor records into physical sleeve lanes.src/lib/diagnostics.tsderives route, riser, panel/junction correspondence, and unconnected-device health lists from persisted relationships.
Project edits are immutable snapshots. A bounded 50-state history provides undo/redo. Autosave sends the current validated snapshot after an 800 ms quiet period, while explicit Save uses the same transaction path.
Server¶
server/index.tsdefines the localhost-only REST API, import validation, meaningful errors, production static serving, a strict loopback Host allowlist, explicit local/Tauri origins, and Fetch-Metadata rejection for cross-site mutations.server/desktop.tsis the sidecar entry point on127.0.0.1:4281; the browser/server entry points remain on127.0.0.1:4280.server/validation.tsvalidates project snapshots and backup envelopes before any write.server/db.tsowns migration application, prepared queries, normalized reconstruction, and transactional saves.server/migrations/001_initial.sqldefines the initial normalized schema and query-driven indexes. Later numbered migrations are append-only; migrations 004–006 add visual metadata, level blueprints, device mounting/port placement, and explicit floor ordering. Migration 007 adds normalized lighting-control relationships and photo-marker/asset metadata. Migration 008 adds normalized wall core and left/right lining columns. Migration 009 adds per-port termination-space requirements for expandable enclosures. Migration 010 adds application-wide built-in device defaults shared across local projects; project-created custom types remain isolated. Migration 011 adds the optional route installation date used by the shared installation workflow. Migration 012 marks automatically generated route points used for crossing clearance.
Whole-project saves use BEGIN IMMEDIATE, replace the project's dependent rows in relationship-safe order, and either commit the complete snapshot or roll everything back. In the same transaction, edits to built-in device definitions update the global local catalogue; loading or creating any project overlays that catalogue before returning data. Installed device instances and user-created custom types remain project-owned. Imports go through the same validator and repository transaction. After each successful save, the server atomically refreshes the project's local project.json mirror inside a UUID-validated workspace path derived by the server.
Performance decisions¶
Wall and device meshes are simple low-poly primitives, and the project model keeps integer millimetres to avoid repeated floating-point drift. Visible curved-route geometry is memoized by project/view inputs, wall associations use indexed lookup, and each visible route fragment is submitted as one polyline for all sampled segments. The canvas renders on demand and switches to continuous frames while animated X-ray flow markers are active; compass updates bypass React state. Version 0.3.0 is sized for normal residential models. Profiling will guide future use of instanced meshes and spatial indexing.