A progressive web app.
The app is automatically deployed: ABC DPT App
Make sure to have Node.js and yarn installed on your machine.
Then, install the node dependencies:
$ yarn
Run the app:
$ yarn start
The API used by the app is documented in an OpenAPI spec at [docs/ABC-DPT.v1.yaml].
By default, API requests are mocked using MSW. The behavior of the API client can be controlled using environment variables:
API_USE_MOCK
: Boolean whether API requests are mocked. Default: falseAPI_ROOT
: String of the API root without trailing slash, e.g."https://example.com/api"
. Default:""
API mocks are defined at src/mocks/
.
Entry point: src/index.tsx
Recommended editor setup:
- editorconfig
- prettier
Basic library choices:
- Language: TypeScript
- Module bundler: webpack 5 + ts-loader
- Reactivity Framework: React
- Component Library: Material-UI
- Internationalization: formatjs / react-intl
- API mocking: Mock Service Worker
Architecture overview:
- The folder structure is based on the Redux Feature-Folder Approach
- Folder structure is as follows:
src/app/
- App-Wide setup that depends on all the other folderssrc/app/pages/
- App pages, i.e. index, camera, code, start, ...
src/common/
- Generic, reusable components and utilitiessrc/common/components/
- Generic, dumb React componentssrc/common/hooks/
- Generic React hooks, API hooks based onuseSWR
src/common/icons/
- Additional icons that are not part of@material-ui/icons
src/common/testing/
- Code only used for unit testingsrc/common/types
- Generic TypeScript types used throughout the app
src/features/
- Folders that contain all functionality related to a specific featuresrc/features/code/
- Game code featuresrc/features/parameters/
- Game parameter feature
src/mocks/
- Mock Service Worker setup and handlers
Every component and every module should have a basic unit tests. Unit tests are written using Jest.
Tests are written as follows:
- React Components:
- Create meaningful Snapshot Tests
- Test behavior using
@testing-library/react
- React Hooks
- Test behavior using
@testing-library/react-hooks
- Test behavior using
- Hooks/Components that issue API requests:
- Mock API requests using Mock Service Worker
- Simple functions
- Unit test using Jest
expect()
- Unit test using Jest
To run all tests, execute:
yarn test
For Internationalization, formatjs / react-intl is used. The workflow is as follows:
Declare messages only using default message and description!
See react-intl API Reference for a full documentation.
Run yarn extract
. The file at lang/de.json
is updated. On import, it is automatically precompiled using Webpack.
Translate the messages inside lang/de.json
. The messages are formatted using the ICU Message syntax.
See Format.JS Message Syntax for a quick overview of what you can do.
See ICU Formatting Messages Documentation for a full reference.