Sequence Diagrams
Use Case 1: Starting a Session and Drawing UI Sketches
As a user, I want to start sketching UI components for my website
- User navigates to the Sketch2Screen application URL
- Frontend generates unique session ID and creates initial page
- User sees Excalidraw canvas interface with drawing tools
- User draws UI components (buttons, forms, navigation, etc.) on canvas
- Frontend tracks all drawing changes in local state
Use Case 2: Generating HTML from Sketches with AI
As a user, I want to convert my sketches into production-ready HTML using Claude AI
- User clicks "Generate" button in navbar
- Frontend shows loading indicator
- Frontend checks which pages have changed since last generation (smart caching)
- For each changed page, frontend exports canvas to PNG via Excalidraw API
- Frontend sends multipart/form-data to
/api/generate-multi/with all page images - Backend processes each image in parallel using asyncio
- Backend converts PNG to base64 and sends to Claude API
- Claude analyzes sketch and returns raw HTML with Tailwind CSS
- Frontend receives HTML for each page and displays in sanitized iframe
- Frontend caches scene state to avoid regenerating unchanged pages next time
Use Case 3: Managing Multiple Sketch Pages
As a user, I want to create multiple pages for a multi-page website design
- User clicks "Add Page" button in sidebar
- Frontend creates new page and switches to it
- User can rename pages by double-clicking page name
- User can duplicate pages to reuse design
- User can delete pages (minimum 1 page required)
- User can switch between pages to work on different screens
Use Case 4: Editing Mockup Styles and Adding Page Links
As a user, I want to customize the generated HTML and link pages together
- User views generated mockup in iframe
- User clicks element inspector to select HTML element
- User modifies CSS styles (colors, sizes, spacing, etc.)
- Frontend tracks style changes in
mockupStylesstate with undo/redo history - User can link elements to other pages via link dialog
- Frontend stores page links in
pageLinksstate mapping elementId to target pageId - Changes are applied immediately in iframe and persisted for export
Use Case 5: Exporting HTML Files
As a user, I want to export my generated mockups as HTML files
- User clicks export option from navbar dropdown
- User chooses export format: single page, multi-page single HTML, or multi-page ZIP
- Frontend reads iframe content and applies all style modifications
- Frontend processes page links to enable navigation between pages
- System generates download with all customizations applied
- User receives HTML file(s) ready to deploy
Use Case 6: Real-time Collaboration
As a collaborator, I want to join an existing session and edit together
- User A clicks "Start Collaboration" and shares link with
?collab={collabID}parameter - User B clicks the link and enters username when prompted
- Frontend connects to WebSocket at
/ws/collab/{collabID}/ - Backend syncs existing pages and collaborators to User B
- Both users can now draw and see each other's changes in real-time
- Collaborator cursors are shown (filtered by active page)