How moses-beniyel/sorting-visualizer works
Project Type & Purpose
• Type: Full-front-end React single-page application (no custom backend).
File Structure & README Insights
• Top-level:
• public/ – static index.html, manifest, robots.txt
• src/ – React components, styles, assets, context provider, test files
• package.json/package-lock.json – Node.js dependencies & scripts
• Key components in src/:
• App.js – root component
• contextProvider.jsx – React Context for global state (array size, speed, current algorithm, array data)
• algorithm modules – bubbleSort/, mergeSort/, insertionSort/, selectionSort/
• codeSnippet/ – displays pseudo-code or source code
• complexity/ – displays time/space complexity info
• navbar.js – UI header & controls
• assets/ – audio file for swap sound
• README notes: built with React.js, CSS animations, deployed live (e.g., Vercel).
Main Components & Responsibilities
A. Browser / Hosting Layer
• Static files served (public/index.html, CSS, JS bundles)
• Deployed via Vercel or any static-hosting service
B. React Application
1. Root & Layout
• App.js: sets up layout, imports ContextProvider
• Navbar: controls for array size, speed, regenerate button
2. State Management
• ContextProvider: holds global state & dispatch actions
3. Visualization Panel
• Algorithm components: each sorting folder implements the sorting logic & CSS animations
• Assets: swap.wav triggered on element swaps
4. Info Panels
• CodeSnippet: shows current algorithm code
• Complexity: displays theoretical complexity
5. Interactions & Data Flow
• User → Navbar controls → Context state update → triggers algorithm run → visualization update → CSS animations & sound
C. Build & Dev Pipeline
• Node.js + npm scripts (npm start, npm build)
• Webpack/Babel (via Create-React-App) bundling, hot reload in dev
• package.json lists dependencies (react, react-dom, etc.)
Relationships & Data Flows
• User actions → ContextProvider dispatch
• Context state → Algorithm modules (input array, speed)
• Algorithm modules → Visualization Panel updates (React re-render)
• Visualization → CSS animations & swap.wav playback
• Selection in Navbar → triggers CodeSnippet & Complexity Panel updates
• Static asset access: public/index.html → loads main JS/CSS bundles
Architectural Patterns & Principles
• Component-based UI (React)
• Unidirectional data flow (Context API, reducer pattern)
• Separation of concerns:
• Presentation (CSS, animations)
• Logic (sorting algorithms)
• State (ContextProvider)
• Single-page app: all routing (if any) handled client-side
Must-Include Elements
• Clear labels on all components/containers
• Static Hosting Layer
• React App & its sub-components
• Build/Dev Tools