2026-06-15 09:59:40 -03:00
# Architecture Plan — SeaHaven (Selective Rebuild)
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
> Aligned with IrisLoan.Admin · Vite SPA + React Router · **no Next.js** · Tailwind + MUI
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
Mirror document of the Cursor plan. Strategy: **reuse knowledge, discard legacy code** — do not normalize/refactor the current project.
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
## Strategy in one sentence
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
Build `api/` + `domain/` + `app/` from scratch; use `pages/` only as **endpoint and business rule reference** ; **delete** each legacy folder when the new feature is ready.
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
## Matrix: Keep vs Discard
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
### Keep (extract logic → new code)
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
| Legacy | Keep | Destination |
| ------------------------------------- | -------------------------------- | ------------------------------------------------ |
| `lib/api/services.js` | ASP.NET paths + response parsing | `api/api-paths.ts` , `api/handle-api-response.ts` |
| `pages/*/api.js` | Real endpoints | `api/api-paths.ts` |
| `constants/queryKeys.js` | Entities | `infra/query-key/query-key.ts` |
| `hooks/useDebounce.js` , `useModal.js` | Hooks | `hooks/*.ts` |
| `hooks/api/usePMSchedules.js` | RQ pattern | Template `domain/*/use-cases/` |
| `lib/queryClient.js` | Cache defaults | `lib/query/query-client.ts` |
| `App.js` , `Sidebar.js` | Routes and menu | `app/routes.tsx` , `config/menu.ts` |
| `pages/workorders/` (list) | Business flow | Reference for POC |
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
### Discard (delete without refactoring)
2026-06-12 11:41:07 -03:00
- `apiUtil.js` , `services/api.js` , `lib/api/client.js`
- `tokenUtility.js` , `authService.js` , Redux (`app/store.js` , slices)
2026-06-15 09:59:40 -03:00
- `usePaginatedList.js` , entire `pages/` folder (after replacement)
- `Site.Layout.js` , `setupProxy.js` , `site.css` , per-feature CSS, Font Awesome
- Forms `*FormPage.js` (rewrite with RHF + Zod)
- `SharedTable.js` , `ActionBar.js` (recreate if adapting is costly)
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
### Defer (later)
2026-06-12 11:41:07 -03:00
- `pages/vendor-portal/` → `domain/vendor-portal/`
2026-06-15 09:59:40 -03:00
- `pages/calendar/` → new FullCalendar wrapper
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
## Feature priority
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
Full matrix (waves, dependencies, LOC, done criteria): ** [`FEATURE_PRIORITIZATION.md` ](FEATURE_PRIORITIZATION.md )** · TS config: [`src/config/feature-priorities.ts` ](../src/config/feature-priorities.ts ).
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
| Wave | Scope |
2026-06-12 11:41:07 -03:00
| ----------------- | --------------------------------------------------------------------------- |
| **0 POC** | auth → work-orders (list) |
| **1 must-have** | work-orders (full), dashboard, settings/dropdowns |
| **2** | accounts, locations, employees |
| **3 should-have** | vendors, vendor-pos, uplifts, follow-ups, contacts, settings/task-templates |
| **4 later** | calendar, vendor-portal, pm-schedules, assets, reports/documents |
2026-06-15 09:59:40 -03:00
Stakeholder decision: **auth + work-orders first** ; POC = auth + work-orders list (not pm-schedules).
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
## Target structure
2026-06-12 11:41:07 -03:00
```
src/
├── api/
├── domain/< feature > /
├── infra/query-key/
├── lib/
├── components/ui/ + common/
├── app/
├── config/menu.ts
├── hooks/
├── providers/
└── main.tsx
```
---
2026-06-15 09:59:40 -03:00
## Phases
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
| Phase | Goal |
| ----- | ------------------------------------------------------------------------------------- |
| **0** | Complete foundation (Ky, routes, layout, AuthProvider, tooling) — Vite/TS/Tailwind ok |
| **1** | Ky + httpOnly auth cookies; delete legacy HTTP stacks |
| **2** | Rewrite must-have features; delete `pages/<feature>/` per delivery |
| **3** | UI shell + RHF+Zod forms |
| **4** | Remove `pages/` , Redux, legacy CSS; Docker + CI + Vitest |
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
## Next steps
2026-06-12 11:41:07 -03:00
2026-06-15 09:59:40 -03:00
1. Complete foundation (`api/api.ts` , `routes.tsx` , AuthProvider, layout shell)
2. `api/api-paths.ts` (extract from `lib/api/services.js` )
2026-06-12 11:41:07 -03:00
3. POC: `domain/auth` + login → delete `pages/auth/`
2026-06-15 09:59:40 -03:00
4. POC: `domain/work-orders` (list) → delete list portion of `pages/workorders/`
5. Cookie contract with backend
2026-06-12 11:41:07 -03:00
---
2026-06-15 09:59:40 -03:00
See full plan with diagrams in `.cursor/plans/migração_arquitetura_irisloan_cf39e1a6.plan.md` .