How o0phoenix0o/algorithm-visualizer works
Project type and purpose
• This is a single‐page, front-end web application (“Algorithm Visualizer”) built with plain HTML5, CSS3, and ES6+ JavaScript.
• Its goal is to let users select, step through, and visually explore classic algorithms (sorting, searching, graphs, trees) via animated canvas renderings and real-time logging.
File structure
• Top-level:
• index.html – the entry point and UI scaffold
• Algorithms/ – pure algorithm implementations organized by category (Sorting, Searching, Graphs, Trees, Base)
• Core/ – rendering engine (canvas.js), logging (logger.js), controller glue (script.js), and drawing helpers (sketch.js)
• Data/ – algorithm metadata and configuration (algoData.js & JSON)
• Styles/ – UI styling (style.css) and logger styling (logger.css)
• Patterns: modules are strictly separated by concern—algorithm logic vs. rendering vs. UI vs. data. No backend or database: all runs in the browser.
Inspect README for technical details
• Tech stack: HTML5, CSS3, JavaScript (ES6+), Canvas API
• Highlights: interactive UI, step-by-step execution, adjustable speed, modular codebase
a. Main components
• Browser / Host Environment
• UI Layer (index.html + Styles)
• Controller Layer (script.js): manages user events, orchestrates the flow
• Core Services:
– Canvas Renderer (canvas.js + sketch.js)
– Logger Service (logger.js)
• Algorithm Modules (Algorithms/…): sorting, searching, graph, tree engines
• Data Store (algoData.json & algoData.js)
• (Optional) Assets folder if images/SVGs are used
b. Relationships & interactions
1. User clicks/selects algorithm in UI → Controller receives event
2. Controller loads algorithm metadata from Data Store
3. Controller invokes chosen Algorithm Module’s API to generate steps
4. For each algorithm step:
– Controller calls Logger Service to append step info
– Controller listens for playback controls (play/pause/next/prev)
5. UI updates controls and displays code & explanation panels
c. Architectural patterns & principles
• Modular separation of concerns (UI vs. control vs. rendering vs. algorithm logic vs. data)
• Single-page application (SPA) pattern, no server back-end
• Data-driven configuration (algoData.json) for extensibility
d. Key technologies
• HTML5 elements for layout and controls
• CSS3 for styling and theming
• JavaScript ES6 modules for each directory
• Canvas API (2D) for dynamic drawing
• Logger uses DOM manipulation for real-time feedback