Fx MVC houses functionally equivalent versions of an app implemented in different web UI frameworks (currently React and Angular). The app pulls foreign exchange rate data from the Alpha Vantage APIs (with caching in browser storage using the CacheStorage APIs). It displays the historical and intraday data using the Ag Grid and Highcharts libraries, and it simulates currency exchange transactions using the market live rate and a fake personal bank seeded with 5,000 USD. The "bank" data is persisted in browser storage using the IndexedDB APIs. App versions use the standard Material Design UI component implementations avaialble for each framework.
The repo started when I needed to relearn Angular for a project after several years of doing React development. I quickly realized the Nx monorepo scaffolding and tooling would make it easy to run versions of the app that used different UI frameworks with all the data logic reused through shared libraries. Extracting the data logic into libaries lets the app code focus on the core job of the UI frameworks in MVC: responding to user events, orchestrating client state, and syncing views with state. The goal of the project is something like TodoMVC, though with a use case that demonstrates more complexity.
To get started, simply run npm install
. Libraries and tooling have only been tested on Node v12, but should at least work on v >= 10.
Run the React UI with npm run start-fx-react
. Runs on port 4200 by default.
Run the Angular UI with npm run start-fx-angular
. Runs on port 4500 by default (changing port requires updating the npm script).
Both these commands launch dev servers that will live rebuild with code changes. For for full dev tooling, utlize the Nx commands and infrastructure described below.
This project was generated using Nx.
🔎 Nx is a set of Extensible Dev Tools for Monorepos.
10-minute video showing all Nx features
Nx supports many plugins which add capabilities for developing different types of applications and different tools.
These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
Below are some plugins which you can add to your workspace:
- Angular
ng add @nrwl/angular
- React
ng add @nrwl/react
- Web (no framework frontends)
ng add @nrwl/web
- Nest
ng add @nrwl/nest
- Express
ng add @nrwl/express
- Node
ng add @nrwl/node
Run ng g @nrwl/angular:app my-app
to generate an application.
You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.
Run ng g @nrwl/angular:lib my-lib
to generate a library.
You can also use any of the plugins above to generate libraries as well.
Libraries are sharable across libraries and applications. They can be imported from @fx/mylib
.
Run ng serve my-app
for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
Run ng g component my-component --project=my-app
to generate a new component.
Run ng build my-app
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test my-app
to execute the unit tests via Jest.
Run nx affected:test
to execute the unit tests affected by a change.
Run ng e2e my-app
to execute the end-to-end tests via Cypress.
Run nx affected:e2e
to execute the end-to-end tests affected by a change.
Run nx dep-graph
to see a diagram of the dependencies of your projects.
Visit the Nx Documentation to learn more.