This architecture has the following goals in mind:
- Allow for continuous improvements to the v1 codebase
- Code should live outside of v1 codebase for the following reasons:
- Avoids issues with incompatible dependencies (i.e. Bootstrap 3 vs 4)
- Allows code to be tested in isolation
- Enables modern optimizations like code-splitting, minification
- Simplifies build process
- Allows use of modern javascript features (es6, jsx, styled-components, etc)
The codebase will be split into 3 separate packages that all live within a single mono-repo:
v1
: A front-end application that serves components via iframes to the legacy v1 front-endv2
: A front-end application that serves a new site, with a new navigation structure, routing system and themeshared
: A shared library of components used by both of the above applications
The new architecture will leverage the following libraries:
- lerna: used for managing multiple packages within a single repository
- react.js: UI library / framework
- next.js: build system, routing
- bootstrap v4: themeable css framework
- reactstrap: react interface for bootstrap components
- styled-components: styling system that allows for theming and isolation of component styles
- axios: API client
- redux: application state management
- jest: testing + code coverage
- eslint: code linting + formatting
These 3 packages will be managed using Lerna. The directory structure will look as follows:
root/
packages/
shared/
components/
v1/
routes.js
pages/
theme/
variables.scss
v2/
routes.js
pages/
theme/
variables.scss
The shared
package will contain components used by both the v1
legacy site and the new v2
site.
Both the v1
and v2
sites will define their own theme using bootstrap global variables. This will allow the v2
site to change the look and feel independently of the current v1
theme while still allowing both sites to share the same components.
The v1
site will provide access to the new react components via embeddable iframes. Props can be passed to the components via querystring params.
If we wanted to render the Case Index of a firm with the id 123
, we would use the following code snippet:
<iframe src="/shared/case-index?firmId=123" />
The v1
embedded site will then perform the following actions:
- Fetch the data necessary to render the
CaseIndex
component from the API - Render the
CaseIndex
component in isolation using thev1
bootstrap theme
Next.js will compile the application as a static site which can be served from the static
directory of the existing v1
site.
The v2
site will be a stand-alone node.js application that will function independently of the v1
front-end. It will integrate with the existing casepacer backend via API endpoints that will provide JSON data to a new React.js application.
We have several options for hosting. The easiest will be to run the front-end application using a node.js server running from heroku. This will provide the following benefits:
- Allow local development against a staging API without needing to run the existing .NET infrastructure locally
- Allow Q/A using review apps
- Easy integration + deployment with CI systems (i.e. circle)
- Easy rollback of broken builds