# wilsoncespedes-dot/ajedrez- architecture

> Architecture diagram of the GitHub repository wilsoncespedes-dot/ajedrez-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wilsoncespedes-dot/ajedrez-
- Repository: https://github.com/wilsoncespedes-dot/ajedrez-

## Overview

#### Purpose and execution surfaces
This repository models chess-piece movement in Java and provides a standalone browser visualizer of the same rules. It is a movement model, not a full chess engine: check, checkmate, castling, en passant, and pawn promotion are outside its scope.

Java console entry point: `ModeladorAjedrez/src/ajedrez/features/juego/Main.java`.  
Browser entry point: `ModeladorAjedrez/interfaz/index.html`; it runs directly in a browser and is independent of the Java runtime.

#### Core domain model
`ModeladorAjedrez/src/ajedrez/core/Color.java` defines the two sides.  
`ModeladorAjedrez/src/ajedrez/core/Posicion.java` represents board coordinates and chess notation (`a1` through `h8`).  
`ModeladorAjedrez/src/ajedrez/core/Pieza.java` is the abstract base contract for all pieces, carrying shared identity/state and the movement interface.

The central boundary is that piece-specific logic depends on the core abstractions, while core does not depend on concrete piece types.

#### Board state and move boundary
`ModeladorAjedrez/src/ajedrez/core/Tablero.java` owns the 8×8 board state and provides placement, movement, and piece lookup. It is the authoritative Java state container used by movement calculations.

Primary Java flow: a caller constructs/configures a `Tablero`, places `Pieza` instances, asks a selected piece for legal movement destinations against that board, then requests the board to move the piece. Captures are represented by replacing/removing the occupant at a destination rather than through a separate game-service layer.

#### Piece-rule polymorphism
Each chess type is a concrete `Pieza` implementation:
- `ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java`
- `ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java`
- `ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java`
- `ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java`
- `ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java`
- `ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java`

Their defining responsibility is `movimientosPosibles(Tablero)`: each evaluates destinations using position, color, board occupancy, and capture rules. Sliding pieces stop at blockers; movement validity is local to pieces and does not incorporate king-safety rules.

#### Console demonstration
`ModeladorAjedrez/src/ajedrez/features/juego/Main.java` composes the Java model into a deterministic demo: it initializes a board, displays it, queries the white queen’s moves, moves a pawn, and displays the resulting state. It is not an interactive game loop or service endpoint.

The Java runtime requires a JDK; compilation is performed directly over the source tree without a declared build system.

#### Independent HTML visualizer
`ModeladorAjedrez/interfaz/index.html` contains the interactive UI and a JavaScript translation of the Java movement rules. It initializes a standard board, tracks turns, highlights destinations, applies moves/captures, records moves, displays selected-piece metadata, and can reset state.

This is a behavioral duplication boundary: the HTML implementation does not call, compile, or embed the Java model. Rule changes must therefore be kept synchronized manually across `src/ajedrez/features/piezas/` and `interfaz/index.html`.

#### External dependencies and infrastructure
There are no indicated databases, network APIs, backend services, package managers, or deployment infrastructure. Material runtimes are the JDK for the console model and any modern browser for the visualizer.

