# shereali/floor-plan architecture

> Architecture diagram of the GitHub repository shereali/floor-plan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shereali/floor-plan
- Repository: https://github.com/shereali/floor-plan

## Overview

#### Purpose and Entry Points
This is a Nuxt/Vue floor-plan and booth-layout editor. The main editor route is `app/pages/index.vue`; a presentation/export-oriented route is `app/pages/preview.vue`. Application shell and route layouts are rooted at `app/app.vue`, `app/layouts/default.vue`, and `app/layouts/blank.vue`.

#### Editor Composition
`app/components/Whiteboard.vue` is the interactive canvas host, surrounded by tool and editing UI: `app/components/Toolbar.vue`, `app/components/Sidebar.vue`, and `app/components/RightSidebar.vue`. `app/components/WhiteboardPreview.vue` renders the non-editor preview surface. Booth-specific interaction is split into visible items and dialogs in `app/components/BoothItem.vue` and `app/components/BoothModal.vue`.

#### Canvas Engine Boundary
The canvas engine coordinates initialization, state, DOM/canvas events, rendering, panning, and selection through `app/composables/engine/useCanvasSetup.ts`, `app/composables/engine/useCanvasEvents.ts`, and `app/composables/useCanvasEngine.ts`. This separates imperative canvas interaction from Vue panels and route components. Rendering and interaction are performance-sensitive, with dedicated engine rendering and throttling paths in `app/composables/engine/useCanvasRendering.ts` and `app/composables/useThrottledRendering.ts`.

#### Drawing and Object Model
Drawing modes are implemented as specialized composables for lines, shapes, pencils, walls, and curve arrows, including `app/composables/engine/drawing/useShapeDrawing.ts`, `app/composables/engine/drawing/useWallDrawing.ts`, and `app/composables/engine/drawing/usePencilDrawing.ts`. Object-type handlers cover booths, images, text, geometric shapes, arrows, and walls under `app/composables/canvas/useCanvasBooth.ts`, `app/composables/canvas/useCanvasImage.ts`, and `app/composables/canvas/useCanvasWall.ts`. Shared canvas object contracts reside in `app/types/canvas.ts`.

#### State, Selection, and Manipulation
Global editor/UI state is held in Pinia-style stores: `app/stores/canvasStore.ts`, `app/stores/uiStore.ts`, and `app/stores/assetsStore.ts`. Selection, object transforms, keyboard movement, flip behavior, and optimized dragging are separated from drawing logic in `app/composables/useSelectionManager.ts`, `app/composables/useObjectManipulation.ts`, and `app/composables/useOptimizedDragging.ts`. Properties panels consume selected-object state to edit common and type-specific fields via `app/components/properties/PropertiesPanel.vue` and `app/components/properties/ShapePropertiesPanel.vue`.

#### Alignment, Layers, and Visual Feedback
The editor provides layers, snapping/alignment, guide overlays, hover measurement, and level-of-detail support. Key boundaries are `app/components/LayersPanel.vue`, `app/composables/useObjectAlignment.ts`, `app/components/AlignmentGuidesOverlay.vue`, and `app/composables/useCanvasLOD.ts`. These features operate over canvas objects rather than owning the primary persisted floor data.

#### Server APIs and Assets
Nuxt server routes expose floor resources at `server/api/floors/index.ts` and `server/api/floors/[id].ts`; the client API boundary is `app/composables/api/useFloorsApi.ts`. Preview uploads are handled by `server/api/upload-preview.post.ts`. Static design/image assets are served from `public/`, while in-editor asset state is managed by `app/stores/assetsStore.ts`. The runtime is Nuxt with its server API layer; development defaults to port 3000 and supports npm, pnpm, yarn, or Bun.

