How umberto-bianchin/progetto_klotski works
Main Components
• User Interface (View): Represented by the Java Swing components (e.g., KlotskiUI, AuthenticationDialog, Board, Block, SavedGamesDialog, etc.) that render the game visuals and manage user interactions.
• Controller Layer: Classes in the Controller package handle user commands (e.g., AuthListener, BoardListener, HomeCommand, NextCommand, RestartCommand, SaveCommand, UndoCommand). These mediate between the View and Model layers.
• Model Layer: Includes domain models (KlotskiModel, Database, Move, Piece, Solver, State) encapsulating business logic, game state management, and database interactions.
• External Services:
• AWS Lambda-based Solver Service invoked via POST requests. This external Node.js service provides the “next best move” functionality.
• MySQL Database for persisting game state or user data.
• Infrastructure/Dependencies:
• Maven build (pom.xml, mvnw scripts) that link all project modules.
• Configuration files and resources (images, styles, etc.) in the resources directory.
• Testing Suite (JUnit tests under src/test) ensuring quality and regression safety.
Relationships and Data Flow
• The Controller then updates the Model, which may interact with the Database to store state or retrieve game data.
• For hint or move suggestions, the Model (specifically the Solver class) prepares a POST request and sends it to the AWS Lambda-based solver service. The JSON response is then parsed (using JSON simple) and funneled back into the Model (or directly updates the UI via the Controller).
• User → View (UI interactions).
• View → Controller (event notifications).
• Controller → Model (command invocations) and vice versa for updating the UI.
• Model → External Services (both Database queries and AWS Lambda HTTP POST calls).
Architectural Patterns and Technologies
• MVC pattern as the core structural pattern.
• Separation of concerns that isolates UI, application logic, and data access.
• Use of Java Swing (with FlatLaf for a modern look), emphasizing the UI layer.
• AWS Lambda as an external service component communicating via RESTful APIs.
• MySQL database as the repository for game state and possibly user data.
• Maven as a dependency management/build tool tying the project together.