How a-b-h-i-n-a-v-1-9/custom-tshirt-store works
Project Type and Purpose
• That this is a full-stack e-commerce application.
• That users can customize t-shirts in a live 3D environment, manage shopping carts, process payments, and view order histories.
• That the backend uses MySQL for data storage (with tables for users, products, cart, orders, payments, and custom designs) and employs JWT for secure authentication.
Main Components Identification
• Frontend Component:
• Built with React.
• Incorporates routing (React Router), API service calls (Axios), and Three.js libraries for 3D customization.
• Consists of various pages and components (e.g., Home, Cart, Profile, etc.).
• Backend Component:
• Built with Node.js and Express.
• Organized into routes (e.g., authRoutes, productRoutes, cartRoutes, orderRoutes, paymentRoutes, designRoutes), controllers (with business logic), and models (representing MySQL tables).
• Uses middleware (e.g., authMiddleware) for authentication.
• Handles file uploads for custom design images (using Multer).
• Database:
• MySQL database which stores structured data such as user information, product details, cart contents, orders, payments, and custom design records.
• Supporting Components:
• Environment and configuration management using .env and configuration files in backend/config.
• Uploads directory for storing user-uploaded custom t-shirt designs.
• External libraries: Three.js for the live 3D experience, JWT for security, bcrypt for password hashing, etc.
Relationships and Data Flow
• Frontend communicates with the backend via REST API calls using Axios.
• Backend processes requests by routing them to appropriate controller functions and uses models to interact with the MySQL database.
• Interactions between the backend and the uploads folder where custom design images are stored.
• Security flow:
• A note on the JWT authentication flow from client to server and the use of auth middleware to secure API endpoints.
Architectural Patterns and Design Principles
• The design largely follows the MVC (Model-View-Controller) pattern on the backend:
• Models represent the data structures (e.g., UserModel, ProductModel).
• Controllers handle the business logic.
• Routes serve as the connection between controllers and client requests.
• The separation of concerns is clearly maintained by isolating frontend and backend functionalities.
• Use of a RESTful API design that separates concerns between client and server.