How pbl6-khoa-hoc-lap-trinh-online/pbl6-mobile works
Main Components
• Mobile App UI (Presentation Layer):
• The "app" folder contains the routing and screens. Notice the separation between app routes (mostly in the "(app)" folder under different tabs like account, categories, orders, products, checkout, etc.) and authentication screens (in the "(auth)" folder).
• The assets and animations directories support UI elements such as loading animations and image assets.
• API Integration Layer:
• The "apis" directory hosts modules like auth, cart, product, etc. These serve as the interface between the mobile client and the backend services that provide e-commerce functionalities and user data management.
• State Management & Business Logic:
• The "context" folder provides global state management for authentication and the shopping cart, ensuring that information flows correctly between components and screens.
• Custom hooks in the "hooks" folder (such as useThemeColor, useColorScheme, and useDebounce) encapsulate business logic and device-specific interactions.
• Utility & Type Safety:
• The "utils" folder (e.g., for HTTP requests and price conversion) contains helper functions.
• The "type" folder defines TypeScript types for entities like address, brand, cart, category, order, product, etc., ensuring type safety across the application.
• Testing & Quality Assurance:
• The "__tests__" folder mirrors the component structure and contains tests (mostly component tests for UI elements) ensuring code reliability and expected behavior.
Relationships and Interactions
• The UI/Presentation layer interacts with:
• Reusable UI components (from the "components" directory).
• Navigation and routing (files in the "app" folder for switching between different application states like auth, product view, cart, etc.).
• Global state management (via context files handling authentication and the cart).
• The API Integration Layer:
• State Management and Business Logic:
• Connects the UI with data sources. The contexts feed data to the screens and components, while hooks and utilities streamline common functionalities.
• Testing Layer:
• Although not part of the runtime system, note that tests (in "__tests__") verify functionality for the UI components, ensuring that the design is robust.
Architectural Patterns and Technologies Used
• Component-Based Design:
• The application follows a modular structure, where each UI element (button, card, header, etc.) can be seen as an individual component that may be composed together.
• Separation of Concerns:
• Clear delineation between presentation (UI and routing), business logic (context and hooks), and data communication (APIs and utilities).
• Mobile-Specific Permissions:
• Special mention of READ_MEDIA_IMAGES in the README suggests that the design must account for mobile permissions and the module where users select an avatar, which is implemented in the components (e.g., in the avatar component) and possibly influenced by context and API handling.