How andrewagain/calculator works
Project type and purpose
• This is a single-page web application built with React (created via create-react-app).
• Its sole purpose is to provide a client-side calculator UI and perform arithmetic operations in the browser.
File structure
Top-level:
• package.json / package-lock.json – build scripts, dependencies, start/test commands
• public/ – static assets served as-is (index.html, manifest.json)
• src/
– component/ – React presentation components (App, Display, ButtonPanel, Button)
– logic/ – pure JS modules implementing calculator behavior (calculate, operate, isNumber)
– index.js, index.css – entry point and global styles
README
• Confirms it’s a create-react-app project, published to GitHub Pages.
• No backend or external API dependencies—pure front-end code.
a. Main components to show
• Browser (user agent)
• Static server / CDN (serving public assets and bundled app)
• React application
– Component layer (App → Display, ButtonPanel → Button)
– Logic layer (calculate.js, operate.js, isNumber.js)
• Build tools (Webpack under the hood via react-scripts)
b. Relationships & interactions
• User clicks Button → ButtonPanel handler → calls calculate()
• calculate() orchestrates calls to isNumber() or operate()
• Result returned to App state → Display updates
• index.js mounts App into root div in public/index.html
• package.json scripts drive build, start, and deploy
c. Architectural patterns & principles
• Component-Based Architecture: UI split into reusable, stateless and stateful React components
• Separation of Concerns: view logic (component/) vs. business logic (logic/)
• Single Source of Truth: App holds calculator state, passed down via props
• Modular code: pure functions for arithmetic operations for easy testing
d. Key technologies & frameworks
• React.js (with Hooks or class components)
• JavaScript ES6 modules
• CSS modules or plain CSS for styling
• create-react-app (Webpack, Babel, react-scripts)
• Jest & React Testing Library for tests