How amr-al/buybay works
BuyBay is an e-commerce backend for user accounts, product listings, carts, purchases, and subscription payments. The principal buyer flow is to browse products, add items to a cart, and submit the cart as a purchase; sellers can manage listings and purchase requests. Authentication and profile management form a separate account workflow, while PayPal payment and email are integrations. The excerpts show route-to-controller and controller-to-model calls for several workflows; unsampled route implementations and some runtime wiring remain uncertain.
Main entry points: index.js Express server · authRoutes.js Auth routes · productModel.js Product records · userModel.js User records
Components 24
API and identity
- Express server
index.js - Auth routes
routes/authRoutes.js - Account workflows
controllers/authController.js - User records
models/userModel.js - Token validation
validation/authValidation.js - Message routes
routes/messagesRoutes.js - Contact messages
controllers/messagesController.js
Product catalog
- Product routes
routes/productRoutes.js - Product workflows
controllers/productController.js - Product records
models/productModel.js - Upload middleware
assits/multer.js - File uploader
assits/fileUploader.js
Cart and purchases
- Cart routes
routes/cartRoutes.js - Cart workflows
controllers/cartController.js - Cart records
models/cartModel.js - Purchase routes
routes/purchesRoutes.js - Purchase workflows
controllers/purchesController.js - Purchase records
models/purchesModel.js
External services
- Payment routes
routes/paymentRoutes.js - PayPal
- Email delivery
assits/sendMails.js - Google identity
- Gmail SMTP
Other components
- API client
Connections 37
- API client → Express server: sends requests
- Express server → Auth routes: mounts routes
index.js - Express server → Product routes: mounts routes
index.js - Express server → Cart routes: mounts routes
index.js - Express server → Message routes: mounts routes
index.js - Express server → Purchase routes: mounts routes
index.js - Express server → Payment routes: mounts routes
index.js - Auth routes → Account workflows: dispatches
routes/authRoutes.js - Auth routes → User records: reads and writes
routes/authRoutes.js - Auth routes → Token validation: uses
routes/authRoutes.js - Auth routes → Upload middleware: uses
routes/authRoutes.js - Account workflows → User records: reads and writes
controllers/authController.js - Account workflows → Email delivery: sends mail
controllers/authController.js - Auth routes → Google identity: authenticates with
routes/authRoutes.js - Auth routes → Email delivery: sends mail
routes/authRoutes.js - Product routes → Product workflows: dispatches
routes/productRoutes.js - Product routes → Token validation: uses
routes/productRoutes.js - Product routes → Upload middleware: uses
routes/productRoutes.js - Product workflows → Product records: reads and writes
controllers/productController.js - Cart routes → Cart workflows: dispatches
routes/cartRoutes.js - Cart routes → Token validation: uses
routes/cartRoutes.js - Cart workflows → Cart records: reads and writes
controllers/cartController.js - Cart workflows → Product records: updates products
controllers/cartController.js - Purchase routes → Purchase workflows: dispatches
routes/purchesRoutes.js - Purchase routes → Token validation: uses
routes/purchesRoutes.js - Purchase workflows → Cart records: reads and clears
controllers/purchesController.js - Purchase workflows → Purchase records: reads and writes
controllers/purchesController.js - Message routes → Contact messages: dispatches
routes/messagesRoutes.js - Contact messages → Email delivery: sends mail
controllers/messagesController.js - Payment routes → PayPal: creates payments
routes/paymentRoutes.js - Payment routes → PayPal: executes payments
routes/paymentRoutes.js - Email delivery → Gmail SMTP: sends messages
assits/sendMails.js - Product records → User records: references users
models/productModel.js - Cart records → User records: references users
models/cartModel.js - Cart records → Product records: references products
models/cartModel.js - Purchase records → User records: references users
models/purchesModel.js - Purchase records → Product records: references products
models/purchesModel.js