A modern, responsive calculator web application built with Node.js, Express, and TypeScript. Features both a visual calculator interface and an expression evaluator.
- Visual Calculator: Interactive button-based calculator with a clean, modern UI
 - Expression Evaluator: Input and evaluate mathematical expressions directly
 - Keyboard Support: Full keyboard navigation and input support
 - Responsive Design: Works seamlessly on desktop and mobile devices
 - TypeScript: Fully typed codebase with comprehensive error handling
 - REST API: Backend API for calculator operations
 - Session Management: Multiple calculator sessions support
 - Comprehensive Testing: Unit and integration tests with high coverage
 
- Node.js (version 16 or higher)
 - npm or yarn
 
- Clone the repository:
 
git clone <repository-url>
cd typescript-calculator-webapp- Install dependencies:
 
npm install- Build the application:
 
npm run build- Start the server:
 
npm start- Open your browser and navigate to 
http://localhost:3000 
For development with auto-reload:
npm run devTo watch for TypeScript changes:
npm run watchThe visual calculator provides a traditional calculator interface with:
- Number buttons (0-9)
 - Basic operators (+, -, ×, ÷)
 - Decimal point support
 - Clear (C) and Clear All (AC) functions
 - Equals button for calculations
 
- Numbers (0-9): Input digits
 - Operators (+, -, *, /): Mathematical operations
 - Enter or =: Calculate result
 - Escape: Clear all
 - Backspace: Clear current input
 - .: Decimal point
 
Enter mathematical expressions directly:
2 + 3 * 4→ 14(2 + 3) * 4→ 2010 / 2 + 5→ 101.5 + 2.5→ 4
GET /health
Returns server health status.
POST /api/calculate
Content-Type: application/json
{
  "expression": "2 + 3 * 4"
}
Response:
{
  "result": 14
}POST /api/calculator/:sessionId/operation
Content-Type: application/json
{
  "operation": "digit",
  "value": 5
}
- digit: Input a digit (0-9)
 - decimal: Input decimal point
 - operator: Input operator (+, -, *, /, =)
 - clear: Clear current input
 - clearAll: Reset calculator
 
- Express Server: RESTful API and static file serving
 - Calculator Class: Core calculation logic with state management
 - Error Handling: Comprehensive error handling and validation
 - Session Management: Multiple calculator instances per session
 
- CalculatorUI Class: Manages UI interactions and API communication
 - Responsive Design: CSS Grid and Flexbox for layouts
 - Keyboard Support: Event listeners for keyboard navigation
 - Error Handling: User-friendly error messages
 
Run all tests:
npm testRun tests with coverage:
npm test -- --coverage- Calculator Logic: Unit tests for all mathematical operations
 - API Endpoints: Integration tests for all REST endpoints
 - Edge Cases: Division by zero, invalid expressions, etc.
 - Error Handling: Comprehensive error scenario testing
 
Run ESLint:
npm run lintnpm run build: Compile TypeScript to JavaScriptnpm start: Start the production servernpm run dev: Start development server with ts-nodenpm run watch: Watch TypeScript files for changesnpm test: Run test suitenpm run lint: Run ESLintnpm run clean: Remove build artifacts
├── src/
│   ├── calculator.ts          # Core calculator logic
│   ├── server.ts             # Express server setup
│   └── __tests__/
│       ├── calculator.test.ts # Calculator unit tests
│       └── server.test.ts    # API integration tests
├── public/
│   ├── index.html           # Main HTML file
│   ├── styles.css           # CSS styles
│   └── calculator.js        # Frontend JavaScript
├── dist/                    # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
├── jest.config.js
├── .eslintrc.js
└── README.md
- Backend: Node.js, Express, TypeScript
 - Frontend: HTML5, CSS3, Vanilla JavaScript
 - Testing: Jest, Supertest
 - Linting: ESLint with TypeScript support
 - Build: TypeScript Compiler
 
- Fork the repository
 - Create a feature branch
 - Make your changes
 - Add tests for new functionality
 - Ensure all tests pass
 - Run linting
 - Submit a pull request
 
MIT License - see LICENSE file for details.
- Scientific calculator functions
 - History of calculations
 - Themes and customization
 - WebSocket for real-time updates
 - Progressive Web App (PWA) support
 - Calculator memory functions (M+, M-, MR, MC)