How duybui2608bku/clone-shoppe works
Main Components
• UI Layer – Includes all visual components and pages. Organize this layer by:
• Pages: Home, Cart, Login, Register, Profile, ProductDetail, ProductsList, etc.
• Components: Reusable pieces like ButtonShoppe, HeaderMain, Footer, InputNumber, Paginate, ProductRating, QuantityController, and various Popovers.
• Layouts: MainLayout, RegisterLayout, and UserLayout that wrap around pages to provide a consistent look and navigation.
• Application State Management – The Context folder (App.context.tsx) shows that the app uses React Context API to manage global state.
• API/Service Layer – The Services folder encapsulates communication with back-end endpoints. This includes API calls for categories, products, login/logout, purchases, and user operations.
• Custom Hooks – Provided in the Hooks folder (e.g., useQueryConfig, useQueryParams) to encapsulate reusable logic and interactions.
• Utility and Constants Modules – The Utils and constants folders provide helper functions (Auth, axios, ruls etc.) and configuration values (paths, HTTP status codes, product/purchase settings).
Relationships and Interactions
• The UI Layer (Pages and Components) “talks” to the API/Service layer by invoking functions from the Services folder.
• The Context layer integrates with both UI components and Service calls to manage and propagate state (e.g., logged-in user, items in the cart, etc.).
• Custom Hooks act as intermediaries to extract query data and other logic from the URL or other sources, thereby influencing component behavior.
• Layouts wrap around pages, providing common navigation (such as Header or Footer) and an overall structure to the UI.
• The constants and types files ensure consistency in data types and configuration throughout the application.
Important Architectural Patterns
• Component-Based Architecture: Separating visual and reusable code into discrete components.
• Separation of Concerns: Dividing the system into UI, state management, and service/API layers.
• Modular Organization: Specific directories for hooks, services, context, constants, and utilities allow the project to remain maintainable and scalable.
• Use of Custom Hooks and Context API: For managing and sharing state logic across various parts of the application.
Relevant Technologies and Libraries
• React with TypeScript – Main framework and typing system.
• SCSS – For styling components with organized style files.
• Vite – Likely used as the build tool (as seen from vite.config.ts and vite-env.d.ts).
• ESLint and Prettier – For code quality and formatting.
• Axios – Presumably wrapped within the Utils/axios.ts for API requests.