How driss292/poker-odds-calculator works
Main Components
• Frontend/UI Layer:
• This layer consists of all the React components under the “src/components” directory (e.g., Card, Deck, CardPlaceholder, Flop, River, Turn, Seat, IconDeck, ImageTable, ResetButton, StartAnalysis, Suit). These components together form the interactive poker table UI with drag and drop functionality.
• The index.html (in the root) serves as the entry point, along with the main.tsx in “src”, which bootstraps the React application.
• Drag and Drop Interaction:
• The application uses “Dnd Kit” to implement drag and drop. Mark this as a critical interaction layer that communicates between UI elements (cards, slots on the table) and internal state.
• Calculation/Business Logic Layer:
• This encapsulates the logic for computing odds, implemented in “src/utils/Calculator” (including modules like Card, CardGroup, Game, HandRank, OddsCalculator) as well as other calculation utilities in “src/utils”. These modules process the data based on the user’s card placements to deliver win probability estimates.
• Data/State Management and Supporting Utilities:
• Other utility modules (“src/utils/calculateOdds.ts”, “src/utils/data.ts”, etc.) handle helper functions, state modifications related to the drag and drop interactions, and the overall data flow.
• Configuration and Build:
• The project configuration files (e.g., package.json, vite.config.ts, tsconfig.json, etc.) support build processes and dependency management.
Relationships and Data Flow
• User Interface and Interaction:
• The user manipulates the UI on a virtual poker table via drag and drop; the interactive events are captured by the Dnd Kit integration.
• The UI components then relay these actions to the business logic layer.
• Business Logic Communication:
• When a card is dropped into a slot (for instance, in the CardSlot component), the action triggers the corresponding functions in the Calculator modules.
• These modules compute the odds based on the current state of the game (which cards are on the table, in the deck, etc.).
• Presentation of Results:
• The computed probabilities are then funneled back into the UI components, like StartAnalysis or the statistics display, updating the visual feedback.
• External Communication:
• Although the core functionality is computed within the client’s browser, the README mentions plans for a Chrome extension version which may require packaging or interfacing with browser APIs.
Architectural Patterns and Design Principles
• Separation of Concerns:
• Keep the UI (React components) distinct from the calculation logic (in the utils folder), ensuring modularity.
• Reusability and Componentization:
• The project's file structure indicates a strong emphasis on reuse with modular components (e.g., Card, Deck, IconDeck) and clear separation within the Calculator folder.
• Event-Driven Data Flow:
Technologies & External Libraries
• React & TypeScript:
• That the application uses React for the frontend coupled with TypeScript for type safety.
• Dnd Kit:
• Role of Dnd Kit as the library managing drag and drop interactions.
• CSS Modules:
• That styling is handled using Module CSS to maintain scope.