An accessible scientific calculator web app with calculation history, keyboard controls, and theme switching. The project now ships with modern tooling, automated tests, and documentation to support production-ready workflows.
- Responsive and accessible calculator UI with opt-in persistent history and memory functions.
- Dark/light theme with system preference detection and user persistence.
- Input sanitisation backed by a hardened expression parser that supports parentheses, exponentiation, and unary operators.
- Automated linting (ESLint + Stylelint), formatting (Prettier), and unit tests (Vitest).
- Node.js >= 18.18
- npm >= 9 (bundled with Node)
npm installnpm run dev # Start a static dev server at http://localhost:4173
npm test # Run unit tests once
npm run test:watch # Run unit tests in watch mode
npm run coverage # Run unit tests with coverage
npm run lint # Run ESLint and Stylelint
npm run format # Format files with Prettier- Install dependencies with
npm install. - Start the dev server:
npm run dev. - Open http://localhost:4173 in your browser.
├── index.html # Entry point with strict CSP and module loader
├── script.js # UI logic (ES module)
├── src/
│ └── lib/
│ └── calculator.js # Pure calculation helpers & memory register
├── style.css # Theming and layout
├── tests/ # Vitest unit tests
└── docs & tooling files # README, SECURITY, lint configs, etc.
- Secrets or environment-specific overrides go in
.envfiles (not committed). Provide.env.examplewhen environment variables are introduced. - The calculator persists theme and opt-in history preferences in
localStorage; history entries expire automatically after 30 days and never leave the device.
This is a static application. Any static host (Netlify, Vercel, GitHub Pages, S3, etc.) can serve the contents of the repository. Ensure cache headers are configured to allow quick updates (e.g., cache-busting by commit hash).
- Fork the repository and create a feature branch.
- Run
npm run lintandnpm testbefore opening a pull request. - Follow the architecture and security guidelines in
ARCHITECTURE.mdandSECURITY.md.