This file tracks architectural debt, pending refactors, and "nice-to-have" improvements that we've identified but haven't yet implemented.
-
Implement IFileSystem Interface (ADR-004)
- Create
src/lib/filesystem/interface.ts. - Refactor
EngineManager,StaticEngine, andNextjsEngineto use this interface instead offs/promises. - Create
NodeFileSystemimplementation.
- Create
-
Implement Command Pattern (ADR-005)
- Create
Commandinterface. - Refactor
editor-script.tsto dispatch commands. - Create a Command Manager to handle Stack (Undo/Redo).
- Create
-
Migrate Schemas to tRPC Routers
- Convert
src/lib/schemasto Zod schemas insrc/server/api/routers.
- Convert
-
Refactor Editor Engine to use IFileSystem
- Abstract Editor file operations behind
IFileSystem. - Create
NodeFileSystemimplementation.
- Abstract Editor file operations behind
-
Migrate Project Persistence to Database (Critical for Serverless/Vercel)
- Context: Currently, projects are stored as folders on disk (
src/lib/storage.ts). This fails on Vercel (ephemeral filesystem) and is slow to query. - Goal: Move project metadata and content-reference to Postgres.
- Steps:
- Create
ProjectandPagemodels inprisma/schema.prisma. - Update
src/lib/storage.tsto query Prisma instead offs.readdir. - Update
src/server/api/routers/project.tsto write to DB. - (Optional) Store actual page content in DB or S3, instead of local JSON files.
- Create
- Context: Currently, projects are stored as folders on disk (
-
Refactor Editor State Management (Performance & Stability)
- Goal: Move away from React Context for high-frequency editor state.
- Steps:
- Install
zustandandxstate. - Migrate
EditorContext(currently inpage.tsxor similar) to a Zustand store. - Implement XState machine for the "Drag & Drop" logic (Idle -> Dragging -> Dropped).
- Connect XState to update Zustand.
- Install
-
Refactor Legacy State to tRPC Mutations
- Context: Some components (like
ticket-window.tsx) still use manualuseStatefor loading/error/success states. - Action: Replace
useStatelogic with tRPC's nativeisPending,isSuccess,isErrorflags. - Target Components:
TicketWindow,PropertiesPanel,SaveStatus.
- Context: Some components (like
-
Delete Legacy API Routes (T3 Migration)
- Context: T3 uses tRPC. Next.js API Routes (
src/app/api) are legacy. - Action: Audit
src/app/api, port logic tosrc/server/api/routers, and DELETE the implementation folders.
- Context: T3 uses tRPC. Next.js API Routes (
-
Component Standardization
- [Placeholder: Check after exploring components]
-
Documentation & Type Audit (Agent-Friendly)
- Goal: Ensure all public boundaries have explicit types and JSDoc to facilitate AI reasoning.
- Target Files:
src/server/api/routers/project.ts(API Contracts)src/lib/engine-manager.ts(Core Logic)src/lib/storage.ts(Data Access)src/lib/utils.ts(Shared Utils)
- Action: Add JSDoc with @param/@returns and explicit TS return types.
-
Standardize Error Handling (UX & Security)
- Goal: Implement the Three-Tier Error Strategy.
- Steps:
- Install
react-hot-toast(or similar). - Create a
TRPCLoggerMiddlewareto catch/log server errors before sendingTRPCError. - Refactor
src/server/api/routers/*to ensure no raw errors are thrown. - Update frontend mutations to use
toast.error(e.message).
- Install