How kerokerokohei/nutri_pruner works
Main Components
• User Interface Layers:
• PC Interface: Located in src/PC. This includes components like PCApp.js which stitches together UI elements such as Header, ModalOpen variations, CalcNutri, Chat, ChatGPT, NutriDatabase, and WebGL.
• Mobile Interface: Located in src/SP. Similar to the PC view, MobileApp.js handles layout and contains similar components adapted for smartphone display.
• State Management & Business Logic:
• Redux Store: Represented by src/store. Actions and reducers (with separate implementations under src/PC/actions, src/PC/reducers, src/SP/actions, and src/SP/reducers) manage state changes such as setting modes (to ChatGPT, to WebGL, or simple state changes) and updating selected dishes.
• Data and External Services:
• Firebase Integration: Found in src/FireBase (firebase.js & TodosProvider.js). This is used for persisting data and possibly handling authentication or real-time updates.
• ChatGPT Integration: Both PC and mobile actions include “setToChatGPT” which suggests the system interacts with the ChatGPT API to fetch recipe recommendations based on nutritional imbalances.
• Unity/WebGL Integration: Unity builds (under public/unity) expose a WebGL interactive component that visualizes the nutritional balance evaluation. The WebGL.js components on both platforms manage the embedding and communication with these Unity builds.
• Styling & Build Tools:
• Tailwind CSS: Configured via tailwind.config.js and used for styling.
• Build/Config Files: Other support files such as postcss.config.js and package.json indicate the build process and dependency management.
Relationships and Interactions
• The user interacts with either the PC or Mobile UI to input food data.
• This interaction triggers actions (e.g., updateSelectedDishes, setToState, setToChatGPT, and setToWebGL) that update the application state via reducers.
• The state is centrally managed in the store which provides coordinated data to components like CalcNutri (for nutritional calculations) and the various Modal/Chat components.
• When the nutritional balance indicates deficiencies, the ChatGPT actions invoke external API calls to fetch recipe suggestions.
• In parallel, the computed results are fed into the Unity WebGL interface (via the WebGL component) which then displays the interactive, visual representation (including elements like rotating “komas” and animated Unity character).
• Firebase might handle data persistence and user session management.
Architectural Patterns & Design Principles
• Separation of Concerns: Distinct directories for PC and Mobile interfaces allow specialized layouts while sharing business logic.
• Component-based Architecture: Each UI section (Nutrition Calculator, Chat, Modal Pop-Ups, etc.) is modular.
• Redux-like Data Flow: Actions dispatch changes to reducers and lead to UI updates.
• External Integration: Clear divisions between local business logic and external services like Firebase, ChatGPT, and Unity.