How doonmad/reactplayground works
Project type and purpose
• This is a React SPA scaffolded by Vite, featuring multiple small “project” demos under src/projects/.
• Purpose: demonstrate React components, state management, and HMR using either Babel (plugin-react) or SWC (plugin-react-swc).
File structure
• Top-level files
– index.html: SPA entry point
– package.json / vite.config.js: build & dev-server config; NPM scripts
– eslint.config.js: linting rules
• public/: static assets (favicon, images…) served “as-is”
• src/:
– main.jsx: mounts <App /> into div#root
– App.jsx + App.css: core layout, routing to individual demos
– components/: reusable presentational units (e.g., ProjectCard.jsx)
– projects/[01ViteReact…05LOLScript]: five demo apps, each self-contained with its own index.jsx, optional hooks, subcomponents
Extract additional insights from README
• Emphasizes Vite for fast refresh + HMR
• Optional Babel vs SWC plugin for compilation
• Encouraged TypeScript + type-aware ESLint for production, though this template is plain JS
Main components & boundaries
a. Developer workstation
– IDE / source code
– NPM scripts (npm run dev, npm run build)
b. Build & Dev pipeline
– Vite Dev Server
• Reads vite.config.js, watches src/ + public/
• Applies @vitejs/plugin-react or @vitejs/plugin-react-swc (Babel/SWC transforms, HMR)
– ESLint (pre-commit or editor integration)
c. Source layers
– Public assets served statically
– index.html: root shell (div#root) + script injection
– Module graph under src/:
• main.jsx → App.jsx → child components & demo entrypoints
• components/ & projects/* folders
d. Browser runtime
– Bundled modules delivered via Vite’s module server (ESM)
– React reconciliation & Virtual DOM
– Rendered UI in the DOM
e. Individual project demos (01…05)
– Each is a sub-module:
• e.g. 05LOLScript uses custom hook useGetJoke to fetch data
Interactions & data flow
• On load: Browser requests index.html → Vite injects script tags → modules load
• React bootstraps at #root → App.jsx renders navigation + <ProjectCard> list → clicking a card loads corresponding demo component
• Demo components may fetch data (e.g. jokes) via hooks → update component state → UI refresh
Architectural patterns & principles
• Component-based UI: All UI divided into small, reusable React components
• SPA routing/navigation (implicit in App.jsx)
• Modular demos: each project folder is a pluggable module
• HMR & ESM: Vite leverages native ES modules for lightning-fast hot updates
• Separation of concerns: Static assets vs source code vs config vs build pipeline
Detail level
• Every folder and major file as a node in the “Source Code” zone
• HMR loop: Dev → Vite → Browser → React → back to Dev upon save