Multi-Tic-Tac is a simple online multiplayer X-O game built using Spring Boot and HTMX. The application allows multiple users to play Tic-Tac-Toe in real-time. You can take a look at the static site from here : https://bajahaw.github.io/multi-tic-tac/src/main/resources/static/index.html
The full project is hosted on Render: https://multi-tic-tac.onrender.com note that it might take long time to open due to free Render account limitations.
├── .devcontainer/
├── .github/
├── .idea/
├── pom.xml
├── Dockerfile
├── Readme.md
└── src/
└── main/
├── java/
│ └── org/
│ └── example/
│ └── game/
│ ├── GameApp.java
│ ├── controller/
│ │ └── GameController.java
│ ├── model/
│ │ ├── Board.java
│ │ ├── Computer.java
│ │ ├── Game.java
│ │ ├── GameStatus.java
│ │ └── User.java
│ └── service/
│ └── GameService.java
└── resources/
├── application.properties
└── static/
├── index.html
├── sse.js
├── htmx.min.js
└── style.css
- Java 21
- Maven
- Docker (optional, for containerized development)
To build the project, run the following command:
mvn clean install
To run the application, use the following command:
mvn spring-boot:run
To run the tests, use the following command:
mvn test
The main application class is GameApp:
@SpringBootApplication
public class GameApp {
public static void main(String[] args) {
SpringApplication.run(GameApp.class, args);
}
}
The main controller for the game is GameController:
@Controller
public class GameController {
// Handling connections and requests from UI
}
The game logic is handled by the GameService:
@Service
public class GameService {
// Handling game logic
}
The UI updates triggered by Server Sent Events (SSE) in EventService:
@Service
public class EventService {
// Brodcasting events to UI
}
The application configuration is located in application.properties
.
The frontend of the application is built using HTML and CSS. The main HTML file is index.html
and the CSS file is style.css
.
The project uses the following JavaScript libraries:
HTMX File: htmx.min.js
used for making AJAX requests and handling real-time updates via SSE directly from HTML attributes.
SSE File: sse.js
used for real-time updates from the server to the client.
The project includes configuration files for various development environments:
- VS Code: .vscode
- IntelliJ IDEA: .idea
- Docker: .devcontainer
This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request.