How winifycode/kttstore-react works
Main Components
a. Frontend (React/Vite)
– Entry: main.jsx → App.jsx
– React Router layer (pages/…)
– Shared Components (components/…)
– Contexts (AdminThemeContext, CustomerThemeContext)
– Services (axios instance in utils/axios.js)
– Styles (TailwindCSS + CSS files)
b. Backend (Node.js/Express)
– Entry: server.js
– Routing layer (routes/*.route.js)
– Controller layer (controllers/*Controller.js)
– Data layer (models/*.js using Mongoose)
– Middlewares (auth.middleware, ImagesCloudinary_Controller)
– Utility modules (server/utils/payos.js, server/data/trainingData.js)
c. Database
– MongoDB (hosted via connection string in .env)
– Collections: Users, Products, Orders, Cart, Category, Coupon, Notification, etc.
d. External Services
– Cloudinary (image uploads)
– PayOS (payment gateway)
– Nodemailer (email via SMTP/OAuth)
– OAuth 2.0 (social login)
– AI chat (optional integration via AIController + trainingData)
Relationships & Data Flow
– Frontend → HTTP/REST calls → Backend Routes
– Backend Routes → invoke Controllers → interact with Mongoose Models → read/write MongoDB
– Controllers → call External Service modules (Cloudinary, PayOS, Nodemailer) as needed
– Responses percolate back up: Models → Controllers → Routes → Frontend
– Frontend state updates via Contexts/Redux and re-renders UI
Architectural Patterns
– Frontend: Component-based architecture with a clear separation of pages, layouts, contexts, and shared UI controls
– Backend: Classic MVC (Express Routes → Controllers → Models)
– Authentication: JWT tokens handled in auth.middleware and stored in front-end (e.g., localStorage)
– File uploads: Direct to Cloudinary via middleware
– Payment: Backend gateway integration (PayOSController)
– Email: EmailController + subscription.route