Skip to content

Refactoring structure of the UI app - #102

Merged
Pan14ek merged 8 commits into
mainfrom
feature/refactor-lined-web-with-es6
Jul 18, 2026
Merged

Refactoring structure of the UI app#102
Pan14ek merged 8 commits into
mainfrom
feature/refactor-lined-web-with-es6

Conversation

@Pan14ek

@Pan14ek Pan14ek commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Purpose

Type

  • 🧪 Experiment (fitness function research)
  • ✨ Feature (new business logic)
  • 🐛 Bug fix
  • ♻️ Refactor / neutral change
  • 📝 Documentation only

Changes

Files changed

File Change

Expected result

Metric Baseline (main) Branch Direction
checkstyle_violations
spotbugs_total
line_coverage
critical_violations
code_smells
duplicated_lines_density
F score
SonarQube QG

Checklist

  • ./gradlew check passes locally
  • ./gradlew jacocoTestReport passes locally
  • No unintended changes to main business logic
  • Branch name matches experiment/feature naming convention

Pan14ek added 8 commits July 18, 2026 22:34
Each feature now owns its DTOs under features/{feature}/model/index.ts
instead of a single central src/types/index.ts, so a feature's data
shape lives next to the code that uses it.
Each feature owns its API surface under features/{feature}/api/:
prod.ts (real ky requests, moved from src/api/*), dev.ts (in-memory
mocks derived from the existing MSW fixtures), and index.ts, which
picks one based on VITE_USE_MOCKS. Mock data and MSW request handlers
used by tests move alongside as mockData.ts and handlers.ts.

Adds MockHttpError/getErrorStatus/mockDelay to lib/apiClient.ts so
error-status checks in apiErrors.ts work uniformly against both a
real ky HTTPError and a mocked one.
Feature-specific TanStack Query hooks move from src/hooks/ into
features/{feature}/hooks/, updated to call each feature's own api/
module. The generic, domain-agnostic hooks (useDebouncedValue,
useFormState, useRowMutationState, useOptimisticPatchMutation) stay
shared in src/hooks/ and are converted to arrow functions.
calendarUtils/freeSlots -> features/calendar/lib, taskUtils ->
features/tasks/lib, subscriptionUtils -> features/subscription/lib.
constants.ts (lobby-type styling, task-status/priority labels, and
the QUERY_KEYS cache-key registry) is split the same way, with each
feature keeping its own QUERY_KEYS object so call sites didn't need
renaming, only their import path. src/lib/ now holds only the truly
cross-feature infra: apiClient, apiErrors, and the cn() class-merge
helper.
Moves every domain component and route page out of the flat
src/components/ and src/pages/ trees into feature-owned folders under
src/features/{feature}/ (auth, calendar, dashboard, layout, lobby,
notifications, settings, subscription, tasks), grouping each
feature's larger component sets into topic subfolders (e.g.
calendar/grid, calendar/events, lobby/members, lobby/settings,
tasks/kanban) with colocated __tests__.

Introduces a new `users` feature for the cross-cutting UserDto/user
lookup surface used by auth, lobby, tasks, and calendar.

Truly shared, non-domain components stay in src/components/
(AssigneeAvatar, ConfirmDialog, EmptyState, FormField, ToggleRow, and
the shadcn-owned components/ui/), each now in its own folder as
index.tsx + __tests__/.

All `function` declarations were converted to arrow-function consts
(ES6 style) as part of this move, including in components/ui/*.

router.tsx, App.tsx, and main.tsx updated for the new import paths.
CLAUDE.md's documented conventions updated to match (route files now
live in src/features/{feature}/pages/).
Adds positive/negative coverage for every component and lib/util file
that didn't already have a test: AssigneeAvatar, SettingsRow,
SettingsCard, TopBar, DashboardHero, KanbanFilters, KanbanColumn,
TasksPage, SearchResultRow, SearchResultsList, MemberListContent,
PendingInvitesSection, LobbyLoadStates, LobbyCard, plus lib/utils.ts,
lib/apiClient.ts, subscriptionUtils.ts, kanbanConstants.ts, and every
feature's lib/constants.ts (QUERY_KEYS shape/uniqueness, lookup-map
completeness against their enum, and any pure functions like
lobbyAccentColor).
…esting conventions

Adds three docs, written from this session's full-repo refactor
(layer-first -> feature-first: components/pages into src/features/,
types into per-feature model/, API split into per-feature prod/dev/index,
hooks and lib split the same way):

- docs/ARCHITECTURE.md: the feature-folder concept, the
  shared-vs-feature-owned ownership rule, the api/{prod,dev,index}.ts
  mock-switch pattern and how it relates to the existing MSW/
  VITE_ENABLE_MSW mocking layer, and a summary of the refactor steps
  that produced this structure.
- docs/PROJECT_STRUCTURE.md: the concrete directory layout, when to
  group a feature's components into a topic subfolder, and import-path
  rules.
- docs/TESTING.md: where tests live, the "every component/util file
  needs positive + negative coverage" rule, and conventions
  (renderWithProviders, MSW over mocking ky, expect.assertions, query
  priority).

Links these from lined-web/AGENTS.md and lined-web/CLAUDE.md as
required reading before writing code, and fixes stale references to
the old flat src/api|hooks|types|components layout in both files and
in the root AGENTS.md/CLAUDE.md.
@Pan14ek
Pan14ek merged commit caba2d5 into main Jul 18, 2026
1 check failed
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant