Skip to content

Refactor/dashboard feature structure - #348

Merged
El-swaggerito merged 3 commits into
Axionvera:mainfrom
D240021:refactor/dashboard-feature-structure
Jul 29, 2026
Merged

Refactor/dashboard feature structure#348
El-swaggerito merged 3 commits into
Axionvera:mainfrom
D240021:refactor/dashboard-feature-structure

Conversation

@D240021

@D240021 D240021 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Restructures the dashboard around explicit feature folders and a clear shared-component
boundary. Domain UI, shared primitives and the app shell previously sat intermixed under
src/components/, which made it hard to tell what was reusable and what belonged to a
single screen.

Every domain component now lives in src/features/<domain>/components/ and is consumed
through an index.ts barrel, so a feature exposes a deliberate public API instead of deep
file paths. src/components/ keeps only genuinely shared code, split into ui/
(presentational primitives), layout/ (the app shell, the one sanctioned composition root
that may import features) and errors/ (error boundaries). All 51 moves were made with
git mv to preserve file history.

The change is structural: no component logic, props or rendered output were altered.

Two duplications tracked in the cleanup checklist are resolved along the way:

  • Duplicate /governance routesrc/pages/governance/index.tsx rendered a mock
    governance stack that shadowed the real wallet-connected page at src/pages/governance.tsx.
    The mock route and its supporting files (GovernanceDashboard.tsx, governanceModel.ts,
    proposals.ts, types.ts) are removed; the on-chain Proposal type in
    utils/contractHelpersGovernance is now the single governance domain type.
  • Two components named AnalyticsDashboard — they were never the same thing. The
    hooks-based one keeps its name and stays wired into the widget registry; the
    service-layer one that takes an address and fetches a period report is renamed
    AnalyticsReportPanel. Both now live in features/analytics/components/.

It also fixes a case collision between docs/ARCHITECTURE.md and docs/architecture.md.
Git tracked both, which is unrepresentable on case-insensitive filesystems and produced
phantom modifications on Windows checkouts; only the lowercase file remains.

Diff shape: 51 renames, 37 modifications, 11 additions, 10 deletions across 109 files.

Closes #331

Type of change

  • feat/ — new feature or enhancement
  • fix/ — bug fix
  • docs/ — documentation
  • refactor/ — restructuring, no logic change
  • chore/ — maintenance or dependencies

Quality gates

See CONTRIBUTING.md.

  • npm run lint passes
  • npm run typecheck passes — 4 pre-existing errors remain, all in
    tests/hooks/useVault.test.ts, untouched by this PR (see notes)
  • npm test passes — 100 of 101 suites pass (655 tests); the same
    tests/hooks/useVault.test.ts fails for the same pre-existing reason

Cleanup checklist

Confirm against docs/dashboard-cleanup-checklist.md.

  • Structure — no new top-level src/ folder; no near-synonym folder added. The
    logic/UI split is respected: src/<domain>/ keeps domain logic and
    features/<domain>/components/ holds that domain's UI.
  • Reuse — every moved component was grepped for before relocating. New UI has one
    home (features/ for domain UI, components/ for shared) and is exported through
    its index.ts barrel.
  • API — no fetch() added or moved; the API layer is untouched by this PR.
  • State — no state library, store or context added. Governance now reuses the
    existing on-chain Proposal type instead of the parallel mock type that was removed.
  • Tests — structural checks live in tests/baseline.test.ts. One suite was deleted
    because its subject no longer exists, not to make CI pass (see notes).
  • Docs — the new docs/structure.md documents the layout rules; the README
    structure table, component table and route table are updated, as are docs/ANALYTICS.md,
    docs/RBAC.md and the cleanup checklist.

Notes for reviewers

A deleted test suite, called out explicitly. tests/components/GovernanceDashboard.test.tsx
is removed because the component it exercised (the mock GovernanceDashboard) is removed
with the duplicate route. The suite only asserted against hardcoded mock proposals, so
there is no behaviour left to cover. No test was deleted or skipped to get CI green.

tests/baseline.test.ts now contains 20 real assertions. It previously held a
placeholder expect(true).toBe(true) so the empty suite would not fail. It now encodes the
rules in docs/structure.md as fitness functions: no loose files directly under
src/components/, shared components may not import from features/, features are consumed
through barrels, and no two page files resolve to the same route. These fail if the layout
regresses.

Merged with #347 rather than rebased. #347 landed while this work was in progress and
rewrote AnalyticsMetrics.tsx and GovernanceStats.tsx, both of which this PR moves. Git's
rename detection applied those rewrites onto the new paths, and the two genuine conflicts
were resolved in favour of the newer code: GovernanceStats keeps the shared MetricCard
primitive from #347. A rebase was deliberately avoided because replaying onto that tree
requires checking out both casings of the architecture doc at once.

One real integration fix. #347 added a jest.mock targeting
@/features/search/GlobalSearch, a path this PR moves. The mock now intercepts the
@/features/search barrel, which is what Navbar actually imports.

Suggested follow-up, out of scope here. tests/hooks/useVault.test.ts calls
useVault({ walletAddress }) while the hook takes no arguments, having moved to a
context-based API. That accounts for all 4 remaining type errors and all 4 remaining test
failures. Neither this PR nor #347 touches the hook, its context or the test, and it is
worth its own issue rather than an unrelated drive-by fix here.

I remain open to any corrections or feedback you may have.

D240021 and others added 3 commits July 29, 2026 11:36
Integrates Axionvera#347 (shared MetricCard primitive) with the feature-folder refactor. The rewritten AnalyticsMetrics and GovernanceStats land on their new paths under features/, and baseline.test.ts keeps the structural regression suite instead of the placeholder assertion.

Co-authored-by: Cursor <cursoragent@cursor.com>
The mock added in Axionvera#347 targeted the pre-refactor path. Navbar imports GlobalSearch from the @/features/search barrel, so the mock has to intercept that module.

Co-authored-by: Cursor <cursoragent@cursor.com>
@El-swaggerito
El-swaggerito merged commit 8fe3027 into Axionvera:main Jul 29, 2026
1 check 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.

Refactor Axionvera dashboard feature folder structure

2 participants