A simple calculator app that performs basic arithmetic operations like addition, subtraction, multiplication, and division. The project is a monorepo managed by Turborepo. There are two apps - backend and frontend. Backend is just a very simple Express.js server exposing API endpoint that handles the logic of calculations. Frontend is a UI layer that renders calculator component and calls backend to get the result of the operation.
- Next.js, React (frontend)
- Node.js, Express.js (backend)
- Turborepo
- TypeScript
- Docker
- Jest, React Testing Library, MSW, Supertest
apps/backend
- Express.js APIapps/frontend
- Next.js apppackages/core
- code to share between frontend and backend
You need Node in version 18 (or higher) installed beforehand.
Install npm dependencies:
npm install
Run apps in dev mode:
npm run dev
You can now access services:
frontend http://localhost:3000
backend http://localhost:3001
Firstly create a network, which allows containers to communicate:
docker network calculator-network
Then, build docker images for backend and frontend:
npm run docker:build
Finally, run docker containers:
npm run docker:start
Ports used by dockerized services are the same as in "Running locally" section.
All packages and apps have tests using Jest as a test runner.
To run tests for all workspaces:
npm run test
To run tests for specific app/package (in this example: frontend):
npm run test -- --filter=@workspace/frontend
The value of the --filter
argument comes from the package.json
of targeted workspace.