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
-
nvm
allows you to quickly install and use different versions ofnode
via the command line. -
It is recommended to install
yarn
through thenpm
package 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
yarn
version 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 false
VITE_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
Vite
dev 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.js
to a local runningapi
server to preview the built artifact successfully. - We have a chunking logic in
vite.prod.config.js
which creates and splits vendor chunks. - We need to copy the map vectors artifact. This is a
json
file that needs to be copied explicitly. - An SRI plugin runs in the
post
pipeline ofVite
to addSRI
values for all assets.
- We use
Vitest
andvue-test-utils
for unit testing:yarn test
- We also use
c8
to capture coverage:yarn test:coverage
- Leverage
Vitest UI
using:yarn test:ui
- We use
eslint
withvite recommendations
:yarn lint
- This is the
Vue2
UI 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
Vue
structure withComponents
containing most of View logic. - The
__tests__
directory containsVitest
based unit tests and some interaction tests. - We use Front-end generated
pdf
logic powered bypdf-lib
. The meat of this code is inpdfhelper
directory. - We have created a util for chunking and paginating for PDF generation.
- We also use
chartJs
,papaparse
andyup
for Charts, CSV parsing and validations respectively. - We use
Vue-router
for defining our paths and common components. - We don't use a state management library.We are using event bubbling in most cases with
window.appPropeties
to 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
scss
for our CSS pre-processing. - Most of our CSS files are in the stylesheets directory from v1.
- We are also using
mixin
based logic for RTL language support. scss
support comes in-built inVite
so no additional configurations needed for the same.- We have a start-server script that starts the
httpd
server instance on depoyment.
- We have 3
environments
of Deployment: - We use
github actions
to configure our CI. The code for the same can be found in.github/workflows
directory. - 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
httpd
server onAWS
to start up as a reverse-proxy which serves the Web assets fromasset
directory. - It also routes any requests with
api
to the backend application running on the same instance as ajar
file.
While trying to run the app on your local, here are some of the problems you might be facing:
- Check that the
node
version is used vianvm
or to use the same version as `.nvmrc1 file.
-
In your terminal, run the nvm installer. For
v0.391
the command looks like below. Please checknvm
documentation for the latest version:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
You can use
curl
orwget
depending on the command available on your device. These commands will clone the nvm repository to a~/.nvm
directory on your device. -
Update your profile configuration:
The installation process from step 1 should also automatically add thenvm
configuration to your profile. If it doesn't automatically addnvm
configuration, 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
nvm
installed. -
Use the specified node version in the repository
nvm use