This document outlines the step-by-step execution plan to refactor the LinkLift frontend to a Hexagonal Architecture, as described in FRONTEND_ARCHITECTURE_REFACTOR_PLAN.md.
Goal: Enable TypeScript, set up the build system, and establish the core architectural plumbing.
- 1.1. Install TypeScript Dependencies
- Install
typescript,@types/react,@types/react-dom,@types/node,@babel/preset-typescript. - Install
ts-loaderor configurebabel-loaderfor TS.
- Install
- 1.2. Configure Build System
- Create
webapp/tsconfig.json. - Update
webapp/webpack.config.jsto handle.tsand.tsxfiles. - Smoke test: Rename
src/index.jstosrc/index.tsxand verify build.
- Create
- 1.3. Setup State Management (Zustand)
- Install
zustand. - Create
src/application/state/store.ts(store foundation).
- Install
- 1.4. Setup Dependency Injection
- Create
src/application/di-container.tsfor strictly typed dependency injection.
- Create
Goal: Refactor the "Add Link" feature to prove the architecture pattern.
- 2.1. Domain Layer (Business Logic)
- Create
src/domain/models/Link.ts(Domain Entity). - Create
src/domain/ports/ILinkRepository.ts(Output Port Interface). - Create
src/domain/usecases/AddLinkUseCase.ts(Input Port/Interactor).
- Create
- 2.2. Application Layer (Adapters)
- Create
src/infrastructure/api/axios-instance.ts(Low-level HTTP client). - Create
src/application/services/ApiLinkRepository.ts(Adapter Implementation). - Update
di-container.tsto register the new service and use case. - Create
src/application/state/linkSlice.tsto manage link state.
- Create
- 2.3. Infrastructure Layer (UI Refactor)
- Create
src/infrastructure/ui/hooks/useLinks.ts(Glue code: DI + Store + UI). - Refactor
src/components/AddLink.js->src/infrastructure/ui/components/AddLink.tsx(Dumb Component). - Update the parent view to use
useLinksand wire up the component.
- Create
Goal: Migrate the main data fetching logic.
- 3.1. Domain & Application Updates
- Update
ILinkRepositorywithgetAll(): Promise<Link[]>. - Create
src/domain/usecases/GetLinksUseCase.ts. - Implement
getAllinApiLinkRepository. - Update
linkSliceto store the list of links.
- Update
- 3.2. UI Integration
- Update
useLinks.tsto exposelinksandloadingstate. - Refactor the main content view (e.g.,
ContentViewer.jsorApp.jslogic) to consumeuseLinksinstead of localuseEffect.
- Update
Goal: Complete the migration and remove legacy code.
- 4.1. Refactor Delete Functionality
- Add
deleteto Repository, Use Case, and Store. - Wire up to UI.
- Add
- 4.2. Refactor Content Viewing
- Ensure content viewing logic uses the clean architecture flow.
- 4.3. Cleanup
- Remove old
src/services/api.js. - Remove unused React Contexts (if replaced by Zustand).
- Ensure all new files are in the proper
domain/application/infrastructurestructure.
- Remove old