A full-stack system for tracking vehicle fleet data and fuel consumption statistics. This project uses a Spring Boot backend and a Java CLI client, organized within a multi-module Maven build.
server: The core application logic.- Framework: Spring Boot 3.x
- Features: REST API, Servlet support (
/servlet/*), In-Memory Persistence.
client: A dedicated command-line interface tool.- Framework: Native Java + Picocli.
- Features: User-friendly commands, HTTP API integration.
Here is the directory layout:
├── pom.xml # Parent Maven descriptor
├── server/
│ ├── pom.xml
│ └── src/main/java/com/aem/car/
│ ├── controller/ # REST Controllers (API endpoints)
│ ├── model/ # Domain entities (Car, FuelEntry)
│ ├── repository/ # Data access layer
│ ├── service/ # Business logic
│ ├── servlet/ # Manual HttpServlet implementations
│ └── ServerApplication.java
└── client/
├── pom.xml
└── src/main/java/com/aem/client/
├── api/ # HTTP Client wrapper
└── CliApp.java # Main class & Picocli commands
- Java 17 (Required): Ensure
java -versionshows 17. - Maven 3.6+: Ensure
mvn -versionis installed.
To build the solution and generate the executable JARs, run:
mvn clean installArtifacts generated:
- Server:
server/target/server-1.0.jar - Client:
client/target/client-1.0.jar
For rapid development, run the server using the Spring Boot plugin:
mvn spring-boot:run -pl serverRun the client directly from source without packaging:
mvn clean compile exec:java -pl client \
-Dexec.mainClass="com.aem.client.CliApp" \
-Dexec.args="create-car --brand Tesla --model Model3 --year 2024"Deploy the server application:
java -jar server/target/server-1.0.jarThe server listens on port 8080.
Open a new terminal to interact with the system via the generated client JAR.
java -jar client/target/client-1.0.jar create-car --brand Toyota --model Corolla --year 2018java -jar client/target/client-1.0.jar add-fuel --carId 1 --liters 40 --price 52.5 --odometer 45000java -jar client/target/client-1.0.jar fuel-stats --carId 1Defined in CarController.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/cars |
Create a new car entity. |
GET |
/api/cars |
List all registered cars. |
POST |
/api/cars/{id}/fuel |
Record a fuel transaction. |
GET |
/api/cars/{id}/fuel/stats |
Retrieve aggregated fuel statistics. |
The API documentation is automatically generated by SpringDoc (OpenAPI). Once the server is running, you can access the interactive UI at:
- URL: http://localhost:8080/swagger-ui/index.html
- OpenAPI Spec: http://localhost:8080/v3/api-docs
Defined in FuelStatsServlet.
| Method | Endpoint | Description |
|---|---|---|
GET |
/servlet/fuel-stats?carId={id} |
Manual HttpServlet returning JSON stats. |
- Maven Multi-Module Architecture:
- Separation of Concerns: Enforces a strict boundary between the backend service and the client application, preventing accidental coupling of logic.
- Independent Dependency Management: Allows the
serverto manage Spring Boot dependencies independently from theclient's lightweight CLI requirements. - Unified Build Lifecycle: Facilitates a single command (
mvn clean install) to build, test, and package the entire distributed system, streamlining the CI/CD pipeline.
- Spring Boot 3.2: Selected for the backend to leverage its production-ready features, including robust REST API support and embedded servlet container, while maintaining the flexibility to register legacy
HttpServletcomponents manually. - Picocli: Chosen for the CLI to provide a professional, type-safe user experience with automatic help generation, argument validation, and ANSI color support, superior to manual array parsing.
- Concurrent In-Memory Storage: Implemented using
ConcurrentHashMapto ensure thread safety for concurrent API requests without introducing the operational overhead of an external database for this specific scope.