How kenchiwar/fe-invetory works
Project Type and Purpose
• This is a front-end single-page application (SPA) built with React and TypeScript using Vite as the bundler. It leverages redux with redux-thunk for state management and async API calls.
• The project is structured to render multiple pages (e.g., Home, BrandList, CurrentStock, NotFound) with a clear division of components, layout, API service calls, and state management.
Main Components
• UI Layer:
• React Components: Represented by files under src/Components and src/components (note the distinction in naming conventions).
• Layout & Page Components: Look at src/Components/Layout (e.g., MainLayout.tsx, TestRedux) and src/pages (e.g., Home, BrandList, CurrentStock, NotFound).
• Routing:
• Central routing defined in the src/routes.tsx file, which connects pages/components.
• Additional routing helper functions in src/helper/routerHelper.ts.
• API Service Layer:
• API handler files under src/api (such as api-service.ts, axios-instance.ts, base-service.ts, brand-service.ts, current-stock-service.ts, query-builder.ts).
• These components encapsulate logic to communicate with external backend endpoints.
• State Management:
• Redux Store and Reducers: Found in src/redux (with reducers for Brand, CurrentStock, Loading, and a general BaseApi reducer).
• redux-thunk is used to handle asynchronous API calls (as mentioned in the README).
• Constants & Styles:
• Constants defined in src/constants (for endpoints and HTTP statuses).
• Styling is managed through src/styles (SCSS and Tailwind CSS styles).
Indicating Relationships and Interactions
• UI components (presentational) interact with the Redux store:
• Dispatch actions (via redux-thunk) when user events occur.
• Actions call the API service layer to retrieve or update data.
• API Services:
• They abstract away HTTP calls (using axios-instance) and expose methods to various parts of the application.
• Redux Flow:
Architectural Patterns and Design Principles
• Separation of Concerns:
• Clearly separated layers for presentation (React components/pages), business logic (Redux actions/thunks), API interactions, and styling.
• Modular Design:
• Each domain (e.g., Brand, CurrentStock) has dedicated components, reducers, and services.
• Use of Aliases:
• As noted in the README (“nhớ coi mấy cái alias để xài // @compnents kiểu vậy đó”), indicating that care should be taken to clearly denote module boundaries.