20260718 重构 RPKI Explorer 查询界面
This commit is contained in:
@@ -1,81 +1,111 @@
|
||||
# RPKI Explorer
|
||||
|
||||
RPKI Explorer is the SPA frontend for browsing ours RP `rpki_query_service` outputs.
|
||||
RPKI Explorer is the web UI for browsing the outputs of the ours RP
|
||||
`rpki_query_service` — runs, repositories, publication points, objects,
|
||||
validation issues and evidence exports. It is a read-only query layer: it does
|
||||
not change validation logic or RP state.
|
||||
|
||||
## Scope
|
||||
## Features
|
||||
|
||||
Current MVP covers:
|
||||
- **Overview** — latest-run health at a glance: VRP/ASPA/object/PP counts,
|
||||
validation result and object type charts, top repositories, top reject
|
||||
reasons, all with drill-down links.
|
||||
- **Repositories** — paginated repository list, repository detail with sync
|
||||
phases/terminal states, publication points and scoped object browsing.
|
||||
- **Publication Points** — global PP list and PP detail (URIs, sync state,
|
||||
thisUpdate/nextUpdate, objects).
|
||||
- **Objects** — global object browser with **server-side filters**
|
||||
(`type`, `result`, `rejected`, `q` URI substring) and cursor paging.
|
||||
- **Object detail** — structured parsed projections (ROA prefixes, ASPA
|
||||
providers, manifest file list, CRL revocations, certificate fields),
|
||||
validation summary, on-demand *explain* (audit projection, non-authoritative),
|
||||
chain edges, raw DER download, object-set export.
|
||||
- **Validation** — result distribution, reject-reason distribution with
|
||||
click-to-filter, paginated issue list (`/issues`).
|
||||
- **Search** — unified lookup: exact object URI, SHA-256 (full or ≥8 hex
|
||||
prefix), repository host/URI substring, PP URI substring.
|
||||
- **Exports** — export job list with live polling and tarball download.
|
||||
- **Runs** — indexed run history; pin any run as the browsing context via the
|
||||
run selector in the top bar (`?run=` URL param, deep-linkable everywhere).
|
||||
- **API** — service health and endpoint reference.
|
||||
|
||||
- Overview dashboard from latest run, stats, validation reasons, and top repositories.
|
||||
- Repository -> publication point -> object lazy browser.
|
||||
- Object detail with live object record, validation summary, lazy parsed/chain/list tabs, and validation explain.
|
||||
- Exact URI lookup, raw download action, and object / publication point export actions.
|
||||
## Backend requirements
|
||||
|
||||
Known backend-dependent limits:
|
||||
`rpki_query_service` (this repository, `src/bin/rpki_query_service.rs`) with a
|
||||
query-db built by `rpki_query_indexer`. Some features need extra service flags:
|
||||
|
||||
- Parsed projection, raw download, and export success require `rpki_query_service --repo-bytes-db <path>`.
|
||||
- Without repo bytes, the UI shows explicit unavailable/error states instead of fabricating data.
|
||||
- VRP IP/prefix lookup is not part of this MVP and is tracked separately.
|
||||
- Query service does not provide CORS headers; use a same-origin proxy.
|
||||
| Feature | Requirement |
|
||||
| --- | --- |
|
||||
| Parsed projections, raw download, exports | `--repo-bytes-db <path>` |
|
||||
| New runs appear automatically | `--watch-run-root <path>` |
|
||||
|
||||
The service has **no CORS headers and no authentication** — the UI must be
|
||||
served same-origin with the API behind a proxy (dev: Vite proxy; prod: reverse
|
||||
proxy). VRP IP/prefix/ASN lookup is not available yet (backend feature #070);
|
||||
the search page says so explicitly when such a query is detected.
|
||||
|
||||
## Development
|
||||
|
||||
Start query service first:
|
||||
Start the query service (example with a local query-db):
|
||||
|
||||
```bash
|
||||
rpki_2/rpki/target/llvm-cov-target/debug/rpki_query_service \
|
||||
--query-db .scratch/rpki_explorer_m3_api/query-db \
|
||||
--listen 127.0.0.1:19571
|
||||
rpki_2/rpki/target/debug/rpki_query_service \
|
||||
--query-db /path/to/query-db \
|
||||
--repo-bytes-db /path/to/repo-bytes.db \
|
||||
--listen 127.0.0.1:9557
|
||||
```
|
||||
|
||||
Start the Vite dev server with a proxy:
|
||||
Start the Vite dev server:
|
||||
|
||||
```bash
|
||||
cd rpki_2/rpki/ui/rpki-explorer
|
||||
npm install
|
||||
RPKI_EXPLORER_API_TARGET=http://127.0.0.1:19571 npm run dev -- --port 5173
|
||||
RPKI_EXPLORER_API_TARGET=http://127.0.0.1:9557 npm run dev
|
||||
```
|
||||
|
||||
The Vite dev server proxies `/api/v1/*` to `RPKI_EXPLORER_API_TARGET`; default target is `http://127.0.0.1:9557`.
|
||||
The dev server proxies `/api/v1/*` to `RPKI_EXPLORER_API_TARGET`
|
||||
(default `http://127.0.0.1:9557`) and serves the UI on `http://127.0.0.1:5173`.
|
||||
|
||||
## Production Build Preview
|
||||
## Production
|
||||
|
||||
```bash
|
||||
cd rpki_2/rpki/ui/rpki-explorer
|
||||
npm run build
|
||||
RPKI_EXPLORER_API_TARGET=http://127.0.0.1:19571 npm run preview -- --port 4173
|
||||
RPKI_EXPLORER_API_TARGET=http://127.0.0.1:9557 npm run preview # smoke-test the build
|
||||
```
|
||||
|
||||
For real deployment, serve `dist/` through a static server or reverse proxy and route `/api/v1/*` to `rpki_query_service` on the same origin.
|
||||
For real deployments serve `dist/` with any static server / reverse proxy and
|
||||
forward `/api/v1/*` to `rpki_query_service` on the same origin, e.g. nginx:
|
||||
|
||||
```nginx
|
||||
location /api/v1/ { proxy_pass http://127.0.0.1:9557; }
|
||||
location / { root /srv/rpki-explorer/dist; try_files $uri /index.html; }
|
||||
```
|
||||
|
||||
`try_files ... /index.html` (SPA fallback) is required because routing is
|
||||
client-side.
|
||||
|
||||
## Validation
|
||||
|
||||
```bash
|
||||
npm run typecheck
|
||||
npm run lint
|
||||
npm run build
|
||||
npm audit --audit-level=high
|
||||
npm run test:e2e
|
||||
npm run typecheck # tsc project references
|
||||
npm run lint # eslint
|
||||
npm test # vitest unit tests (lib + api contract)
|
||||
npm run build # production build
|
||||
npm run test:e2e # Playwright, fully mocked backend (no service needed)
|
||||
```
|
||||
|
||||
Playwright is intentionally configured with `workers: 1`. The current query service object endpoints use lazy `report.json` scans, so parallel browser tests can create artificial backend contention and false failures.
|
||||
E2E tests intercept every `/api/v1/**` request with a fixture-backed mock
|
||||
(`tests/e2e/mockApi.ts`), so they are deterministic and need no running query
|
||||
service. They start the Vite dev server automatically (`workers: 1`).
|
||||
|
||||
## Screenshot Evidence
|
||||
|
||||
Milestone screenshots are stored under:
|
||||
## Directory layout
|
||||
|
||||
```text
|
||||
specs/develop/20260617/m*_playwright/
|
||||
```
|
||||
|
||||
## Directory Layout
|
||||
|
||||
```text
|
||||
src/api/ query-service client and TypeScript records
|
||||
src/app/ app shell and top-level navigation state
|
||||
src/components/layout/ sidebar/topbar shell
|
||||
src/features/overview/ latest run overview dashboard
|
||||
src/features/repositories repo -> PP -> object browser
|
||||
src/features/object-detail live object detail and workflows
|
||||
src/styles/globals.css MVP visual system
|
||||
src/api/ fetch client, zod schemas, typed endpoint functions
|
||||
src/app/ providers, router, react-query client
|
||||
src/components/ shell, data table, pills, pager, tabs, object table, …
|
||||
src/lib/ formatting, cursor pager state machine, run context, guards
|
||||
src/pages/ one file per route
|
||||
src/styles/ design tokens + base/shell/components/pages CSS
|
||||
tests/e2e/ Playwright specs + fixture-backed API mock
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user