How aymenchla/tennis-score-computer works
Project Type and Purpose
• This is a backend-focused Kagata “kata” application—a Tennis Score Computer—built with Java, Maven, and Spring Boot, following a Hexagonal (Ports & Adapters) architecture.
• Its goal is to compute and output the current score of a tennis game based on inputs fed via CLI or Kafka, and print results to the console.
File Structure Analysis
Top-level:
• pom.xml, mvnw* – Maven build & wrapper files.
• src/main/java/com/kata/tennis_score_computer – main codebase, organized into:
– adapter/input/cli (TennisGameCliAdapter)
– adapter/input/kafka (TennisGameKafkaConsumer)
– adapter/output/console (TennisScoreConsolePrinter)
– application/service (TennisGameUseCaseImpl)
– domain/model (Player, Score, TennisGame)
– domain/port/input (PlayTennisGameUseCase)
– domain/port/output (ScoreOutputPort)
– config (TennisGameRunnerConfig)
• src/main/resources/application.properties – Spring Boot config.
• src/test – matching unit and integration tests.
README Insights
• Minimal description, but repository name and module naming confirm this is a Tennis Score Computer Kata.
Components
a. Main Components
• Adapters/Input
– CLI Adapter
– Kafka Consumer Adapter
• Application Layer
– TennisGameUseCaseImpl (implements input port)
• Domain Layer (Core)
– TennisGame, Player, Score (domain model)
– PlayTennisGameUseCase (input port interface)
– ScoreOutputPort (output port interface)
• Adapters/Output
– Console Printer
• Configuration & Runner
– TennisGameRunnerConfig (Spring Boot wires up adapters and use-case)
• External Systems
– STDIN/Console
– Kafka Broker
b. Relationships & Data Flows
1. User or external system → Input Adapter (CLI/Kafka)
2. Adapter calls → PlayTennisGameUseCase (port)
3. Flow into Application Service → domain model (TennisGame.play, update Score)
4. Application invokes → ScoreOutputPort → Output Adapter (ConsolePrinter)
5. Output Adapter emits → STDOUT
c. Architectural Patterns & Principles
• Hexagonal / Ports & Adapters: clear separation between domain, application, and infrastructure.
• Dependency Inversion: domain and application layers depend on interfaces (ports), not implementations.
• Single Responsibility: each adapter solves one I/O concern.
d. Key Technologies & Frameworks
• Java 17+ (assumed)
• Spring Boot (auto-configuration, dependency injection)
• Maven (build & dependency management)
• Kafka Client (for input)