How shereali/floor-plan works
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: useCanvasEngine.ts Canvas engine · index.vue Editor route · canvasStore.ts Editor state · preview.vue Preview route
Components 22
Nuxt App
- Application shell
app/app.vue - Editor route
app/pages/index.vue - Preview route
app/pages/preview.vue
Editor
- Editor panels · Toolbar and sidebars drive editor controls.
app/components/Toolbar.vue - Interactive whiteboard
app/components/Whiteboard.vue - Preview surface
app/components/WhiteboardPreview.vue - Booth interaction · Visible booth items and editing dialog.
app/components/BoothItem.vue - Properties panels · Edits common and shape-specific selected-object fields.
app/components/properties/PropertiesPanel.vue
Canvas Engine
- Canvas engine · Coordinates imperative canvas lifecycle and interaction.
app/composables/useCanvasEngine.ts - Setup & events · Initializes canvas and handles DOM/canvas input.
app/composables/engine/useCanvasSetup.ts - Rendering pipeline · Performance-sensitive rendering and throttling.
app/composables/engine/useCanvasRendering.ts - Drawing modes · Shapes, walls, pencils, and curve arrows.
app/composables/engine/drawing/useShapeDrawing.ts - Canvas object handlers · Creates and updates booths, images, and walls.
app/composables/canvas/useCanvasBooth.ts - Canvas contracts
app/types/canvas.ts
State & Editing
- Editor state · Canvas, UI, and in-editor asset state.
app/stores/canvasStore.ts - Selection & transforms · Selection, keyboard movement, transforms, and optimized dragging.
app/composables/useSelectionManager.ts - Alignment & layers · Layers, snapping, guides, measurement, and LOD.
app/components/LayersPanel.vue
Server & Assets
- Floors client API
app/composables/api/useFloorsApi.ts - Floors API · Creates and lists floor resources.
server/api/floors/index.ts - Floor resource API · Handles an individual floor by ID.
server/api/floors/[id].ts - Preview upload API
server/api/upload-preview.post.ts - Static assets · Design and image assets served by Nuxt.
Connections 22
- 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