- name
- full-stack-dev
- description
- How to develop the frontend and backend together. When you want to make changes to the UI, use this.
# Frontend application
We have a frontend React app in `hawk/www/`. It is pretty lightweight for the moment. It has some views to list eval sets, scans, and samples, from the data warehouse DB.
It embeds the inspect_ai and inspect_scout frontend components.
If you want to make changes to inspect_ai and inspect_scout, you can link them to this project.
It's perfectly okay to make changes to inspect_ai and inspect_scout. We can contribute changes upstream.
## Environment files
Env files are generated from Pulumi stack outputs using
`scripts/dev/generate-env.py` from the repository root.
Log in to Hawk's S3 Pulumi backend, set a stack name once, then generate the environment files from the repository root:
```bash
export AWS_PROFILE="<profile-for-the-target-account>"
export PULUMI_FALLBACK_TO_STATE_SECRETS_MANAGER=true
pulumi login "s3://<state-bucket>?region=<region>&awssdk=v2"
export STACK="<stack>"
```
**CLI-only env** (for hawk CLI usage):
```bash
uv run python scripts/dev/generate-env.py "$STACK" > .env
```
**Full local dev env** (includes HAWK_API_* vars for running FastAPI locally):
```bash
uv run python scripts/dev/generate-env.py "$STACK" --api > hawk/.env
```
The destinations intentionally differ: the Hawk CLI loads `.env` from its
current working directory, while `scripts/dev/api` explicitly loads
`hawk/.env` before starting the local API.
The `--api` flag adds backend `HAWK_API_*` variables for the deployed stack's
database, S3 bucket, Middleman, ECR repositories, and other infrastructure. It
sets `VITE_API_BASE_URL` so the frontend talks to the local API.
Use `stg` or the name of your own `dev-*` stack.
## Running the backend
To run FastAPI locally against a deployed stack's DB/S3/etc.:
```bash
cd hawk
uv run python ../scripts/dev/generate-env.py "$STACK" --api > .env # if not already done
set -a && source .env && set +a
uv run fastapi dev hawk/api/server.py --port 8080
```
The backend takes ~15-20 seconds to start due to heavy imports. If port 8080 is in use, pick another port and update `VITE_API_BASE_URL`.
Alternatively, to skip running the backend locally and point the frontend at a deployed API:
```bash
DEPLOYED_API_URL="$(pulumi stack output api_url -s "$STACK")"
cd hawk/www
VITE_API_BASE_URL="$DEPLOYED_API_URL" pnpm dev
```
## Running the frontend
The frontend uses **pnpm** (specified in `package.json` `packageManager`). `npm run dev` also works.
```bash
cd hawk/www
pnpm install # if needed
set -a && source ../.env && set +a # picks up VITE_* vars
pnpm dev
```
The dev server runs on http://localhost:3000/. The backend API URL is configured via `VITE_API_BASE_URL` (defaults to `http://localhost:8080`).
## Developing embedded viewer libraries
Ordinary Hawk frontend work needs only `hawk/www`; do not clone Inspect AI or
Inspect Scout unless the change is inside one of their embedded viewer
libraries. For that cross-repository workflow, including cloning the relevant
repository at Hawk's pinned revision and linking its viewer package locally,
follow [hawk/www/README.md](../../../hawk/www/README.md#developing-the-embedded-viewer-libraries).
عرض على GitHub