Summary
Today’s work focused on aligning the project with the intended business flow: guest checkout with email OTP validation, instead of traditional user registration/login. The backend, schema, and cart payload were cleaned up to remove account-based flow and enforce a consistent transaction model.
What changed
- Removed the account-based auth flow from the project.
- No more
userstable in the database. - No more
loginandregisterendpoints.
- No more
- Kept the guest checkout path as the only legitimate order flow.
- Customer browses without logging in.
- Customer enters name, phone, and email on checkout.
- Email OTP is sent and validated before the order is placed.
- Fixed the order schema to match the real business model.
-
orders.customer_phoneis used as the canonical phone field. -
orders.totalremains the canonical total value.
-
- Refined the order item model.
-
order_itemsnow stores eithermenu_idorproduct_id, never both. - This avoids the earlier issue where
product_idwas effectively a stringly-typed placeholder and not a real product reference.
-
- Resolved cart identity collisions.
- Menu and product items can share the same numeric
id, so the cart now distinguishes them usingitem_type.
- Menu and product items can share the same numeric
- Created a separate
seed.sqlfile for catalog data.- Schema file now defines structure only.
- Seed file loads initial menu and product records.
Key architecture decision
The system now follows a single contract:
- Guest checkout only
- Email OTP verification required before order placement
- Orders stored in
orders - Line items stored in
order_items - Each order item references either:
- a menu item, or
- a product item
This avoids duplicated and confusing legacy fields such as phone, total_amount, and users authentication.
Validation
I verified the JavaScript syntax for the changed backend and cart code:
-
node --checkpassed for the modified JavaScript files. - No editor errors were reported for the updated route and cart logic.
Notes / Follow-up
The remaining operational step is database migration/import:
- recreate the local MariaDB database
- import the cleaned schema
- import the seed file
- start the app and test the OTP checkout flow end-to-end
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.