Frontend ‐ Backend Flow guide - hokumcangus/taste-of-aloha GitHub Wiki
🔄 Frontend -> Backend Flow
This guide tracks how data moves from the user's click in the browser to the PostgreSQL database.
🛒 Shopping Cart Flow
- UI Component: User clicks "Add to Cart" in
apps/web/src/components/Menu/. - State Management: The
useCarthook (Redux) updates the local state. - API Call: The
cartService.jssends aPOSTrequest to/api/cart. - Backend Route:
apps/backend/src/routes/cartRoutes.jsreceives the request. - Controller:
cartController.jsvalidates the item and quantity. - Persistence: Prisma saves the cart item to the database.
📋 Menu Loading Flow
- Page Load:
apps/web/src/pages/HomecallsfetchMenu. - Backend:
menuController.jsqueries theMenutable viaprisma.menu.findMany(). - Normalization: The controller ensures category names are standardized before sending the JSON response.
🛠 Troubleshooting Data Flow
If data isn't showing up:
- Check the Network Tab (F12) to see if the request hits
:3000. - Run
npx prisma studioinapps/backendto see if the data exists in the DB.