Welcome to the UKHSA Data Dashboard Frontend. This project is built with Next.js, utilizing the GOV.UK Frontend and adhering to the GOV.UK Design System (GDS) principles to deliver a robust and accessible data visualization platform.
Before you begin, ensure you have the following installed:
- Node.js version 22.13.1 or later
-
Install Dependencies
- Install node modules :
npm install
- Install node modules :
-
Environment Variables:
Create a.env.localfile at the root of your project directory. Use the example below as a reference for the required environment variables:TZ="Europe/London" API_KEY=123 API_URL=http://localhost:3005 FEEDBACK_API_URL=http://localhost:3005 GOOGLE_TAG_MANAGER_ID=GTM-W39KF5J2 -
Development Server:
Start the Next.js development server by running the following command in your terminal:npm run dev
Access the application by navigating to http://localhost:3000 in your browser.
The frontend interacts with a Node.js Express-based mock server during development. This server runs on http://localhost:3005 and uses the /mock-server/handlers directory for loading mock data. This setup allows for isolated local development ahead of backend integrations.
We have some Playwright tests which are used during the CI pipeline on PRs for testing as well as after deployments to smoke test (this is triggered from the infrastructure repository after a deployment is completed).
To setup to run the playwright tests locally, you must install playwright's dependencies:
npx playwright install --with-depsThis should install the necessary packages on your system and will inform you if anything can't be installed.
There are two sets of Playwright tests each of which targets a specific task and server. There are general tests which you should run against a dev instance of the frontend using either the mock server or a dev backend instance, and then there are smoke tests which should be run against WKEs like production.
Which server to target is specified using the baseURL environment variable.
You can specify this in your .env.local file which is read in the Playwright config file, or
you can specify it directly as an environment variable before you run Playwright (e.g. export baseURL=http://a.b.c).
The Playwright configuration will default this baseURL to http://localhost:3000 if not specified.
Which tests are run is easiest controlled using the --grep argument passed to playwright, this is shown below.
Target baseURL at local development server, make sure your dev server is running, and then run:
npx playwright test --grep-invert @smoke
# or
npm run test:e2eTarget baseURL at a WKE's URL and then run:
npx playwright test --grep @smoke
# or
npm run test:e2e:smokeOur project uses a GitHub Actions workflow for CI/CD. The workflow, located at .github/workflows/build-test-deploy, automates the build, test, code quality checks, and deployment processes. Deployments are made to AWS Elastic Container Service (ECS) on port 3000. The workflow also initiates deployment updates in our infrastructure repository.
For styling, the project primarily uses GOV.UK Frontend components and styles, supplemented with Tailwind CSS for additional customization. Conditional styles within components are managed using the clsx package.
For a detailed list of our deployment environments and their configurations, refer to our environments documentation on Confluence.
Instructions on setting up your the non-public version of the dashboard can be found here: Enabling Non Public
This repository uses pre-commit to automatically scan for hardcoded secrets before allowing commits.
We recommend using prek, a faster drop-in replacement for pre-commit. It works with the existing configuration and requires no changes to the config files.
- Install
uv(if not already installed)
On macOS:
brew install uv- Install
prekglobally:
uv tool install prek- Install Git Hooks(required)
Run this once per repository
prek installThis install the git hooks so secret scanning runs automatically before every commit
- Run Manually(Optional)
To scan all files manually
prek run --all-files