How saadmansakib47/electronics-calculator works
Purpose and Entry Points
Calculator Suite is a multi-page, static browser application with three calculator modes: basic, advanced, and electronics-specific. index.html is the landing/navigation page; basic.html, advanced.html, and custom.html host the respective calculator UIs. Local serving starts at port 8080 via the npm start script defined in package.json.
Presentation and Page Boundaries
Each calculator is a separate HTML page rather than a single routed application. Shared visual styling is centralized in styles.css; each page loads its dedicated controller/calculation module.
• basic.html
• advanced.html
• custom.html
• styles.css
Basic Calculator Stage
The basic calculator implements the repaired core arithmetic behavior and is independently consumable in both browser and Node test contexts. Its script owns basic-operation state/interaction logic for basic.html, while CommonJS export guards permit Jest to import the same implementation.
• Scripts/basic.js
• basic.html
• Tests/basic.test.js
Advanced Calculator Stage
The advanced calculator extends the core calculator offering with advanced operations while retaining the dual-runtime model: browser globals for page execution and Node exports for automated tests. Its page and test suite form an isolated feature boundary.
• Scripts/advanced.js
• advanced.html
• Tests/advanced.test.js
Electronics Calculator Domain
The custom calculator is an electronics-domain calculator rather than generic arithmetic. Scripts/custom.js translates UI input into formula-based results defined by the project’s electronics reference. Input validation is shared through requireAtLeastOne, reducing duplicated validation behavior and establishing utils.js as a common domain-support dependency.
• Scripts/custom.js
• Scripts/utils.js
• ELECTRONICS_CALCULATOR.md
Test and Execution Flow
Browser users load an HTML page, interact with DOM controls, and invoke the corresponding script’s calculator behavior. Tests import those same scripts under Node/Jest, exercising calculation and integration behavior without a separate backend or API layer. Reusable test construction is centralized to keep calculator suites consistent.
• Tests/basic.test.js
• Tests/advanced.test.js
• Tests/custom.test.js
• Tests/testHelpers.js
Runtime, Automation, and Infrastructure
The repository has no server-side application, database, or external service dependency indicated; it is served locally as static web content and tested in the Node/npm ecosystem. GitHub Actions runs the Node CI workflow, making automated test execution the primary delivery gate.
• package.json
• .github/workflows/node.yml
• package-lock.json
Main entry points: custom.js Electronics calculator · index.html Landing page · basic.html Basic calculator page · advanced.html Advanced calculator page
Components 16
Static Pages
Independent browser entry points.
- Landing page · Navigation entry point for calculator modes.
index.html - Basic calculator page
basic.html - Advanced calculator page
advanced.html - Electronics calculator page
custom.html - Shared styles
styles.css
Calculator Modules
Browser controllers also exported for Node tests.
- Basic calculator · Core arithmetic state, interaction, and calculation behavior.
Scripts/basic.js - Advanced calculator · Advanced operations and page behavior.
Scripts/advanced.js - Electronics calculator · Maps UI inputs to electronics formula results.
Scripts/custom.js - Validation utility · Provides requireAtLeastOne input validation.
Scripts/utils.js - Electronics reference · Defines the electronics formulas and behavior.
ELECTRONICS_CALCULATOR.md
Test & CI
Node/Jest verification and delivery gate.
- Basic tests
Tests/basic.test.js - Advanced tests
Tests/advanced.test.js - Electronics tests
Tests/custom.test.js - Test helpers · Reusable test construction shared by calculator suites.
Tests/testHelpers.js - Node CI · Runs automated Node tests as the delivery gate.
.github/workflows/node.yml
Other components
- npm scripts · Starts local static serving and test tooling.
package.json
Connections 18
- Landing page → Basic calculator page: navigates to
- Landing page → Advanced calculator page: navigates to
- Landing page → Electronics calculator page: navigates to
- Basic calculator page → Shared styles: loads
- Advanced calculator page → Shared styles: loads
- Electronics calculator page → Shared styles: loads
- Basic calculator page → Basic calculator: loads
- Advanced calculator page → Advanced calculator: loads
- Electronics calculator page → Electronics calculator: loads
- Electronics calculator → Validation utility: validates with
- Electronics calculator → Electronics reference: implements formulas from
- Basic tests → Basic calculator: imports
- Advanced tests → Advanced calculator: imports
- Electronics tests → Electronics calculator: tests
- Basic tests → Test helpers: uses
- Advanced tests → Test helpers: uses
- Electronics tests → Test helpers: uses
- Node CI → npm scripts: runs test script