# stevenmorano/print-frame-visualizer architecture

> Architecture diagram of the GitHub repository stevenmorano/print-frame-visualizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stevenmorano/print-frame-visualizer
- Repository: https://github.com/stevenmorano/print-frame-visualizer

## Overview

#### 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: [`src/App.tsx`](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/App.tsx) (Editor orchestration), [`src/geometry.ts`](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/geometry.ts) (Framing geometry), [`src/types.ts`](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/types.ts) (Shared project types), [`src/main.tsx`](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/main.tsx) (React mount)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser application"]
  node_html["Vite HTML root<br/>entry document<br/>[index.html]"]
  node_main["React mount<br/>browser entry<br/>[main.tsx]"]
  node_app["Editor orchestration<br/>React UI<br/>[App.tsx]"]
  node_styles["Editor styles<br/>CSS<br/>[styles.css]"]
end

subgraph group_domain["Framing domain"]
  node_types["Shared project types<br/>TypeScript domain<br/>[types.ts]"]
  node_project["Project lifecycle<br/>domain logic<br/>[project.ts]"]
  node_presets["Frame-size presets<br/>dimension catalog<br/>[presets.ts]"]
  node_geometry{{"Framing geometry<br/>calculation core<br/>[geometry.ts]"}}
end

subgraph group_local["Local I/O"]
  node_storage[("Browser persistence<br/>IndexedDB adapter<br/>[storage.ts]")]
  node_indexeddb[("IndexedDB site data<br/>browser storage")]
  node_export["PNG snapshot export<br/>Canvas exporter<br/>[exportSnapshot.ts]"]
end

subgraph group_delivery["Build &amp; verification"]
  node_package["Scripts &amp; dependencies<br/>package manifest<br/>[package.json]"]
  node_vite["Vite build config<br/>build configuration<br/>[vite.config.ts]"]
  node_tsconfig["TypeScript config<br/>compiler configuration<br/>[tsconfig.json]"]
  node_geometry_tests["Geometry tests<br/>automated tests<br/>[geometry.test.ts]"]
  node_dist["Static dist assets<br/>production artifact"]
end

node_html -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_app -->|"uses"| node_styles
node_app -->|"uses state types"| node_types
node_app -->|"creates and updates projects"| node_project
node_app -->|"selects frame sizes"| node_presets
node_app -->|"derives live preview"| node_geometry
node_project -->|"constructs"| node_types
node_project -->|"applies orientation"| node_presets
node_geometry -->|"consumes dimensions"| node_types
node_app -->|"loads and saves"| node_storage
node_storage -->|"reads and writes"| node_indexeddb
node_app -->|"exports snapshot"| node_export
node_export -->|"uses derived measurements"| node_geometry
node_export -->|"uses image placement"| node_types
node_geometry_tests -->|"validates"| node_geometry
node_package -->|"runs build"| node_vite
node_package -->|"runs type check"| node_tsconfig
node_vite -->|"produces"| node_dist
node_main -.->|"bundled into"| node_dist

click node_html "https://github.com/stevenmorano/print-frame-visualizer/blob/main/index.html"
click node_main "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/main.tsx"
click node_app "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/App.tsx"
click node_styles "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/styles.css"
click node_types "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/types.ts"
click node_project "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/project.ts"
click node_presets "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/presets.ts"
click node_geometry "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/geometry.ts"
click node_storage "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/storage.ts"
click node_export "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/exportSnapshot.ts"
click node_package "https://github.com/stevenmorano/print-frame-visualizer/blob/main/package.json"
click node_vite "https://github.com/stevenmorano/print-frame-visualizer/blob/main/vite.config.ts"
click node_tsconfig "https://github.com/stevenmorano/print-frame-visualizer/blob/main/tsconfig.json"
click node_geometry_tests "https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/geometry.test.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_html,node_main,node_app,node_styles toneBlue
class node_types,node_project,node_presets,node_geometry toneAmber
class node_storage,node_indexeddb,node_export toneMint
class node_package,node_vite,node_tsconfig,node_geometry_tests,node_dist toneRose
```

## Components

### Browser application

- [Vite HTML root](https://github.com/stevenmorano/print-frame-visualizer/blob/main/index.html): entry document · `index.html`
- [React mount](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/main.tsx): browser entry · `src/main.tsx`
- [Editor orchestration](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/App.tsx): React UI · Coordinates controls, project actions, preview state, persistence, and export. · `src/App.tsx`
- [Editor styles](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/styles.css): CSS · `src/styles.css`

### Framing domain

- [Shared project types](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/types.ts): TypeScript domain · `src/types.ts`
- [Project lifecycle](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/project.ts): domain logic · Creates, duplicates, normalizes, and orients projects. · `src/project.ts`
- [Frame-size presets](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/presets.ts): dimension catalog · `src/presets.ts`
- [Framing geometry](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/geometry.ts): calculation core · Derives cavity, mat, visible art, orientation, and fit warnings. · `src/geometry.ts`

### Local I/O

- [Browser persistence](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/storage.ts): IndexedDB adapter · Stores projects, custom presets, and uploaded image data locally. · `src/storage.ts`
- **IndexedDB site data**: browser storage · Clearing browser site data loses local projects and images.
- [PNG snapshot export](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/exportSnapshot.ts): Canvas exporter · Generates annotated high-resolution PNGs from geometry and image placement. · `src/exportSnapshot.ts`

### Build & verification

- [Scripts & dependencies](https://github.com/stevenmorano/print-frame-visualizer/blob/main/package.json): package manifest · `package.json`
- [Vite build config](https://github.com/stevenmorano/print-frame-visualizer/blob/main/vite.config.ts): build configuration · `vite.config.ts`
- [TypeScript config](https://github.com/stevenmorano/print-frame-visualizer/blob/main/tsconfig.json): compiler configuration · `tsconfig.json`
- [Geometry tests](https://github.com/stevenmorano/print-frame-visualizer/blob/main/src/geometry.test.ts): automated tests · Core automated coverage for framing calculations. · `src/geometry.test.ts`
- **Static dist assets**: production artifact · Static browser-delivered output with no backend.

## Connections

- 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