Main entry points: [`ModeladorAjedrez/src/ajedrez/core/Pieza.java`](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Pieza.java) (Pieza), [`ModeladorAjedrez/src/ajedrez/core/Tablero.java`](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Tablero.java) (Tablero), [`ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java`](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java) (Reina rules), [`ModeladorAjedrez/src/ajedrez/features/juego/Main.java`](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/juego/Main.java) (Console demo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_java["Java movement model"]
  node_main["Console demo<br/>Java entry point<br/>[Main.java]"]
  node_board[("Tablero<br/>board state<br/>[Tablero.java]")]
  node_piece["Pieza<br/>abstract piece contract<br/>[Pieza.java]"]
  node_position["Posicion<br/>coordinate value<br/>[Posicion.java]"]
  node_color["Color<br/>side enum<br/>[Color.java]"]
end

subgraph group_pieces["Piece rules"]
  node_pawn["Peón rules<br/>concrete piece<br/>[Peon.java]"]
  node_rook["Torre rules<br/>concrete piece<br/>[Torre.java]"]
  node_knight["Caballo rules<br/>concrete piece<br/>[Caballo.java]"]
  node_bishop["Alfil rules<br/>concrete piece<br/>[Alfil.java]"]
  node_queen["Reina rules<br/>concrete piece<br/>[Reina.java]"]
  node_king["Rey rules<br/>concrete piece<br/>[Rey.java]"]
end

subgraph group_browser["Browser visualizer"]
  node_visualizer["Interactive visualizer<br/>browser entry point<br/>[index.html]"]
  node_browser_state["UI board and turns<br/>client state<br/>[index.html]"]
  node_browser_rules["JavaScript move rules<br/>rule implementation<br/>[index.html]"]
end

node_main -->|"creates and displays"| node_board
node_main -->|"queries moves"| node_queen
node_board -->|"places and moves"| node_piece
node_piece -->|"uses"| node_position
node_piece -->|"uses"| node_color
node_pawn -->|"implements"| node_piece
node_rook -->|"implements"| node_piece
node_knight -->|"implements"| node_piece
node_bishop -->|"implements"| node_piece
node_queen -->|"implements"| node_piece
node_king -->|"implements"| node_piece
node_pawn -->|"evaluates occupancy"| node_board
node_rook -->|"evaluates blockers"| node_board
node_bishop -->|"evaluates blockers"| node_board
node_queen -->|"evaluates destinations"| node_board
node_visualizer -->|"runs"| node_browser_state
node_browser_state -->|"requests legal moves"| node_browser_rules
node_browser_rules -.->|"manually mirrors"| node_piece

click node_main "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/juego/Main.java"
click node_board "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Tablero.java"
click node_piece "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Pieza.java"
click node_position "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Posicion.java"
click node_color "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Color.java"
click node_pawn "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java"
click node_rook "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java"
click node_knight "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java"
click node_bishop "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java"
click node_queen "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java"
click node_king "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java"
click node_visualizer "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html"
click node_browser_state "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html"
click node_browser_rules "https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_board,node_piece,node_position,node_color toneBlue
class node_pawn,node_rook,node_knight,node_bishop,node_queen,node_king toneAmber
class node_visualizer,node_browser_state,node_browser_rules toneMint
```

## Components

### Java movement model

- [Console demo](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/juego/Main.java): Java entry point · Runs a deterministic board and move demonstration. · `ModeladorAjedrez/src/ajedrez/features/juego/Main.java`
- [Tablero](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Tablero.java): board state · Owns the authoritative 8×8 Java board state and moves. · `ModeladorAjedrez/src/ajedrez/core/Tablero.java`
- [Pieza](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Pieza.java): abstract piece contract · Shared piece state and movement interface. · `ModeladorAjedrez/src/ajedrez/core/Pieza.java`
- [Posicion](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Posicion.java): coordinate value · Board coordinates and chess notation. · `ModeladorAjedrez/src/ajedrez/core/Posicion.java`
- [Color](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/core/Color.java): side enum · `ModeladorAjedrez/src/ajedrez/core/Color.java`

### Piece rules

- [Peón rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java`
- [Torre rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java`
- [Caballo rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java`
- [Alfil rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java`
- [Reina rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java`
- [Rey rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java): concrete piece · `ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java`

### Browser visualizer

- [Interactive visualizer](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html): browser entry point · Standalone UI with translated movement rules and board state. · `ModeladorAjedrez/interfaz/index.html`
- [UI board and turns](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html): client state · Initializes pieces, tracks selection and turns, and applies captures. · `ModeladorAjedrez/interfaz/index.html`
- [JavaScript move rules](https://github.com/wilsoncespedes-dot/ajedrez-/blob/main/ModeladorAjedrez/interfaz/index.html): rule implementation · Independent translation of Java piece movement logic. · `ModeladorAjedrez/interfaz/index.html`

## Connections

- Console demo → Tablero: creates and displays
- Console demo → Reina rules: queries moves
- Tablero → Pieza: places and moves
- Pieza → Posicion: uses
- Pieza → Color: uses
- Peón rules → Pieza: implements
- Torre rules → Pieza: implements
- Caballo rules → Pieza: implements
- Alfil rules → Pieza: implements
- Reina rules → Pieza: implements
- Rey rules → Pieza: implements
- Peón rules → Tablero: evaluates occupancy
- Torre rules → Tablero: evaluates blockers
- Alfil rules → Tablero: evaluates blockers
- Reina rules → Tablero: evaluates destinations
- Interactive visualizer → UI board and turns: runs
- UI board and turns → JavaScript move rules: requests legal moves
- JavaScript move rules → Pieza: manually mirrors · Changes must be synchronized; no runtime integration exists.
