Skip to content

Standalone in-house Digital Landscape in React.js and Node.js hosted on AWS ECS Fargate.

License

Notifications You must be signed in to change notification settings

ONS-Innovation/keh-digital-landscape

Repository files navigation

Digital Landscape

Linting Status CodeQL Status Dependabot Status LICENSE. GitHub pull requests

This tool aims to provide a visual representation of the digital landscape at ONS. This consists of the following 3 main pages and one homepage:

Tech Radar:

  • Tech Radar is a tool that helps you track the Infrastructure, Languages, Frameworks and Supporting Tools used in ONS repositories and then categorises them into Adopt, Trial, Assess or Hold.
  • Use the following keyboard shortcuts to navigate the tech radar:
    • 2 to move up the list of technologies
    • 1to move down the list of technologies

Statistics:

  • This provides a collection of statistics about the language breakdown within the ONSDigital GitHub Organisation.
  • Multiple filters such as Archive/Active, date filter and project filteroptions are available.
  • Sort options such as Alphabetically, Most/Least Repositories, usage, size.
  • Toggle options to display Tech Radar languages only and switch between Average Size and Total Size.

Projects:

  • This displays the project data collected from the Tech Audit Tool.
  • Multiple features such as alphabetically, most/least tech and tech radar ring ratio per project are available.

Review Page

  • On the deployed version, this page is only available to users from the Cognito user pool.
  • Grants a user the ability to move, edit and bring new technology on to the Radar.

Homepage:

  • This is the homepage of the tool.
  • It provides a brief overview of the tool and its purpose.

Getting started

Clone the repository:

git clone https://github.com/ONS-innovation/keh-digital-landscape.git

Install both backend and frontend dependencies:

make install

How to setup

First, ensure you have Node.js installed. It is recommended to use Node Version Manager (nvm) to manage Node.js versions:

  1. Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  1. Install Node.js using nvm:
nvm install 18.19.0
  1. Set the Node.js version to use:
nvm use 18.19.0
  1. Remember to export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:
export AWS_ACCESS_KEY_ID=<your_access_key>
export AWS_SECRET_ACCESS_KEY=<your_secret_key>

Running locally

Make dev.sh executable:

chmod +x dev.sh

To run the project locally (frontend and backend together):

make dev

This runs the frontend and backend locally on ports 3000 and 5001.

To run the frontend only:

make frontend

To run the backend only:

make backend

How to deploy locally

make docker-build
make docker-up

This should build the project and then start the project locally on port 3000 and 5001.

To stop the project:

make docker-down

Testing

Tests are run with PyTest. To run the tests, refer to the README.md in the /testing/ folder.

Linting

Linting is run with ESLint. To run the linting, run the following commands:

Install the dev dependencies:

make install-dev

Run the linting:

make lint

Run the linting for the frontend:

make lint-frontend

Run the linting for the backend:

make lint-backend

How to containerise and deploy to ECR on AWS

Build the frontend container:

docker build -t <account_id>.dkr.ecr.<region>.amazonaws.com/<repo>:<version_tag> ./frontend

Push the frontend container to ECR:

docker push <account_id>.dkr.ecr.<region>.amazonaws.com/<repo>:<version_tag>

Build the backend container:

docker build -t <account_id>.dkr.ecr.<region>.amazonaws.com/<repo>:<version_tag> ./backend

Push the backend container to ECR:

docker push <account_id>.dkr.ecr.<region>.amazonaws.com/<repo>:<version_tag>

How to deploy infrastructure to AWS

Login to AWS via CLI:

aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin 999999999999.dkr.ecr.eu-west-2.amazonaws.com

Change directory to the authentication folder:

cd terraform/authentication

Set the environment variables. Check the terraform/service/env/dev/example_tfvars.txt file for the correct values.

Run Terraform:

terraform init -backend-config="env/dev/backend-dev" -reconfigure
terraform plan -var-file=env/dev/dev.tfvars
terraform apply -var-file=env/dev/dev.tfvars

Change directory to the service folder (if in authentication folder):

cd ../service

Set the environment variables. Check the terraform/service/env/dev/example_tfvars.txt file for the correct values.

Run Terraform:

terraform init -backend-config="env/dev/backend-dev" -reconfigure
terraform plan -var-file=env/dev/dev.tfvars
terraform apply -var-file=env/dev/dev.tfvars

Change directory to the storage folder (if in service folder):

cd ../storage

Set the environment variables. Check the terraform/storage/env/dev/example_tfvars.txt file for the correct values.

Run Terraform:

terraform init -backend-config="env/dev/backend-dev" -reconfigure
terraform plan -var-file=env/dev/dev.tfvars
terraform apply -var-file=env/dev/dev.tfvars

Makefile

To see the available commands, run the following command:

make