How lucaslimaaz/soloyugioh works
Based on your file tree and the README, the project is clearly a single-page application designed to simulate a Yu-Gi-Oh! duel and help players build and test their physical decks. It leverages React for building UI components, using a clear separation between presentational (JSX) components and their accompanying business logic (custom hooks). The project also places a premium on clean code and SOLID principles, with a further division into shared hooks using Jotai for global state, services for handling calls to the Yu-Gi-Oh! API and reading local JSON card lists, and helpers (like sound management with HowlerJS).
Main Components
• UI / Presentation Layer:
• Components: These include card, container, deck, enemy-turn (with its sub-phases), field, graveyard, hand, modals (attack, change-stats, search-card, settings), scoreboard, and tool-bar.
• Each component has its presentational part (JSX file) and its logic hook (named use-componentName).
• Shared Hooks and Global State:
• Located in src/shared/hooks
• Uses Jotai atoms (in src/shared/atoms.jsx) to provide a consistent global state across the application.
• Services:
• API communication with the Yu-Gi-Oh! API.
• Reading and managing local cardList JSON files.
• Found in src/shared/services.
• Helpers:
• Utility functions such as playSound (using HowlerJS) for playing sound effects.
• External Libraries & Frameworks:
• React for UI, MUI for styling components, Jotai for global state, and HowlerJS for audio.
Relationships and Interactions
• UI components invoke their corresponding hooks to handle logic encompassing state management, complex behaviors, or even local computations.
• Shared hooks update/read Jotai atoms, meaning that many UI components (like the deck, hand, and scoreboard) will interact via these shared state containers.
• Service modules act as mediators between the UI and external data sources (the external API as well as local JSON datasets).
• Helper functions, such as the one that manages sound effects, are used by multiple components to enhance interactivity.
• The directional data flow is essentially: User Interactions → UI Components → Hooks (logic) → Services (data/API calls) → Global State Updates → UI Re-render.
Architectural Patterns & Design Principles to Highlight
• Emphasis on separation of concerns: UI (presentation) is kept separate from business logic (hooks) and data sourcing (services).
• Global state management with Jotai ensuring consistency across components.
• Clean Code and SOLID principles achieved via modularization of each concern (components, hooks, services, etc.).
• Coupling between components is minimized by keeping shared functionality within dedicated modules (e.g., shared hooks, helpers).
Final Checklist for the Principal Software Engineer
• Component is clearly labeled with its name and role (e.g., “card (Presentation)” and “use-card (Logic)”).
• UI components and their hooks.
• Hooks and the services module (illustrating API and JSON processing).
• Hooks and shared state (using Jotai atoms), reflecting the global state management.
• External technology usages (React, MUI, Jotai, HowlerJS, Yu-Gi-Oh! API).
• Notes or call-outs for important architectural principles like separation of concerns and adherence to SOLID principles.