How harryho/react-crm works
Main Components
• User Interface (Presentation Layer):
• React Components found in the “src/components” folder (e.g., AppNavBar, AppDrawerMenu, DataTable, etc.), along with specialized dashboard components.
• Pages (e.g., DashboardPage, CustomerListPage, OrderFormPage, etc.) under “src/pages.”
• Storybook integration for UI development (see “.storybook” and “src/stories” folders).
• State Management:
• Redux Store setup in “src/store” that integrates reducers from “src/reducers” (auth, customer, order, product).
• Actions in “src/actions” and asynchronous API call handling with Redux-Thunk in “src/services/thunks.ts.”
• Middleware located in “src/middleware” (including “api.ts” and demos for fake API responses).
• Back-end / API Simulation:
• The README indicates a readonly fake API rather than a full backend. The “demo-data.json” and “demo-db.ts” files in the middleware hint at data simulation.
• Although there’s no real API server, the architecture is set up to integrate with external services if needed.
• Build and Deployment:
• Build scripts (package.json commands, webpack config under “.storybook/webpack.config.js”) for hot loading and production builds.
• Dockerfile along with the nginx config (config/nginx.conf) indicate deployment using Docker containers and a reverse proxy.
• Other configuration files such as .babelrc, tsconfig.json, and jest.config.js contribute to the build/test pipeline.
• Supporting Infrastructure:
• Public assets served under the “public” directory.
• Testing support via Jest and Storybook snapshots.
Relationships and Interactions
• The user interacts with the UI (React components/pages). Pages then:
• Dispatch Redux actions (from “src/actions”) to trigger state changes.
• The actions engage service calls (Redux-Thunk pattern in “src/services/thunks.ts”) to interact with API middleware.
• The reducers (in “src/reducers”) update the application’s state stored in the Redux store (“src/store”).
• UI components subscribe to these state changes via Redux’s connect (or hooks) and re-render as needed.
• Storybook serves as a playground to develop and test individual UI components in isolation.
• The Dockerfile and nginx configuration show how the production build from “dist” (built via “npm run build”) is packaged and served.
Architectural Patterns and Design Principles
• The separation of concerns is clear:
• Presentation (React Components, Pages, Storybook stories),
• Business logic & state management (Redux actions, reducers, thunks),
• API abstraction (middleware simulating the backend), and
• Deployment concerns (Dockerfile, Nginx config).
• Use of Redux-Thunk for asynchronous actions and integration with a possible remote API.
• Modular and reusable components (especially with Storybook) support maintainability and scalability.
Relevant Technologies
• React 16 and React-Redux for UI and state management.
• Material-UI for the design system.
• TypeScript for type safety.
• Redux-Thunk middleware for handling asynchronous calls.
• Docker and Nginx for deployment and reverse proxy.
• Testing frameworks like Jest and Storybook for UI testing.