Skip to content

feat: add web admin console for managing hypergraph databases - #12

Merged
yifanfeng97 merged 2 commits into
iMoonLab:mainfrom
yuxizhe:feat/admin-console
Oct 16, 2026
Merged

yifanfeng97 merged 2 commits into
iMoonLab:mainfrom
yuxizhe:feat/admin-console

Conversation

@yuxizhe

@yuxizhe yuxizhe commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a browser-based admin console for Hypergraph-DB. The existing visualization (hg.draw()) is read-only; the console also lets you change data and inspect the database.

hg.admin()  # http://127.0.0.1:8900

Admin console overview

Features

  • Overview dashboard: counts of vertices and hyperedges, average and maximum degree and hyperedge size, isolated vertices, degree and hyperedge size distributions, top vertices, entity types, and attribute keys. The histograms use a log scale (on by default) and geometric buckets so long-tailed data stays readable.
  • Vertices and hyperedges: paginated tables with search, entity-type filtering and sorting. When searching, vertices whose ID matches come before attribute-only matches.
  • Create, edit and delete: a JSON attribute editor with live validation. Delete follows remove_v() semantics.
  • HIF import and export, plus an explicit Save to the .hgdb file. Edits stay in memory until saved, and the page warns before you leave with unsaved changes.
  • Embedded graph viewer: the viewer now accepts ?vertex=<id>, so a vertex's detail view links straight to its graph.
  • Chinese and English UI with an EN / 中文 switch. The choice is remembered per browser, and the first visit follows the browser language.
  • JSON REST API under /api/admin/*, which the UI uses and scripts can call too.

Implementation

  • hyperdb/admin.py: HypergraphAdminHandler extends the existing HypergraphAPIHandler, so the viewer endpoints keep working at /viewer. It uses only the standard library. The server is single-threaded on purpose, since HypergraphDB is not thread-safe.
  • hyperdb/templates/admin.html: a single-page app in the same React + Tailwind (CDN) stack as the viewer, with library versions pinned.
  • BaseHypergraphDB.admin(port=8900, open_browser=True, blocking=True, host="127.0.0.1").

Other changes

  • draw.py: /api/graph now resolves non-string vertex IDs. Query parameters are always strings, so vertices with int IDs could never be shown in the viewer before.
  • Viewer: the cluster attribute is now hidden in the detail panel.

Notes

  • The console has no authentication. It binds to 127.0.0.1 by default, and the README says so.
  • Found while building this (not changed here): HypergraphDB.nbr_v() raises KeyError for isolated vertices, because it removes v_id from an empty set. The console works around it.

Test plan

  • tests/test_admin.py: 8 tests against a live server on an ephemeral port, covering pages, info and stats, listing and search ranking, vertex and hyperedge CRUD (merge vs. replace, 404/409/400), save round-trip, HIF import and export, bad requests, and non-string IDs in the viewer API.
  • Full suite: 30 passed. black, isort and flake8 are clean.
  • Manually tested in Chrome on sanguo.hgdb (4.3K vertices) and neurology.hgdb (25K vertices; list and stats API calls take 0.06–0.15s).

🤖 Generated with Claude Code

yuxizhe and others added 2 commits October 16, 2026 14:02
Add a browser-based admin console (`db.admin()`) on top of the existing
viewer server:

- Overview dashboard: counts, degree / hyperedge size distributions
  (log scale, geometric buckets for long tails), top vertices, entity
  types and attribute keys
- Vertex and hyperedge tables with search, filtering, sorting and paging
- Create, edit (JSON attribute editor) and delete vertices and hyperedges
- HIF import / export and explicit save to the .hgdb file
- Embedded graph viewer; the viewer now accepts ?vertex=<id>
- Chinese / English UI switch (remembered per browser)
- JSON REST API under /api/admin

Also make the viewer's /api/graph resolve non-string vertex ids (e.g.
ints), which previously never matched the string query parameter, and
hide the `cluster` attribute in the viewer's detail panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Annotate HypergraphAPIHandler with BaseHypergraphDB (what the viewer
already accepts), and have the admin look up to_hif / from_hif at
runtime, returning 501 for database classes without HIF support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanfeng97
yifanfeng97 merged commit 4f5964e into iMoonLab:main Oct 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants