How hundredrabbits/dotgrid works
Project type and purpose
• Dotgrid is a single-page, front-end web application (no separate backend).
• Its purpose is to provide a grid-based vector drawing environment in the browser, supporting SVG, PNG export, multiple layers, mirroring, radial drawing, and a variety of drawing tools.
File structure
• Top-level:
• index.html – the single entry point
• links/*.css – styling (main.css, theme.css)
• scripts/ – all application logic
• scripts/ is divided into:
• core modules (manager.js, renderer.js, tool.js, picker.js, interface.js, generator.js, cursor.js, client.js)
• lib/ – shared utilities (acels.js, build.js, history.js, source.js, theme.js)
• push.sh, LICENSEs, README.txt: deployment and documentation—but no server-side code.
README for additional insights
• Confirms front-end only, open-source under MIT.
• Describes features (layers, SVG spec, effects) but no mention of a backend or external APIs other than file download.
Main components
a. Browser / Frontend Container
b. User Interface Layer
• HTML (index.html)
• CSS themes (links/main.css, links/theme.css)
c. Input & Event Handling
• scripts/client.js (keyboard/mouse event capture)
• scripts/lib/acels.js (keyboard accelerators)
d. Tool Management
• scripts/tool.js (tool selection, stroke modes)
• scripts/cursor.js (cursor updates)
e. Application State & History
• scripts/manager.js (document state, layers, grid)
• scripts/lib/history.js (undo/redo stack)
f. Rendering Engine
• scripts/generator.js (generate radial/mirror effects)
g. Export Module
• scripts/lib/source.js (assemble SVG source)
• scripts/client.js or build.js (trigger PNG export, download)
h. Theming & Configuration
• scripts/lib/theme.js (load/reset theme)
i. Build & Deployment (optional)
• scripts/lib/build.js
• push.sh (deployment script)
Relationships & data flows
• User → UI Layer → Input Handler → Tool Manager → App State
• App State → Rendering Engine → Canvas Display
• App State → History Module (undo/redo)
• App State → Export Module → File Download (SVG/PNG)
• Theme Module ↔ UI Layer
Architectural patterns & design principles
• Modular, client-side MVC style:
• “Controller” → client.js + tool.js
• “Model” → manager.js + history.js
• “View” → renderer.js + generator.js
• Event-driven: input events drive state changes and re-render.
• Separation of concerns:
• lib/ for reusable utilities
• core scripts for domain logic
Essential elements to capture
• All scripts in their logical groups (interface, tool, manager, renderer, lib)
• The CSS/theme subsystem and index.html as entry point
• Data flow from user events through state to rendering and export
• Undo/redo and theming as cross-cutting concerns