-
Notifications
You must be signed in to change notification settings - Fork 1
Design Decisions
React is a frontend framework for JavaScript that uses components to build interactive and responsive webpages. It is currently the most popular JavaScript framework with a large online community of resources.
Key reasons React was included:
- Developer familiarity with the framework
- Large knowledge base both within organization and online
- Wide assortment of UI components available
- Easily manageable state for a small project
Vite is a development environment that replaces the common react-scripts
. It allows developers to quickly start React projects, but it also boasts a faster build process than react-scripts
by identifying which components have changed and only rebuilding those components.
Vite was selected to make use of the benefits noted above but also for developer learning experience.
Express is a backend API framework for Node.js that allows developers to build robust REST API web services quickly and easily.
It was selected for this project for the following reasons:
- Developer familiarity
- Integration with existing components needed for IDIR authentication
- Flexible method handlers and routing options
- Compatibility with the projected needs of the project
MongoDB is a NoSQL database option that is known for its high-flexibility and easy scalability. It stores its data in BSON, but works natively with JavaScript objects to perform queries and mutations as necessary.
Although PostgreSQL was also considered, MongoDB was selected for the following reasons:
- The CHEFS form is highly likely to change over time, and a NoSQL solution offers a more dynamic schema, compared to a relational option that would require migrations after each change.
- The expected data does not need to be transactional, which is typically associated with relational models.
- The data stored should be fairly unitary. The only expected input of data is from the CHEFS form, and all user authentication and authorization is done using the Keycloak IDIR login, meaning there is no need to store a collection or table of users. Because of this, there is little need for a relational model.
Docker is a containerization platform that allows developers to build and run images containing their applications. By leveraging this, the developer can ensure that the application is always run in its expected environment.
This project also leverages the docker-compose
option, using a docker-compose.yaml
file to specify the required containers and their parameters when building the project. This same technology is used when deploying images to a cloud environment.
Swagger is a documentation tool which uses OpenAPI standards to create a living documentation page. This page displays all resources and methods available on the API, and it allows users to test these endpoints directly through this interface.
Swagger was selected as the documentation tool because of its simple and easy to create YAML configuration, its features allowing in-documentation testing, and its common use among other BC Government projects.
Cypress is a testing framework that specializes in frontend component and end-to-end testing. It offers an interactive UI where developers can view tests happening in realtime and see their results immediately.
Reasons to use Cypress for frontend testing:
- It contains its own assertion library.
- It is easier to identify on-screen elements and manipulate them when compared to a competitor, such as Puppeteer when used with Jest.
- It offers the ability to produce videos of failed tests to see exactly how the test failed.
- It has been used on other projects in conjunction with the Keycloak authentication system.
Jest is another JavaScript testing framework. It offers many of the usual testing functions, such as code coverage, mocking, and snapshots.
Jest was considered for backend testing for the following reasons:
- Cypress is not well equipped to complete backend testing.
- Combined with the SuperTest module, it is easy to make requests against API resources for integration testing.
- The developers have prior experience with Jest, allowing reuse of previous work.
The Common Hosted Form Service is an application created by BC Government that allows for the creation of custom forms. Users are able to drag and drop needed components, and CHEFS offers a variety of customization options to suit a range of needs.
The reasons for including CHEFS in this project include:
- Meets project goal of demonstrating possible CHEFS integration with custom application.
- Offers many tools for developers to create needed forms without having to create the form components from scratch.
- Can send form data directly to REST API endpoints.
When choosing a library for schema validation, the three options most closely weighed were Yup, Zod, and Validate.js.
Validate.js, while being the most established option, was the least developer friendly in terms of setup and syntax. It was highly customizable, but required a steeper learning curve. One benefit was the lack of dependancies, but it did lack a simple way of doing asynchronous validation.
Yup was a familiar library to the developer involved. It offers straightforward, friendly syntax, but applying the validation to a TypeScript environment involved additional steps.
Zod offered similar features to Yup but with a TypeScript-first approach. It also offered zero dependancies and builds off of earlier work with similar validation libraries. Validation with Zod generates thrown errors, which is something Yup does not do, offering a more calculated approach to error control. One downside is that it is the newest option, and therefore has the least amount of online resources.
With this comparison in mind, Zod was chosen for schema validation.