This document describes the codebase, including details such as folder structure, technology stack, and style guide.
The folder structure looks like so:
- client/
- client-e2e/
- docker-compose.yml
The codebase is meant to be run on docker containers through docker-compose
. Each top-level folder is responsible for a particular container, so there's a docker-compose.yml
file as well as a Dockerfile
in each folder.
client
contains the code for the front-end.client-e2e
is a project using WebdriverIO and Selenium to run end-to-end tests forclient
.
To run the tests, Selenium hub is run through docker-compose. This is convenient for developers since they won't need to have selenium and all the browser engines installed. (See testing for more testing information)
client
is a NodeJS codebase written in TypeScript. It uses the npm cli to manage dependencies.
Webpack is used to compile the source code (located in client/src
) to static files to be viewed by the browser.
For the frontend UI, ReactJS is used. React is used as it encourages declarative rendering and FP principles, which makes the code easier to maintain.
The folder structure for client
looks like this:
- src
- app
- components
- hooks
- types
- util
- public
- vendor
- magic-wormhole.rs
- wasm
src
is where all our first-party code goes.
vendor
as of now only contains a submodule tomagic-wormhole.rs
. This is included to compile the wasm module.
wasm
contains the bindings that allow us to usemagic-wormhole.rs
in the browser via webassembly.
The react app code is located here.
src/app/components
for React components.src/app/hooks
for React hooks.src/app/types
for type-only.ts
files andd.ts
filessrc/app/util
contain files that typically export a single pure function or several constant values. They are usually shared across multiple files
src/public
contains static files that should be copied to the final build such as images, fonts, etc.
Webpack is configured to use style-loader and css-loader, allowing you to import CSS from JS/TS files.
CSS modules is enabled if the file ends in *.modules.css
. You will see this used often in app/components
to generate scoped CSS per React component.
- Jest is used as for unit/integration tests.
- Testing Library is used to write better integration tests for react components and hooks.
- WebdriverIO is used to write e2e tests. The tests are run through Selenium hub in a docker container. (See this section for more info.)
TODO