How stevenmorano/print-frame-visualizer works
Purpose and Runtime
A private, local-first browser tool for planning print, mat, and frame combinations. It renders proportional previews, manages reusable projects and custom frame sizes, and exports annotated PNG snapshots. Runtime is React 19 + TypeScript in Vite; production output is static dist assets with no backend, account system, or cloud service.
Entry points: src/main.tsx mounts the application; src/App.tsx contains the primary UI and interaction orchestration; index.html hosts the Vite application root.
Application Composition
src/App.tsx is the central composition boundary: it connects editing controls, preview state, project lifecycle actions, persistence, and export. Application state is represented through shared domain types in src/types.ts and project-level construction/normalization logic in src/project.ts.
The UI is a single browser application rather than a service-oriented system. State changes from dimension inputs, preset selection, image controls, and project actions flow through the app’s React state, then are persisted or rendered as appropriate.
Framing Geometry and Preview Model
src/geometry.ts is the core domain-calculation layer. It computes relationships among artwork dimensions, frame cavity, frame-face width, mat borders/opening, visible art, orientation, and fit warnings. This is the main correctness boundary: visual rendering and export should consume derived geometry rather than duplicate measurements.
src/geometry.test.ts validates these calculations. src/styles.css supports the layered visual presentation and responsive editor layout, while src/App.tsx turns computed geometry into the interactive on-screen preview.
Presets and Dimension Inputs
src/presets.ts owns the standard frame-size catalog and supports matching/searching selectable cavity dimensions. It is combined with orientation-aware project state from src/project.ts, allowing standard and custom sizes to follow portrait/landscape choices.
The application supports exact decimal-inch values, mobile-oriented whole/fraction controls, paired mat borders, and advertised mat-opening entry. Conversion between these input representations is a UI/domain synchronization concern coordinated in src/App.tsx and grounded by src/geometry.ts.
Project Lifecycle and Browser Persistence
src/project.ts defines project creation, duplication, and domain defaults/transformations. src/storage.ts is the persistence boundary for projects, custom frame presets, and uploaded image data.
Persistence uses native IndexedDB only. Reads occur on browser startup/loading actions; saves, deletes, and custom-preset updates write locally. There is no API, authentication, telemetry, server-side validation, or cross-device synchronization. Browser site-data clearing is therefore a material data-loss boundary.
Image Preparation and Export
Uploaded print imagery is kept browser-local and represented in project state. src/App.tsx applies user-controlled zoom, translation, and rotation for the preview; no perspective-correction stage exists.
src/exportSnapshot.ts is the output boundary. It uses Canvas to generate a high-resolution annotated PNG from project/framing geometry and image-placement state. Export must preserve the same measurement convention and layered mat/art/frame interpretation used by src/geometry.ts and the live preview.
Build and Verification Boundaries
Vite configuration is in vite.config.ts; package scripts and dependency/runtime declarations are in package.json. TypeScript configuration is rooted at tsconfig.json. The expected delivery artifact is a static Vite build, not a deployed service.
Core automated coverage is focused on framing math in src/geometry.test.ts; linting, type checking, tests, and production build provide the main validation pipeline.
Main entry points: App.tsx Editor orchestration · geometry.ts Framing geometry · types.ts Shared project types · main.tsx React mount
Components 16
Browser application
- Vite HTML root
index.html - React mount
src/main.tsx - Editor orchestration · Coordinates controls, project actions, preview state, persistence, and export.
src/App.tsx - Editor styles
src/styles.css
Framing domain
- Shared project types
src/types.ts - Project lifecycle · Creates, duplicates, normalizes, and orients projects.
src/project.ts - Frame-size presets
src/presets.ts - Framing geometry · Derives cavity, mat, visible art, orientation, and fit warnings.
src/geometry.ts
Local I/O
- Browser persistence · Stores projects, custom presets, and uploaded image data locally.
src/storage.ts - IndexedDB site data · Clearing browser site data loses local projects and images.
- PNG snapshot export · Generates annotated high-resolution PNGs from geometry and image placement.
src/exportSnapshot.ts
Build & verification
- Scripts & dependencies
package.json - Vite build config
vite.config.ts - TypeScript config
tsconfig.json - Geometry tests · Core automated coverage for framing calculations.
src/geometry.test.ts - Static dist assets · Static browser-delivered output with no backend.
Connections 20
- Vite HTML root → React mount: loads
- React mount → Editor orchestration: mounts
- Editor orchestration → Editor styles: uses
- Editor orchestration → Shared project types: uses state types
- Editor orchestration → Project lifecycle: creates and updates projects
- Editor orchestration → Frame-size presets: selects frame sizes
- Editor orchestration → Framing geometry: derives live preview
- Project lifecycle → Shared project types: constructs
- Project lifecycle → Frame-size presets: applies orientation
- Framing geometry → Shared project types: consumes dimensions
- Editor orchestration → Browser persistence: loads and saves
- Browser persistence → IndexedDB site data: reads and writes
- Editor orchestration → PNG snapshot export: exports snapshot
- PNG snapshot export → Framing geometry: uses derived measurements
- PNG snapshot export → Shared project types: uses image placement
- Geometry tests → Framing geometry: validates
- Scripts & dependencies → Vite build config: runs build
- Scripts & dependencies → TypeScript config: runs type check
- Vite build config → Static dist assets: produces
- React mount → Static dist assets: bundled into