How hey-ashik/ghorerbazar works
Ghorer Bazar is a full-stack storefront and commerce API. Customers browse and search the catalogue, manage a cart, get server-priced checkout totals, place and track orders, and use account features; a separate chat flow answers store questions using catalogue context. The graph follows the documented Next.js-to-Express API boundary and sampled controller/service calls. Several frontend and backend subsystems are represented at directory level because their source was not sampled; their internal wiring is therefore not expanded.
Main entry points: index.js API routes · app Storefront routes · productService.js Product queries · db.js MySQL
Components 22
Storefront
- Storefront routes
frontend/src/app - Product and shop UI
frontend/src/components/product - Collection UI
frontend/src/components/shop - Cart state
frontend/src/context/CartContext.jsx - API client
frontend/src/lib/api.js
Commerce API
- API application
backend/src/app.js - API routes
backend/src/routes/index.js - Catalogue handlers
backend/src/controllers/productController.js - Product queries
backend/src/services/productService.js - Order handlers
backend/src/controllers/orderController.js - Order pricing and lifecycle
backend/src/services/orderService.js
Accounts
- Authentication handlers
backend/src/controllers/authController.js - Account handlers
backend/src/controllers/accountController.js
Chat Support
- Chat widget
frontend/src/components/layout/ChatWidget.jsx - Chat handlers
backend/src/controllers/chatController.js - Chat rate limiting
backend/src/services/chatRateLimitService.js - AI chat service
backend/src/services/groqService.js
Runtime Data
- MySQL
backend/src/config/db.js - Catalogue cache
backend/src/services/cacheService.js - Optional Redis
backend/src/config/redis.js
Other components
- Customer
- Groq API
Connections 28
- Customer → Storefront routes: browses and checks out
- Storefront routes → Product and shop UI: renders catalogue
- Storefront routes → Collection UI: renders collections
- Storefront routes → Cart state: manages cart
- Storefront routes → API client: requests data
- Chat widget → API client: sends messages
- API client → API application: calls API
- API application → API routes: dispatches
- API routes → Catalogue handlers: dispatches catalogue
- API routes → Order handlers: dispatches orders
- API routes → Authentication handlers: dispatches auth
- API routes → Account handlers: dispatches accounts
- API routes → Chat handlers: dispatches chat
- Catalogue handlers → Product queries: queries products
- Catalogue handlers → Catalogue cache: caches catalogue
- Product queries → MySQL: reads catalogue
- Order handlers → Order pricing and lifecycle: prices and places orders
- Order pricing and lifecycle → Product queries: loads products
- Order pricing and lifecycle → MySQL: reads and writes orders
- Authentication handlers → MySQL: reads and writes users
- Account handlers → MySQL: reads and writes account data
- Account handlers → Product queries: loads wishlist products
- Chat handlers → Chat rate limiting: checks message limits
- Chat handlers → AI chat service: requests reply
- AI chat service → Catalogue cache: loads catalogue context
- AI chat service → Groq API: sends prompt
- Catalogue cache → Optional Redis: uses when configured
- Chat rate limiting → Optional Redis: uses when configured