Main entry points: [`app/composables/useCanvasEngine.ts`](https://github.com/shereali/floor-plan/blob/main/app/composables/useCanvasEngine.ts) (Canvas engine), [`app/pages/index.vue`](https://github.com/shereali/floor-plan/blob/main/app/pages/index.vue) (Editor route), [`app/stores/canvasStore.ts`](https://github.com/shereali/floor-plan/blob/main/app/stores/canvasStore.ts) (Editor state), [`app/pages/preview.vue`](https://github.com/shereali/floor-plan/blob/main/app/pages/preview.vue) (Preview route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Nuxt App"]
  node_app_shell["Application shell<br/>Nuxt root<br/>[app.vue]"]
  node_editor_route["Editor route<br/>Nuxt page<br/>[index.vue]"]
  node_preview_route["Preview route<br/>Nuxt page<br/>[preview.vue]"]
end

subgraph group_editor["Editor"]
  node_editor_ui["Editor panels<br/>Vue components<br/>[Toolbar.vue]"]
  node_whiteboard["Interactive whiteboard<br/>canvas host<br/>[Whiteboard.vue]"]
  node_preview_surface["Preview surface<br/>Vue component"]
  node_booth_ui["Booth interaction<br/>Vue components<br/>[BoothItem.vue]"]
  node_properties["Properties panels<br/>Vue components"]
end

subgraph group_canvas["Canvas Engine"]
  node_canvas_engine{{"Canvas engine<br/>composable facade<br/>[useCanvasEngine.ts]"}}
  node_canvas_setup_events["Setup &amp; events<br/>engine composables<br/>[useCanvasSetup.ts]"]
  node_rendering["Rendering pipeline<br/>engine composables"]
  node_drawing["Drawing modes<br/>drawing composables<br/>[useShapeDrawing.ts]"]
  node_object_handlers["Canvas object handlers<br/>canvas composables<br/>[useCanvasBooth.ts]"]
  node_canvas_types["Canvas contracts<br/>TypeScript types<br/>[canvas.ts]"]
end

subgraph group_state["State &amp; Editing"]
  node_editor_state[("Editor state<br/>Pinia stores<br/>[canvasStore.ts]")]
  node_selection_manipulation["Selection &amp; transforms<br/>editing composables"]
  node_alignment_layers["Alignment &amp; layers<br/>editor features<br/>[LayersPanel.vue]"]
end

subgraph group_server["Server &amp; Assets"]
  node_floors_client["Floors client API<br/>API composable<br/>[useFloorsApi.ts]"]
  node_floors_api{{"Floors API<br/>Nuxt server route<br/>[index.ts]"}}
  node_floor_api{{"Floor resource API<br/>Nuxt server route<br/>[&#91;id&#93;.ts]"}}
  node_preview_upload{{"Preview upload API<br/>Nuxt server route"}}
  node_public_assets["Static assets<br/>public files"]
end

node_app_shell -->|"hosts"| node_editor_route
node_app_shell -->|"hosts"| node_preview_route
node_editor_route -->|"composes"| node_editor_ui
node_editor_route -->|"mounts"| node_whiteboard
node_preview_route -->|"renders"| node_preview_surface
node_whiteboard -->|"uses"| node_canvas_engine
node_canvas_engine -->|"coordinates"| node_canvas_setup_events
node_canvas_engine -->|"renders through"| node_rendering
node_canvas_engine -->|"activates"| node_drawing
node_drawing -->|"creates objects with"| node_object_handlers
node_object_handlers -->|"uses"| node_canvas_types
node_canvas_engine -->|"reads and updates"| node_editor_state
node_editor_ui -->|"controls"| node_editor_state
node_properties -->|"edits selection"| node_selection_manipulation
node_selection_manipulation -->|"updates"| node_editor_state
node_alignment_layers -->|"overlays and aligns"| node_canvas_engine
node_booth_ui -->|"edits booths"| node_object_handlers
node_editor_route -->|"loads and saves floors"| node_floors_client
node_floors_client -->|"requests collection"| node_floors_api
node_floors_client -->|"requests floor"| node_floor_api
node_preview_route -->|"uploads preview"| node_preview_upload
node_editor_state -.->|"uses design assets"| node_public_assets

click node_app_shell "https://github.com/shereali/floor-plan/blob/main/app/app.vue"
click node_editor_route "https://github.com/shereali/floor-plan/blob/main/app/pages/index.vue"
click node_preview_route "https://github.com/shereali/floor-plan/blob/main/app/pages/preview.vue"
click node_editor_ui "https://github.com/shereali/floor-plan/blob/main/app/components/Toolbar.vue"
click node_whiteboard "https://github.com/shereali/floor-plan/blob/main/app/components/Whiteboard.vue"
click node_preview_surface "https://github.com/shereali/floor-plan/blob/main/app/components/WhiteboardPreview.vue"
click node_booth_ui "https://github.com/shereali/floor-plan/blob/main/app/components/BoothItem.vue"
click node_properties "https://github.com/shereali/floor-plan/blob/main/app/components/properties/PropertiesPanel.vue"
click node_canvas_engine "https://github.com/shereali/floor-plan/blob/main/app/composables/useCanvasEngine.ts"
click node_canvas_setup_events "https://github.com/shereali/floor-plan/blob/main/app/composables/engine/useCanvasSetup.ts"
click node_rendering "https://github.com/shereali/floor-plan/blob/main/app/composables/engine/useCanvasRendering.ts"
click node_drawing "https://github.com/shereali/floor-plan/blob/main/app/composables/engine/drawing/useShapeDrawing.ts"
click node_object_handlers "https://github.com/shereali/floor-plan/blob/main/app/composables/canvas/useCanvasBooth.ts"
click node_canvas_types "https://github.com/shereali/floor-plan/blob/main/app/types/canvas.ts"
click node_editor_state "https://github.com/shereali/floor-plan/blob/main/app/stores/canvasStore.ts"
click node_selection_manipulation "https://github.com/shereali/floor-plan/blob/main/app/composables/useSelectionManager.ts"
click node_alignment_layers "https://github.com/shereali/floor-plan/blob/main/app/components/LayersPanel.vue"
click node_floors_client "https://github.com/shereali/floor-plan/blob/main/app/composables/api/useFloorsApi.ts"
click node_floors_api "https://github.com/shereali/floor-plan/blob/main/server/api/floors/index.ts"
click node_floor_api "https://github.com/shereali/floor-plan/blob/main/server/api/floors/%5Bid%5D.ts"
click node_preview_upload "https://github.com/shereali/floor-plan/blob/main/server/api/upload-preview.post.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_app_shell,node_editor_route,node_preview_route toneBlue
class node_editor_ui,node_whiteboard,node_preview_surface,node_booth_ui,node_properties toneAmber
class node_canvas_engine,node_canvas_setup_events,node_rendering,node_drawing,node_object_handlers,node_canvas_types toneMint
class node_editor_state,node_selection_manipulation,node_alignment_layers toneRose
class node_floors_client,node_floors_api,node_floor_api,node_preview_upload,node_public_assets toneIndigo
```

## Components

### Nuxt App

- [Application shell](https://github.com/shereali/floor-plan/blob/main/app/app.vue): Nuxt root · `app/app.vue`
- [Editor route](https://github.com/shereali/floor-plan/blob/main/app/pages/index.vue): Nuxt page · `app/pages/index.vue`
- [Preview route](https://github.com/shereali/floor-plan/blob/main/app/pages/preview.vue): Nuxt page · `app/pages/preview.vue`

### Editor

- [Editor panels](https://github.com/shereali/floor-plan/blob/main/app/components/Toolbar.vue): Vue components · Toolbar and sidebars drive editor controls. · `app/components/Toolbar.vue`
- [Interactive whiteboard](https://github.com/shereali/floor-plan/blob/main/app/components/Whiteboard.vue): canvas host · `app/components/Whiteboard.vue`
- [Preview surface](https://github.com/shereali/floor-plan/blob/main/app/components/WhiteboardPreview.vue): Vue component · `app/components/WhiteboardPreview.vue`
- [Booth interaction](https://github.com/shereali/floor-plan/blob/main/app/components/BoothItem.vue): Vue components · Visible booth items and editing dialog. · `app/components/BoothItem.vue`
- [Properties panels](https://github.com/shereali/floor-plan/blob/main/app/components/properties/PropertiesPanel.vue): Vue components · Edits common and shape-specific selected-object fields. · `app/components/properties/PropertiesPanel.vue`

### Canvas Engine

- [Canvas engine](https://github.com/shereali/floor-plan/blob/main/app/composables/useCanvasEngine.ts): composable facade · Coordinates imperative canvas lifecycle and interaction. · `app/composables/useCanvasEngine.ts`
- [Setup & events](https://github.com/shereali/floor-plan/blob/main/app/composables/engine/useCanvasSetup.ts): engine composables · Initializes canvas and handles DOM/canvas input. · `app/composables/engine/useCanvasSetup.ts`
- [Rendering pipeline](https://github.com/shereali/floor-plan/blob/main/app/composables/engine/useCanvasRendering.ts): engine composables · Performance-sensitive rendering and throttling. · `app/composables/engine/useCanvasRendering.ts`
- [Drawing modes](https://github.com/shereali/floor-plan/blob/main/app/composables/engine/drawing/useShapeDrawing.ts): drawing composables · Shapes, walls, pencils, and curve arrows. · `app/composables/engine/drawing/useShapeDrawing.ts`
- [Canvas object handlers](https://github.com/shereali/floor-plan/blob/main/app/composables/canvas/useCanvasBooth.ts): canvas composables · Creates and updates booths, images, and walls. · `app/composables/canvas/useCanvasBooth.ts`
- [Canvas contracts](https://github.com/shereali/floor-plan/blob/main/app/types/canvas.ts): TypeScript types · `app/types/canvas.ts`

### State & Editing

- [Editor state](https://github.com/shereali/floor-plan/blob/main/app/stores/canvasStore.ts): Pinia stores · Canvas, UI, and in-editor asset state. · `app/stores/canvasStore.ts`
- [Selection & transforms](https://github.com/shereali/floor-plan/blob/main/app/composables/useSelectionManager.ts): editing composables · Selection, keyboard movement, transforms, and optimized dragging. · `app/composables/useSelectionManager.ts`
- [Alignment & layers](https://github.com/shereali/floor-plan/blob/main/app/components/LayersPanel.vue): editor features · Layers, snapping, guides, measurement, and LOD. · `app/components/LayersPanel.vue`

### Server & Assets

- [Floors client API](https://github.com/shereali/floor-plan/blob/main/app/composables/api/useFloorsApi.ts): API composable · `app/composables/api/useFloorsApi.ts`
- [Floors API](https://github.com/shereali/floor-plan/blob/main/server/api/floors/index.ts): Nuxt server route · Creates and lists floor resources. · `server/api/floors/index.ts`
- [Floor resource API](https://github.com/shereali/floor-plan/blob/main/server/api/floors/%5Bid%5D.ts): Nuxt server route · Handles an individual floor by ID. · `server/api/floors/[id].ts`
- [Preview upload API](https://github.com/shereali/floor-plan/blob/main/server/api/upload-preview.post.ts): Nuxt server route · `server/api/upload-preview.post.ts`
- **Static assets**: public files · Design and image assets served by Nuxt.

## Connections

- Application shell → Editor route: hosts
- Application shell → Preview route: hosts
- Editor route → Editor panels: composes
- Editor route → Interactive whiteboard: mounts
- Preview route → Preview surface: renders
- Interactive whiteboard → Canvas engine: uses
- Canvas engine → Setup & events: coordinates
- Canvas engine → Rendering pipeline: renders through
- Canvas engine → Drawing modes: activates
- Drawing modes → Canvas object handlers: creates objects with
- Canvas object handlers → Canvas contracts: uses
- Canvas engine → Editor state: reads and updates
- Editor panels → Editor state: controls
- Properties panels → Selection & transforms: edits selection
- Selection & transforms → Editor state: updates
- Alignment & layers → Canvas engine: overlays and aligns
- Booth interaction → Canvas object handlers: edits booths
- Editor route → Floors client API: loads and saves floors
- Floors client API → Floors API: requests collection
- Floors client API → Floor resource API: requests floor
- Preview route → Preview upload API: uploads preview
- Editor state → Static assets: uses design assets
