4.8 KiB
4.8 KiB
Handoff Report — Explorer 1 (Milestone 2: Backend & DB)
1. Observation
I observed the following files and code blocks:
apps/backend/prisma/schema.prisma:- The
Menumodel is defined at lines 638-646:model Menu { id Int @id @default(autoincrement()) name String @unique // e.g., "header", "footer" payload Json? isActive Boolean @default(true) items MenuItem[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } - The
MenuItemmodel is defined at lines 648-658:model MenuItem { id Int @id @default(autoincrement()) menuId Int menu Menu @relation(fields: [menuId], references: [id], onDelete: Cascade) label String url String order Int @default(0) translations MenuItemTranslation[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
- The
packages/types/index.ts:- The
MenuItemtype interface is defined at lines 195-201:export interface MenuItem { id: number label: string url: string order: number translations?: any[] } - The
Menutype interface is defined at lines 203-208:export interface Menu { id: number name: string items: MenuItem[] payload?: any }
- The
apps/backend/src/routes/menus.ts:- Contains endpoints
POST /(line 32),PUT /:name(line 60) for handling and validating menus, utilizing TypeBoxtschema builders. For instance, thePUT /:namevalidator at line 133:body: t.Object({ payload: t.Optional(t.Any()), isActive: t.Optional(t.Boolean()), items: t.Array(t.Object({ id: t.Optional(t.Number()), label: t.String(), url: t.String(), order: t.Number(), translations: t.Optional(t.Array(t.Object({ langCode: t.String(), label: t.String() }))) })) })
- Contains endpoints
apps/mcp-server/menu-tools.ts:- Contains
validateMenuItemshelper function (line 158) verifying URL and order values.
- Contains
apps/mcp-server/menu-toolkit.ts:- Defines MCP tools input schemas, such as
upsert_menu(line 34) and executes the actual HTTP endpoint mutations insidehandleMenuTool(line 196). - MCP tools register dynamically from
MENU_TOOL_DEFINITIONSinapps/mcp-server/index.tsat line 78:...MENU_TOOL_DEFINITIONS,.
- Defines MCP tools input schemas, such as
2. Logic Chain
- Schema Update Strategy: Based on the requirements to add
rootImagetoMenuandcolumnImage/hoverImagetoMenuItem, adding these as optional fields (String?in Prisma, and optional mapping to properties?: string | nullin TypeScript types) ensures they are backward-compatible. - Database Migration Logic: Running
bunx prisma migrate devcompiles the changes into SQL, writes the schema updates, and triggers the Prisma client generation automatically. - Route Request/Response Integration: Since route request payloads are validated using TypeBox
t.Object, the body validators inPOST /andPUT /:namemust be updated to acceptt.Optional(t.Nullable(t.String()))for the new properties. Destructuring, transaction update blocks, and transaction create blocks must maps these fields to Prisma's API parameter targets. - MCP Validation Alignment: Since MCP tools use
validateMenuItemsinternally to check lists of items before putting request payloads,validateMenuItemsmust be updated to inspect the validity ofcolumnImageandhoverImagestrings. The input schemas of MCP tools (likeupsert_menu) must also expose the properties for AI context discovery.
3. Caveats
No caveats. The proposed changes are localized, backwards-compatible, and standard for Elysia/Typebox and Prisma.
4. Conclusion
The database, shared types, API routes, and MCP tools can be modified to safely support optional image properties on menus and menu items.
5. Verification Method
- Prisma Typecheck & Compile:
Run:
Check that typecheck compiles successfully via
cd apps/backend && bunx prisma migrate dev --name add_menu_image_fieldsbunx tsc -p tsconfig.json --noEmitinsideapps/backendandapps/mcp-server. - Type checks on workspace packages:
Ensures
npm run build@homaroma/typestype changes sync across all monorepo modules cleanly. - Run local manual integration checks:
Call
get_menuandupsert_menuusing MCP server commands or directly through curl/POSTMAN towardsPOST /menusandPUT /menus/:nameto ensure images are persisted and returned correctly.