Skip to content

Extract DB module to phoenix_kit_db package; remove dead PagesHTML - #518

Merged
ddon merged 4 commits into
BeamLabEU:devfrom
mdon:feat/extract-db-module
May 6, 2026
Merged

Extract DB module to phoenix_kit_db package; remove dead PagesHTML#518
ddon merged 4 commits into
BeamLabEU:devfrom
mdon:feat/extract-db-module

Conversation

@mdon

@mdonmdon commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Two cleanups in core, both part of the lib/modules/* extraction direction:

  1. DB module extraction — `lib/modules/db/` is now a standalone PhoenixKit plugin package (`phoenix_kit_db`, separate repo). Hosts pull it in via `{:phoenix_kit_db, "~> 0.1"}`; auto-discovery + `admin_tabs/0` wires up the routes — no hand-registration in core needed.
  2. Dead PagesHTML removal — `PhoenixKitWeb.PagesHTML` had no callers, no controller, no route. The `embed_templates` directive plus `pages_html/show.html.heex` plus the `integration.ex` docstring described a markdown-page-rendering feature that was never wired up. Publishing module covers actual CMS-page rendering.

The companion DB module repo is in flight on the boss's side; this PR is the core-side cleanup and can ship independently — the DB explorer route registration is now done by the external module via `admin_tabs/0` once the package is installed.

Commits

  • `6b5badb4` — Remove DB module — extracted to phoenix_kit_db package (the surgical lift: drop `PhoenixKit.Modules.DB` from `internal_modules/0`, drop the three hand-registered `live` declarations, drop the hardcoded DB module card from `modules.html.heex`, delete `lib/modules/db/` entirely — 8 files).
  • `3a859a25` — Update internal-modules tests after DB extraction (drop `PhoenixKit.Modules.DB` from `@all_internal_modules` in `module_test.exs` and the `expected` list in `module_registry_test.exs`; lower three `>= 8` count assertions to `>= 7`).
  • `c42fb797` — Update module-system guide reference table after DB extraction (move `lib/modules/db/db.ex` reference from the Internal examples section to External as `phoenix_kit_db/` between hello_world and document_creator — sits naturally between them as a small-footprint plugin with a Postgrex.Notifications GenServer child + multi-page admin tabs).
  • `559f86df` — Remove dead PagesHTML module (delete `pages_html.ex` + `pages_html/show.html.heex`; trim the "Public pages routes" docstring block in `integration.ex`).

Verification

  • `mix compile --warnings-as-errors`: clean.
  • `mix format --check-formatted`: clean.
  • `mix credo --strict`: 0 issues across 514 files; module count drops 7204 → 7202 (one removed for DB, one for PagesHTML).
  • `mix test`: 1055 tests, 4 failures — all in `V107Test` (AI endpoint `integration_uuid` backfill); pre-existing on `dev` before this branch (verified by stashing my changes and re-running). Unrelated to this PR.

Stale-ref grep — both removals

```
ast-grep --lang elixir --pattern 'PhoenixKit.Modules.DB' lib/ test/ # zero
ast-grep --lang elixir --pattern 'PhoenixKitWeb.PagesHTML' lib/ test/ # zero
rg -n 'db_explorer|/admin/db' lib/ # zero (besides the
# auth.ex:997 best-path
# map entry, kept by
# design — same shape
# as the also-external
# phoenix_kit_ai entry)
rg -n 'PagesHTML|PagesController|pages_html' lib/ test/ dev_docs/ guides/ # zero
```

The four hits in `dev_docs/{guides,plans,audits}/` for `lib/modules/db` are point-in-time PR reviews / plans / audits — historical artifacts, left untouched per the workspace reviewer-artifact convention. The single living guide reference (`module-system-guide.md`) was updated in commit `c42fb797`.

Test plan

  • `mix compile --warnings-as-errors` clean
  • `mix format --check-formatted` clean
  • `mix credo --strict` zero issues
  • `mix test`: 1055 tests, only the 4 pre-existing V107 failures (unrelated to this PR)
  • 3x `mix test` stability runs — same 4 V107 failures on each, no flakes introduced
  • `ast-grep` confirms zero structural references to either removed module

mdon added 4 commits May 6, 2026 20:32
The DB explorer module is now a standalone PhoenixKit plugin
(github.com/BeamLabEU/phoenix_kit_db). Hosts that want it pull it in
via:
{:phoenix_kit_db, "~> 0.1"}
Auto-discovery + admin_tabs/0 wires up the routes; no hand-registration
in core needed.
Changes:
- Drop PhoenixKit.Modules.DB from internal_modules/0 in
module_registry.ex.
- Drop hand-registered /admin/db, /admin/db/activity, and
/admin/db/:schema/:table live declarations from integration.ex.
- Drop the hardcoded DB module card from modules.html.heex; the
external module renders its own card via the auto-discovered
"External" section.
- Delete lib/modules/db/ entirely (db.ex + listener.ex + 6 web files).
The previous commit removed PhoenixKit.Modules.DB from
internal_modules/0 in module_registry.ex and deleted the lib/modules/db
tree, but two test files still hardcoded the module:
- test/phoenix_kit/module_test.exs — @all_internal_modules list
- test/phoenix_kit/module_registry_test.exs — `expected` list +
three "registered count >= 8" assertions
Drop PhoenixKit.Modules.DB from both lists and lower the count
floors from 8 to 7 to match the new internal-module count.
ast-grep --lang elixir --pattern 'PhoenixKit.Modules.DB' returns zero
hits across lib/ + test/ after this change. The single
{"db", "/admin/db"} entry in lib/phoenix_kit_web/users/auth.ex:997's
best-available-admin-path map stays as-is — same shape as the also-
external phoenix_kit_ai's {"ai", "/admin/ai"} entry, gated at runtime
by enabled_module_keys/0.
Verification
- mix compile --warnings-as-errors clean
- mix format --check-formatted clean
- mix credo --strict: 0 issues
- 1055 tests, 4 failures — all in V107Test (AI endpoint
integration_uuid backfill); pre-existing on dev, unrelated to
this extraction.
The "Reference Files" table at the end of dev_docs/guides/
2026-02-24-module-system-guide.md cited lib/modules/db/db.ex as the
canonical "Supervisor child and admin tab" example. Now that the
module is external (phoenix_kit_db package), move the reference into
the External examples section between hello_world (minimal) and
document_creator (full-featured) — phoenix_kit_db sits naturally
between them as a small-footprint plugin with a Postgrex.Notifications
GenServer child + multi-page admin tabs.
Other dev_docs hits for "lib/modules/db" are point-in-time PR reviews,
audits, and plans — historical artifacts, left untouched per the
workspace reviewer-artifact convention.
Verification
- mix compile clean
- mix format --check-formatted clean
- mix credo --strict: 0 issues
- ast-grep --lang elixir --pattern 'PhoenixKit.Modules.DB' returns
zero hits across lib/ + test/.
PhoenixKitWeb.PagesHTML had no callers anywhere — no controller, no
route, no test. The module embedded a single show.html.heex template
that read @html_content / @page_title assigns nothing was setting,
and integration.ex's docstring described /pages/* and root catch-all
routes that don't exist.
Verification before deletion:
- ast-grep --lang elixir --pattern 'PhoenixKitWeb.PagesHTML' returns
only the module's own definition.
- ripgrep for /pages/* routes finds only doc-example strings inside
modules/sitemap/route_resolver.ex (illustrative, not real refs)
and the now-removed integration.ex docstring.
- priv/static/pages/ doesn't exist; the markdown source dir the
template was meant to render from was never created.
- Two guides (custom-admin-pages.md, making-pages-live.md) are about
custom admin LiveViews and PubSub-driven real-time, both unrelated
to this dead markdown-renderer.
- The publishing module (phoenix_kit_publishing) covers actual
CMS-page rendering, which is presumably why this never got wired
up.
Removed:
- lib/phoenix_kit_web/controllers/pages_html.ex
- lib/phoenix_kit_web/controllers/pages_html/show.html.heex
- The "Public pages routes (if Pages module enabled)" docstring
block in integration.ex.
Verification after
- mix compile --warnings-as-errors clean (61 files recompiled).
- mix format --check-formatted clean.
- mix credo --strict: 0 issues; 7203 -> 7202 mods/funs (exactly the
one removed module).
- 1055 tests, 4 failures — same V107Test (AI endpoint backfill)
pre-existing on dev. Test count unchanged → no test was tied to
the dead module.
@ddon
ddon merged commit a92a036 into BeamLabEU:devMay 6, 2026
ddon added a commit that referenced this pull request May 8, 2026
Eight post-merge reviews covering V111 PDF tables, the DB-module
extraction, MediaBrowser modal + LV login return_to, external-plugin
admin permissions, dashboard sidebar gettext, live Hex.pm known-packages
fetch, the publishing routing-strategy shim, and the LanguageSwitcher
per_translation_urls attr (plus the bundled DnD work).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon added a commit that referenced this pull request May 8, 2026
…525
Code/doc fixes addressing one finding per PR (or several where
trivial). Each closes a NITPICK or IMPROVEMENT-LOW from the
matching CLAUDE_REVIEW.md; design-level / breaking / risky items
deferred per the FOLLOW_UP.md "Skipped" sections.
- #516: Drop dead `String.to_atom` fallback in OAuth interpolate_url
- #518: Delete stray 0-byte pages_html.ex
- #519: Fix stale `viewer={true}` template comment + login_path
trailing-slash self-loop guard
- #521: Resolution-order doc on permission_key_for_admin_view/1
- #522: Hot-reload safety pitfall in per-module-i18n.md
- #523: KnownPackages — max-pages cap, ensure_table race comment,
Logger-levels operational signals in moduledoc
- #524: __mix_recompile__?/0 note next to apply/3 explanation
- #525: LanguageSwitcher attr doc atom/string keys + DRY resolve_url
per-language + JS sortable:flash defensive status check
Plus FOLLOW_UP.md per PR enumerating closed vs deferred items.
PR #525's FOLLOW_UP also captures the bundled DnD audit trail
(table_default drag-handle scoping, sortable:flash, TR cell-width
preservation) absent from the original PR body.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon added a commit that referenced this pull request May 8, 2026
Three-day window of accumulated work since 1.7.105 (2026-05-05):
PRs #516, #518, #519, #521, #522, #523, #524, #525, plus the
review-doc suite and post-merge triage closing nitpicks across all
eight.
Headline changes — V111 PDF library tables, DB module extracted to
phoenix_kit_db, MediaBrowser modal viewer, sidebar gettext API, live
Hex.pm catalog, publishing routing-strategy shim closing the
/:locale/<literal>/... host-route shadowing bug, LanguageSwitcher
:per_translation_urls, and bundled DnD improvements (drag-handle
scoping, sortable:flash, TR cell-width preservation).
All changes are strictly additive / non-breaking; one transitional
extraction (DB → phoenix_kit_db) requires the paired Hex package
once it ships.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for freeto 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

@mdon@ddon