10 KiB
10 KiB
Handoff Report - Codebase Exploration
This report synthesizes the exploration of the HomAroma codebase regarding its backend, storefront, database models, testing structure, and MCP server setup.
1. Observation
Elysia Backend Server
- File path:
apps/backend/src/index.ts - Port definition:
apps/backend/src/index.ts(lines 31):const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3051;apps/backend/src/index.ts(line 140):.listen({ port: PORT, hostname: "0.0.0.0" });
- Scripts/Commands:
apps/backend/package.json(lines 7-11):"scripts": { "dev": "bun --watch src/index.ts", "build": "prisma generate", "start": "bun src/index.ts" }- PM2 configuration in
ecosystem.config.js(lines 4-7):name: 'homaroma-backend', script: './src/index.ts', cwd: '/home/ti/projects/homaroma-api/apps/backend', interpreter: '/home/ti/.bun/bin/bun',
Next.js Storefront Server
- File path:
apps/website - Output Mode:
apps/website/next.config.ts(lines 3-6)const nextConfig: NextConfig = { output: "standalone", }; - Port definition:
- Development port in
apps/website/package.json(line 6):"dev": "next dev -p 3001", - Production port in
ecosystem.config.js(lines 20-24):max_memory_restart: '1G', env_production: { NODE_ENV: 'production', PORT: 3002 }
- Development port in
- Scripts/Commands:
apps/website/package.json(lines 5-10):"scripts": { "dev": "next dev -p 3001", "build": "next build", "start": "next start", "lint": "eslint" }
Prisma Menu Models
- File path:
apps/backend/prisma/schema.prisma - Model definitions (lines 638-670):
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 } 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 } model MenuItemTranslation { id Int @id @default(autoincrement()) menuItemId Int menuItem MenuItem @relation(fields: [menuItemId], references: [id], onDelete: Cascade) langCode String label String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@unique([menuItemId, langCode]) }
Existing Tests and Configurations
- Workspace scripts:
- Root
package.jsoncontains:"test": "npm run test --workspaces --if-present" - No workspace package has a specific test command (such as running
jestorvitest).
- Root
- Scratch test scripts:
apps/backend/scratch_test.tsapps/backend/scratch_test_langs.tsapps/backend/scratch_test_menus.tsapps/backend/scratch_test_page.tsapps/backend/scratch_test_page2.tsapps/backend/test_category_image.tsapps/mcp-server/test_mcp_category_image.ts
- MCP server integration test:
apps/mcp-server/test_mcp_category_image.tsspawns both the backend server and MCP server, sends jsonrpc requests (initialize,notifications/initialized, and atools/callforupdate_category_image), waits for responses, terminates the servers, and verifies results.
MCP Tools configuration
- File path:
apps/mcp-server/index.ts - Main dependencies:
@modelcontextprotocol/sdk(version^1.29.0) - Transport configuration: Runs over standard input/output (
StdioServerTransport). - State and configuration variables (
apps/mcp-server/index.tslines 11-16):const LOCAL_BACKEND_URL = process.env.MCP_BACKEND_URL_LOCAL || "http://localhost:3051/api"; const PRODUCTION_BACKEND_URL = process.env.MCP_BACKEND_URL_PRODUCTION || "https://api.homaroma.shop/api"; let BACKEND_URL = process.env.MCP_BACKEND_URL || LOCAL_BACKEND_URL; const ADMIN_USERNAME = process.env.MCP_ADMIN_USERNAME || process.env.ADMIN_USERNAME || "admin"; const ADMIN_PASSWORD = process.env.MCP_ADMIN_PASSWORD || process.env.ADMIN_PASSWORD || "homaroma123"; - Login / Authentication Interception (lines 26-50):
Outbound requests are intercepted; if there is no active token, it logs in via
POST /auth/loginto retrieve a JWT Bearer token. - Capabilities & Tool Registry:
- Initialized with tool capabilities.
- Registers tools from:
- Main tool definitions (
apps/mcp-server/index.tslist) - Menu tool definitions (
MENU_TOOL_DEFINITIONSimported from./menu-toolkit) - Layout section block tool definitions (
SECTION_TOOL_DEFINITIONSimported from./section-toolkit)
- Main tool definitions (
- List of registered tools:
- Utility:
set_target_environment,ping_backend - Products/Brands/Categories:
list_product_brands,list_categories,search_products,get_product_detail,update_category_translation,update_category_image,update_product_brand_translation,create_product,bulk_create_products,sync_product_variants,update_product_content,update_product_translation,list_attribute_definitions,get_attribute_definition_detail,create_attribute_definition,update_attribute_definition,update_attribute_definition_translation,list_product_attributes,set_product_attribute,update_product_attribute_translation,upload_product_image_from_url,generate_mock_review - Orders/Customers:
get_order_status,list_pending_orders,update_order_tracking,search_customer - Dynamic Pages & Layout Block Sections:
list_dynamic_pages,list_dynamic_pages_metadata,get_dynamic_page_detail,create_dynamic_page,update_footer_content,get_page_section,add_page_section,update_page_section,delete_page_section, and the block-specific updater tools:update_hero_article,update_editorial_tile,update_rich_text,update_scent_notes_breakdown,update_quote_callout,update_product_carousel,update_accordion,update_contact_info,update_contact_form,update_editorial_carousel,add_accordion_category,update_accordion_category,add_accordion_question,update_accordion_question - Menus:
get_menu,upsert_menu,audit_missing_pages,get_mega_menu_tree,capture_menu_snapshot,restore_menu_snapshot,bulk_menu_operations,add_menu_node,update_menu_translation,move_menu_node,remove_menu_node
- Utility:
2. Logic Chain
-
Elysia Backend Server:
- Locating files via
list_dirand scanningapps/backend/package.jsonconfirms dependencies (elysia,@elysiajs/cors,prisma) and thedev/startscripts targetingsrc/index.ts. - Inspection of
apps/backend/src/index.tsshows the server listens toprocess.env.PORTdefaulting to3051. - Inspection of
ecosystem.config.jsshows that in PM2 environment, it runs ashomaroma-backend.
- Locating files via
-
Next.js Storefront Server:
- Scanning
apps/website/package.jsonidentifies the Next.js dependency (next,react,react-dom). - The script
"dev": "next dev -p 3001"specifies port3001for development. ecosystem.config.jsconfigures the website PM2 processhomaroma-websiterunning on port3002in production.apps/website/next.config.tsconfirms standalone output mode which buildsserver.jsused by PM2.
- Scanning
-
Prisma Models for Menu/Mega Menu:
- Location verified at
apps/backend/prisma/schema.prisma. - Models
Menu,MenuItem, andMenuItemTranslationstructure the menu hierarchy, including references, ordering, JSON payloads (for tree-based navigation), and localized values.
- Location verified at
-
Existing Tests and Runner:
- Searching files for
*.test.ts,*.spec.ts, and checking scripts in workspace package.jsons reveals that no formal testing framework (such as Jest, Vitest, Cypress, or Bun test suite) is integrated. - Instead, the project uses manual scratch runner scripts (e.g.,
scratch_test_menus.ts). - An MCP integration test
apps/mcp-server/test_mcp_category_image.tsruns on Bun to verify MCP jsonrpc request/response handlers.
- Searching files for
-
MCP Tools Configuration:
apps/mcp-server/package.jsonindicates dependency on@modelcontextprotocol/sdk.apps/mcp-server/index.tscreates the stdio Server and registers capabilities.- Analysis of
index.ts,menu-toolkit.ts, andsection-toolkit.tsoutlines a comprehensive list of tools (utility, products, orders, dynamic pages, menus) and environmental variables supporting target switcher and automatic API authentication login.
3. Caveats
- No active test runner is configured, so we cannot run standard test command validations. We assume the codebase relies on manual verification run scripts.
- The
server.jsused in PM2 production is generated dynamically by Next.js standalone build and is not committed to the source control.
4. Conclusion
The Monorepo codebase is split into Elysia (port 3051), React SPA, and Next.js Storefront (dev: 3001, production: 3002). Database interactions are driven by Prisma, with menu systems mapped to Menu, MenuItem, and MenuItemTranslation. Testing is done through standalone manual scripts. The MCP server integrates with the backend via authentication interception and exposes the tools defined in the toolkit modules.
5. Verification Method
To verify these findings:
- Elysia Backend Server Port/Startup:
- Run
PORT=3055 bun apps/backend/src/index.tsand inspect log outputs.
- Run
- Next.js Storefront Dev Port:
- Run
bun --cwd apps/website devand check terminal log output to verify it opens athttp://localhost:3001.
- Run
- Prisma Menu Schema Validation:
- Run
npx prisma validate --schema=apps/backend/prisma/schema.prismato confirm syntax correctness of models.
- Run
- Manual Test Run:
- Run
bun apps/backend/scratch_test_menus.ts(assuming database is running locally) orbun apps/mcp-server/test_mcp_category_image.tsto test MCP tool execution.
- Run