rewrite the readme
rewrite the readme
Summary This update focused on two main issues in the OTP flow: improving the user experience when the send-code button is pressed, and making the Gmail SMTP fallback more reliable on Railway by forcing IPv4 instead of the blocked IPv6 path.
The previous OTP flow allowed users to click the “Send Code” button repeatedly while the backend was still processing the request. This created a poor user experience and could trigger duplicate email sends or repeated requests.
The frontend button logic was updated so that while the OTP request is in progress:
The app was trying to connect to Gmail SMTP using Railway’s outbound networking stack. Railway was preferring IPv6 resolution for Gmail, which caused outbound connections to fail with unreachable network errors.
The SMTP connection attempted to reach Gmail over IPv6, but the Railway container did not have a working outbound route for that address family. As a result, the backend could not complete the SMTP connection, even though the app code itself was otherwise valid.
The Nodemailer transport was updated to force IPv4 resolution by setting:
jsfamily: 4
This keeps the existing SMTP host configuration (host: process.env.SMTP_HOST) but forces Node.js to use IPv4 instead of attempting the failing IPv6 route.Additional timeout settings were also added to prevent request hangs:
jsconnectionTimeout: 10000,greetingTimeout: 5000,socketTimeout: 10000,
This ensures that if SMTP is blocked or slow, the backend responds quickly with a clear error instead of leaving the browser hanging with a generic network issue.
The OTP flow is now more stable and user-friendly:
This patch addresses the UX problem and the deployment-specific SMTP issue without changing the overall app architecture.
src/routes/contact.js
[email protected]
src/routes/auth.js
Status: Resolved Event Binding Issue
DOMContentLoaded event wrapper in contact.js was unreliable because script loads after DOM already readyStatus: Contact form working in production
https://duskcoffee-production.up.railway.app
Project Goes Live!
Status: Core Architecture Deployed & Live (Railway + Aiven DB).
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.
users table in the database.login and register endpoints.orders.customer_phone is used as the canonical phone field.orders.total remains the canonical total value.order_items now stores either menu_id or product_id, never both.product_id was effectively a stringly-typed placeholder and not a real product reference.id, so the cart now distinguishes them using item_type.seed.sql file for catalog data.
The system now follows a single contract:
orders
order_items
This avoids duplicated and confusing legacy fields such as phone, total_amount, and users authentication.
I verified the JavaScript syntax for the changed backend and cart code:
node --check passed for the modified JavaScript files.The remaining operational step is database migration/import:
Guest Checkout and email OTP refactor
Removed the need for users to create an account before browsing or ordering.
Kept the storefront experience frictionless: users can still browse products and add items to the cart without logging in.
Added checkout.html
Added a checkout flow that collects:
full name, phone number, email, 6-digit OTP code
Added a “Send Code” button in the checkout form to trigger email verification before order placement.
Implemented OTP storage with a temporary in-memory map and expiration logic.
Added backend endpoints for:sending OTP emailsverifying OTP codessubmitting guest checkout orders after successful validationUpdated the order flow to store guest customer data directly in the database instead of requiring a registered user session.
Kept the storefront experience frictionless: users can still browse products and add items to the cart without logging in.
REMOVE auth.html
Overview :
Refactored the DuskCoffee client and backend to replace static mockups with a dynamic, data-driven system. Implemented checkout calculations, order submission endpoints, schema updates for order persistence, and a local JSON fallback mechanism for offline development.
File Changes SummaryEdited Files:
checkout.html — Updated UI container structure to support dynamic order rendering.checkout.
js — Added localStorage cart parsing, dynamic item rendering, price computations (subtotal, tax, delivery), and API POST triggers.
menu.html — Removed duplicate static .menu-full-card markup to rely on JavaScript rendering.
script.js — Refactored fetch logic to hit live API endpoints first, falling back to static JSON on failure.
schema.sql — Extended database schema with orders and order_items tables; verified product image paths.
server.js — Mounted orders API route and configured server initialization.
Added Files:
orders.js — Express route handler to process incoming checkout payloads and persist orders to MariaDB.
menu-fallback.json — Static fallback dataset containing all 16 menu items for local development.
checkout.html - Static checkout page but with dynamic/sync data with what item’s user add to cart
Overview :
Refactored the DuskCoffee client and backend to replace static mockups with a dynamic, data-driven system. Implemented checkout calculations, order submission endpoints, schema updates for order persistence, and a local JSON fallback mechanism for offline development.
File Changes SummaryEdited Files:
checkout.html — Updated UI container structure to support dynamic order rendering.checkout.
js — Added localStorage cart parsing, dynamic item rendering, price computations (subtotal, tax, delivery), and API POST triggers.
menu.html — Removed duplicate static .menu-full-card markup to rely on JavaScript rendering.
script.js — Refactored fetch logic to hit live API endpoints first, falling back to static JSON on failure.
schema.sql — Extended database schema with orders and order_items tables; verified product image paths.
server.js — Mounted orders API route and configured server initialization.
Added Files:
orders.js — Express route handler to process incoming checkout payloads and persist orders to MariaDB.
menu-fallback.json — Static fallback dataset containing all 16 menu items for local development.
checkout.html - Static checkout page but with dynamic/sync data with what item’s user add to cart
add dynamic notif “add to cart”
make the contact section look better i thnk, tryna user resend for the logic of sending messages, but it didnt work when i tried it myself for testing. well ill think about that later, i got bigger problem here, how to deploy this thing as full stack web 😭
preview
add auth page for both sign in and signup
edit 8/15/2026, i decided to seperate the menu-producs.html to each has it own page
Key Features:
Navbar - Navigation menu with Home, About Us, Menu, Products, and Contact links; includes search bar and shopping cart
Hero Section - Eye-catching welcome banner with call-to-action (“Order Now”)
About Us - Company story and values with images
Menu Section - Showcases coffee beverages and food items (Croissant, Cappuccino, Americano, etc.) with prices
Interactive Elements - Hamburger menu for mobile, search functionality, click-outside handlers
will add more soon…..