The App is build using Vue2, Vite and Vitest.
It uses Yarn@2 as a package manager and github actions for CI/CD.
- Pre-requisites
- Build Dependencies
- Dev Dependencies
- Running the app locally
- Building the app for production
- Unit testing
- Linting
- Project Overview
- Application Structure
- Deployment
- Troubleshooting
-
nvmallows you to quickly install and use different versions ofnodevia the command line. -
It is recommended to install
yarnthrough thenpmpackage manager, which comes bundled withNode. Once you have npm installed you can run the following both to install and upgradeYarn:nvm use npm install --global yarn
To verify the installation:yarn --version
We are using
yarnversion 3.X in our project.
Some build dependencies of the project inlude:
-
Vue2 as FE framework of choice.
-
axios for API calls.
-
chartjs chart utils.
-
leaflet for displaying Maps.
-
pdf-lib for Browser pdf genration.
-
vue-gtag for Google analytics integration. This depends on the following env variables:
VITE_IS_GOOGLE_ANALYTICS_ENABLED=true or falseVITE_GOOGLE_ANALYTICS_ID={google analytics gid} -
Font-Awesome as CSS style artifact for icons.
Some dev dependencies of the project inlude:
- Vite as FE Bundler of choice.
- husky for pre-push checks.
- eslint for linting.
- prettier for formatting.
- vitest for unit testing
- vue-test-utils for Vue component testing
For running locally, we want to keep the Enabled flag as False
- To run the app locally install dependencies first:
yarn install
- Once installed, run:
The above command will run the
yarn dev
Vitedev server locally. This relies on the backend running on port 8888 - To change the configurations update the same in
vite.dev.config.js
- To build the app for production run:
yarn build
- To preview the built artifacts run:
The above will point to a backend server running locally. Change the
yarn preview
vite.prod.config.jsto a local runningapiserver to preview the built artifact successfully. - We have a chunking logic in
vite.prod.config.jswhich creates and splits vendor chunks. - We need to copy the map vectors artifact. This is a
jsonfile that needs to be copied explicitly. - An SRI plugin runs in the
postpipeline ofViteto addSRIvalues for all assets.
- We use
Vitestandvue-test-utilsfor unit testing:yarn test - We also use
c8to capture coverage:yarn test:coverage
- Leverage
Vitest UIusing:yarn test:ui
- We use
eslintwithvite recommendations:yarn lint
- This is the
Vue2UI repo for GDHM. - The project provides a platform to upload digital health metrices of various Countries globally and a way to visualize them.
- We have yearwise segregation of data to allow comparisons across years.
- We also have Regions which are composed of Countries
- We rely on backend as our source of truth and use the UI for only minor data changes before rendering it on the UI
- The App follows a normal
Vuestructure withComponentscontaining most of View logic. - The
__tests__directory containsVitestbased unit tests and some interaction tests. - We use Front-end generated
pdflogic powered bypdf-lib. The meat of this code is inpdfhelperdirectory. - We have created a util for chunking and paginating for PDF generation.
- We also use
chartJs,papaparseandyupfor Charts, CSV parsing and validations respectively. - We use
Vue-routerfor defining our paths and common components. - We don't use a state management library.We are using event bubbling in most cases with
window.appPropetiesto share state across components. - We are also using
i10n- some of these translations are found here, while for others we rely on the backend. - We don't have API end points configured on the UI side, rather the BE app is assumed to be running on the same instance as the UI app. More of it in deployment section below
- We are using
scssfor our CSS pre-processing. - Most of our CSS files are in the stylesheets directory from v1.
- We are also using
mixinbased logic for RTL language support. scsssupport comes in-built inViteso no additional configurations needed for the same.- We have a start-server script that starts the
httpdserver instance on depoyment.
- We have 3
environmentsof Deployment: - We use
github actionsto configure our CI. The code for the same can be found in.github/workflowsdirectory. - Below is a sequence diagram for CI/CD of the application:
sequenceDiagram;
participant local
participant CI
participant AWS/S3
participant QA
participant ShowCase
participant Production
local-->>local: Pre-push hooks
local->>CI: Code push
CI-->>CI: Install deps
CI-->>CI: Unit tests
CI-->>CI: Build the app and get buildNumber
CI->>AWS/S3: Upload build contents
AWS/S3->>QA: Codedeploy QA
QA-->>QA: Automation tests on QA
QA->>ShowCase: Set a buildNumber and trigger deployment(manual)
ShowCase->>Production: Promote from Showcase to Production(manual)
- We use an
httpdserver onAWSto start up as a reverse-proxy which serves the Web assets fromassetdirectory. - It also routes any requests with
apito the backend application running on the same instance as ajarfile.
While trying to run the app on your local, here are some of the problems you might be facing:
- Check that the
nodeversion is used vianvmor to use the same version as `.nvmrc1 file.
-
In your terminal, run the nvm installer. For
v0.391the command looks like below. Please checknvmdocumentation for the latest version:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashwget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bashYou can use
curlorwgetdepending on the command available on your device. These commands will clone the nvm repository to a~/.nvmdirectory on your device. -
Update your profile configuration:
The installation process from step 1 should also automatically add thenvmconfiguration to your profile. If it doesn't automatically addnvmconfiguration, you can add it yourself to your profile file:export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
This command above loads nvm for use.
-
Reload the shell configuration With your profile configuration updated, now you will reload the configuration for your terminal to use:
source ~/.bashrc`
With this command executed, nvm is ready for you to use. You can confirm that nvm is installed correctly by running:
nvm -v
This should show the version of
nvminstalled. -
Use the specified node version in the repository
nvm use