# pslusarz/gnubridge architecture

> Architecture diagram of the GitHub repository pslusarz/gnubridge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pslusarz/gnubridge
- Repository: https://github.com/pslusarz/gnubridge

## Overview

##### Major Components
a. Core Game Engine:
- Includes domain classes like Card, Deal, Hand, Trick, and Direction.
- This is the foundation for representing and processing the state of a Bridge game.
b. Bidding Logic:
- Contains bidding-related classes (e.g., Auctioneer, BiddingAgent, Bid, Call, Pass, Redouble) along with a rich set of bidding rules (found under org.gnubridge.core.bidding/rules).
- It handles all the decision-making and scoring during the bidding phase.
c. Deck & Card Components:
- Represented by classes in the deck package that define card suits, ranks, and trump logic.
d. Presentation / GUI Layer:
- Provided in the presentation package, this layer includes classes for managing the graphical display of cards, bidding interfaces, deal views, and overall game interaction (e.g., MainView, BiddingDisplay, CardPanel).
e. Search / AI Engine:
- Found within the search package, it includes the DoubleDummySolver, alpha-beta pruning (see classes like AlphaBeta, PruningStrategy), and supporting algorithms that analyze bridge positions.
f. Data & Resources:
- The data folder contains supplementary files and assets (like images for cards and papers for reference/documentation).
g. Testing Suite:
- Comprehensive test packages that validate core functionality for game logic, bidding, GUI, and search algorithms.

##### Out the Component Relationships
- The GUI (Presentation Layer) interacts with the underlying controllers (e.g., MainController, BiddingController, DealController) to send user inputs.
- These controllers, in turn, direct calls to the core game engine and bidding logic to update game state.
- The core engine components (from org.gnubridge.core) use classes from the deck and bidding packages to simulate gameplay.
- The Search / AI component (DoubleDummySolver and related classes) analyzes game state to advise moves or calculate outcomes, interfacing directly with the core game state.
- Configuration and resource files (including Gradle scripts) support build deployment and resource loading for both the GUI and game logic.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Notice the clear separation between the game logic (core, bidding, search) and the presentation (GUI) layers.
- Modular Design: Each folder/package encapsulates a distinct aspect of the game, from core representations to AI search algorithms.
- MVC-like Pattern in Presentation: Although not explicitly documented, the usage of Controllers (e.g., MainController, DealController) alongside distinct View implementations suggests a Model-View-Controller separation.
- Testing: Extensive test cases are organized by the same functional areas, ensuring that each component behaves as expected.

##### Relevant Technologies and Frameworks
- Java (minimum version 1.5).
- Gradle (with the gradlew wrapper provided).
- The project might use specific libraries for GUI rendering (e.g., Swing or AWT) as indicated by the package naming in the presentation layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Domain Layer
    subgraph "Domain Layer"
        CGE["Core Game Engine"]:::domain
        BL["Bidding Logic"]:::domain
        DC["Deck & Card Components"]:::domain
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        PG["Presentation / GUI"]:::presentation
    end

    %% AI Layer
    subgraph "AI / Analysis Layer"
        AI["Search / AI Engine"]:::ai
    end

    %% Supporting Components
    subgraph "Supporting Components"
        DR["Data & Resources"]:::resource
        TS["Testing Suite"]:::testing
        GB["Build System (Gradle)"]:::build
    end

    %% Connections between layers
    PG -->|"UserInput"| CGE
    PG -->|"BiddingRequest"| BL
    CGE -->|"Uses"| DC
    CGE -->|"GameState"| AI
    CGE -->|"LoadAssets"| DR
    PG -->|"LoadImages"| DR

    %% Testing connections
    TS -->|"Tests"| CGE
    TS -->|"Tests"| BL
    TS -->|"Tests"| PG
    TS -->|"Tests"| AI

    %% Build system connections
    GB -->|"Builds"| CGE
    GB -->|"Builds"| BL
    GB -->|"Builds"| PG
    GB -->|"Builds"| AI

    %% Click Events
    click CGE "https://github.com/pslusarz/gnubridge/tree/master/src/main/java/org/gnubridge/core"
    click BL "https://github.com/pslusarz/gnubridge/tree/master/src/main/java/org/gnubridge/core/bidding"
    click DC "https://github.com/pslusarz/gnubridge/tree/master/src/main/java/org/gnubridge/core/deck"
    click PG "https://github.com/pslusarz/gnubridge/tree/master/src/main/java/org/gnubridge/presentation"
    click AI "https://github.com/pslusarz/gnubridge/tree/master/src/main/java/org/gnubridge/search"
    click DR "https://github.com/pslusarz/gnubridge/tree/master/data"
    click TS "https://github.com/pslusarz/gnubridge/tree/master/src/test"

    %% Styles
    classDef domain fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef presentation fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef ai fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef resource fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;
    classDef testing fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef build fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
```
