How guthza/minesweeper works
Project type and purpose
• This is a frontend-only React application, bootstrapped with Create React App.
• From the file names (cell, game-panel, mines, timer, game-over-modal), it implements a Minesweeper-style game in the browser.
• There is no separate backend or API service; all game logic lives in the client.
File structure
• Top level:
• public/ – static assets and HTML shell (index.html, manifest.json, robots.txt)
• src/ – React source code
• package.json / package-lock.json – dependencies and scripts
• src/ contains:
• App.js & index.js – entry points
• components/ – presentational and container components (header, footer, control-panel, game-panel, cell, timer, game-over-modal)
• assets/styles/ – CSS files
• constants/ – global constants (e.g. board dimensions)
• helpers/ – pure functions for board generation, mine placement, shuffling
• tests/ – unit tests
README
• Confirms use of Create React App.
• Standard build, start, test, eject scripts.
• No extra architectural notes (no backend, no microservices).
Main components and interactions
a. Components:
• Browser & Webpack Dev Server (dev mode) / Static Server (prod)
• index.html → root element
• React runtime (bundler output)
• App component (top-level container)
• UI components: Header, ControlPanel (start/reset), GamePanel (grid container), Cell (individual cell), Timer, GameOverModal, Footer
• Business logic modules: boardsize.js, mines.js, shuffle.js
• State management: React useState/useEffect hooks in App / GamePanel
• Styles: CSS files under src/assets/styles and per-component .css
b. Data flow:
1. User opens browser → server serves index.html
2. index.js bootstraps React → renders <App />
3. <App /> initializes state (via helpers: build board, shuffle mines, constants)
4. <GamePanel> renders grid of <Cell> with props (value, status)
5. User clicks a cell → Cell.onClick → event handler in GamePanel/App updates state
6. State change triggers re-render; if game over, <GameOverModal> appears
7. Timer runs via useEffect in Timer component
c. Architectural patterns / principles:
• Component-based UI (React)
• Separation of concerns: helpers for pure logic, components for rendering & event handling, constants for config
• Single-page application: client-side routing (none here), no server round-trips
d. Key technologies:
• React (JSX, hooks)
• Create React App (Webpack, Babel)
• CSS modules / plain CSS
• Jest & React Testing Library for tests