Skip to content

refactor(server): split code_health router into a package#724

Merged
RaghavChamadiya merged 1 commit into
mainfrom
split/code-health-router-package
Jul 8, 2026
Merged

refactor(server): split code_health router into a package#724
RaghavChamadiya merged 1 commit into
mainfrom
split/code-health-router-package

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

What

The code-health router had grown to ~1088 lines: 13 route handlers plus roughly 30 serializers, aggregation helpers, score-breakdown logic, badge rendering, and async DB loaders in one module.

This splits it into a code_health/ package where the shared APIRouter lives in _router.py and the routes are grouped by resource (overview, findings, files, trends, coverage, refactoring-targets, churn, badge), backed by leaf helper modules (serializers, aggregation, breakdown, loaders).

Why

Route handlers grouped by resource, with pure serialization/aggregation helpers factored into their own leaf modules, are far easier to navigate than one 1000+ line router.

Safety

Pure structural move: every symbol relocates verbatim and lazy imports stay function-local. __init__.py imports the route modules for their decorator side-effects and re-exports the helpers that routers/files.py and the tests import, so the public path repowise.server.routers.code_health still resolves router and all helpers unchanged. app.include_router(code_health.router) needs no edit.

Verified: the package exposes all 13 routes and they register on the app; the server health test suites (37 tests) pass.

The code-health router had grown to ~1088 lines: 13 route handlers plus
about 30 serializers, aggregation helpers, score-breakdown logic, badge
rendering, and async DB loaders in one module.

Split it into a code_health/ package where the shared APIRouter lives in
_router.py and the routes are grouped by resource (overview, findings,
files, trends, coverage, refactoring-targets, churn, badge), backed by
leaf helper modules (serializers, aggregation, breakdown, loaders).

Pure structural move: every symbol relocates verbatim, lazy imports stay
function-local, and __init__.py imports the route modules for their
decorator side-effects and re-exports the helpers that routers/files.py
and the tests import, so the public path repowise.server.routers.code_health
still resolves router and all helpers unchanged.
@RaghavChamadiya RaghavChamadiya requested a review from swati510 as a code owner July 8, 2026 09:32
@repowise-bot

repowise-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
9 new findings introduced.

🚨 Change risk: high (riskier than 88% of this repo's commits · raw 9.7/10)
This change's risk is driven by:

  • more lines added than baseline
  • more scattered than baseline

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-08 09:32 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@RaghavChamadiya RaghavChamadiya merged commit fc66771 into main Jul 8, 2026
7 checks passed
@RaghavChamadiya RaghavChamadiya deleted the split/code-health-router-package branch July 8, 2026 09:36
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