Skip to content

Commit dd8d3ea

Browse files
authored
Merge pull request #283 from nanotaboada/docs/readme-review
docs(readme): align structure and update prose
2 parents 176268b + df87963 commit dd8d3ea

File tree

2 files changed

+91
-47
lines changed

2 files changed

+91
-47
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ REST API for managing football players built with Java and Spring Boot. Implemen
1212
- **Database**: SQLite (file-based runtime, in-memory for tests)
1313
- **Build**: Maven 3 — always use `./mvnw` wrapper
1414
- **Validation**: Bean Validation (JSR-380)
15-
- **Caching**: Spring `@Cacheable` (1-hour TTL)
15+
- **Caching**: Spring `@Cacheable` (simple in-memory, no expiry)
1616
- **Mapping**: ModelMapper
1717
- **Logging**: SLF4J
1818
- **Testing**: JUnit 5 + AssertJ + MockMvc + Mockito
@@ -29,7 +29,7 @@ src/main/java/
2929
├── services/ — Business logic + @Cacheable caching [business layer]
3030
├── repositories/ — Spring Data JPA with derived queries [data layer]
3131
├── models/ — Player entity + DTOs
32-
└── converters/ — ModelMapper entity ↔ DTO transformations
32+
└── converters/ — JPA AttributeConverter for ISO-8601 date handling
3333
src/main/resources/ — application.properties, Logback config
3434
src/test/java/ — test classes mirroring main structure
3535
src/test/resources/ — test config, schema (ddl.sql), seed data (dml.sql)
@@ -120,5 +120,5 @@ Example: `feat(api): add player stats endpoint (#42)`
120120
```text
121121
feat(scope): description (#issue)
122122
123-
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
123+
Co-authored-by: Claude <noreply@anthropic.com>
124124
```

README.md

Lines changed: 88 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nanotaboada_java.samples.spring.boot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=nanotaboada_java.samples.spring.boot)
66
[![codecov](https://codecov.io/gh/nanotaboada/java.samples.spring.boot/branch/master/graph/badge.svg?token=D3FMNG0WOI)](https://codecov.io/gh/nanotaboada/java.samples.spring.boot)
77
[![CodeFactor](https://www.codefactor.io/repository/github/nanotaboada/java.samples.spring.boot/badge)](https://www.codefactor.io/repository/github/nanotaboada/java.samples.spring.boot)
8-
[![License: MIT](https://img.shields.io/badge/License-MIT-white.svg)](https://opensource.org/licenses/MIT)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-3DA639.svg)](https://opensource.org/licenses/MIT)
9+
![Dependabot](https://img.shields.io/badge/Dependabot-contributing-025E8C?logo=dependabot&logoColor=white&labelColor=181818)
10+
![GitHub Copilot](https://img.shields.io/badge/GitHub_Copilot-contributing-8662C5?logo=githubcopilot&logoColor=white&labelColor=181818)
11+
![Claude](https://img.shields.io/badge/Claude-Sonnet_4.6-D97757?logo=claude&logoColor=white&labelColor=181818)
912

1013
Proof of Concept for a RESTful Web Service built with **Spring Boot 4** targeting **JDK 25 (LTS)**. This project demonstrates best practices for building a layered, testable, and maintainable API implementing CRUD operations for a Players resource (Argentina 2022 FIFA World Cup squad).
1114

@@ -15,15 +18,15 @@ Proof of Concept for a RESTful Web Service built with **Spring Boot 4** targetin
1518
- [Tech Stack](#tech-stack)
1619
- [Project Structure](#project-structure)
1720
- [Architecture](#architecture)
18-
- [API Endpoints](#api-endpoints)
21+
- [API Reference](#api-reference)
1922
- [Prerequisites](#prerequisites)
2023
- [Quick Start](#quick-start)
2124
- [Clone](#clone)
2225
- [Build](#build)
2326
- [Run](#run)
2427
- [Access](#access)
2528
- [Testing](#testing)
26-
- [Docker](#docker)
29+
- [Containers](#containers)
2730
- [Build and Start](#build-and-start)
2831
- [Stop](#stop)
2932
- [Reset Database](#reset-database)
@@ -90,80 +93,121 @@ src/test/java/.../test/
9093

9194
## Architecture
9295

96+
Layered architecture with dependency injection via Spring Boot's IoC container and constructor injection using Lombok's `@RequiredArgsConstructor`.
97+
9398
```mermaid
99+
94100
%%{init: {
95101
"theme": "default",
96102
"themeVariables": {
97103
"fontFamily": "Fira Code, Consolas, monospace",
98104
"textColor": "#555",
99105
"lineColor": "#555",
100-
"lineWidth": 2
106+
"clusterBkg": "#f5f5f5",
107+
"clusterBorder": "#ddd"
101108
}
102109
}}%%
103110
104-
graph BT
105-
%% Core Layers
106-
models[models]
107-
repositories[repositories]
108-
services[services]
109-
controllers[controllers]
111+
graph RL
110112
111-
%% Framework Features
112-
SpringBoot[Spring Boot]
113-
SpringDataJPA[Spring Data JPA]
114-
SpringCache[Spring Cache]
115-
SpringValidation[Spring Validation]
113+
tests[tests]
116114
117-
%% External Dependencies
118-
ProjectLombok[Lombok]
115+
subgraph Layer1[" "]
116+
Application[Application]
117+
SpringBoot[Spring Boot]
118+
SpringDoc[SpringDoc]
119+
end
120+
121+
subgraph Layer2[" "]
122+
controllers[controllers]
123+
SpringValidation[Spring Validation]
124+
end
125+
126+
subgraph Layer3[" "]
127+
services[services]
128+
ModelMapper[ModelMapper]
129+
SpringCache[Spring Cache]
130+
end
131+
132+
subgraph Layer4[" "]
133+
repositories[repositories]
134+
SpringDataJPA[Spring Data JPA]
135+
end
136+
137+
models[models]
119138
JakartaPersistence[Jakarta Persistence]
120-
ModelMapper[ModelMapper]
121-
SpringDoc[SpringDoc]
139+
ProjectLombok[Lombok]
122140
123-
%% Tests
124-
tests[tests]
141+
%% Strong dependencies
125142
126-
%% Main Application Flow
127-
models --> repositories
128-
models --> services
143+
%% Layer 1
144+
SpringBoot --> Application
145+
SpringDoc --> Application
146+
controllers --> Application
147+
services --> Application
148+
repositories --> Application
149+
150+
%% Layer 2
151+
SpringValidation --> controllers
152+
services --> controllers
129153
models --> controllers
154+
155+
%% Layer 3
156+
SpringCache --> services
157+
ModelMapper --> services
130158
repositories --> services
131-
services --> controllers
159+
models --> services
132160
133-
%% Framework Features connections
134-
SpringBoot --> controllers
135-
SpringBoot --> services
136-
SpringBoot --> repositories
161+
%% Layer 4
137162
SpringDataJPA --> repositories
138-
SpringCache --> services
139-
SpringValidation --> controllers
163+
models --> repositories
140164
141-
%% External Dependencies connections
142-
JakartaPersistence --> models
143-
ProjectLombok --> models
144-
ModelMapper --> services
145-
SpringDoc --> controllers
165+
%% Soft dependencies
146166
147-
%% Tests connection (dotted)
148167
controllers -.-> tests
149168
services -.-> tests
150169
repositories -.-> tests
151170
152-
%% Styling
171+
%% Cross-cutting
172+
173+
JakartaPersistence --> models
174+
ProjectLombok --> models
175+
176+
%% Node styling with stroke-width
153177
classDef core fill:#b3d9ff,stroke:#6db1ff,stroke-width:2px,color:#555,font-family:monospace;
154178
classDef feat fill:#ffffcc,stroke:#fdce15,stroke-width:2px,color:#555,font-family:monospace;
155179
classDef deps fill:#ffcccc,stroke:#ff8f8f,stroke-width:2px,color:#555,font-family:monospace;
156180
classDef test fill:#ccffcc,stroke:#53c45e,stroke-width:2px,color:#555,font-family:monospace;
157181
158-
class models,repositories,services,controllers core
182+
class Application,models,repositories,services,controllers core
159183
class SpringBoot,SpringDataJPA,SpringCache,SpringValidation feat
160184
class JakartaPersistence,ProjectLombok,ModelMapper,SpringDoc deps
161185
class tests test
162186
```
163187

164-
_Figure: Core application flow (blue), supporting features (yellow), external dependencies (red), and test coverage (green). Not all dependencies are shown._
188+
*Simplified, conceptual view — not all components or dependencies are shown.*
189+
190+
### Arrow Semantics
191+
192+
Arrows follow the injection direction: `A --> B` means A is injected into B. Solid arrows (`-->`) represent active Spring dependencies — beans wired by the IoC container and invoked at runtime. Dotted arrows (`-.->`) represent test dependencies — test classes reference the types they exercise but are not injected into them.
193+
194+
### Composition Root Pattern
195+
196+
`Application` is the composition root: `@SpringBootApplication` triggers component scanning that discovers and registers all beans, `@EnableCaching` activates the caching infrastructure, and `@Bean ModelMapper` declares the mapping dependency explicitly. Constructor injection is enforced throughout via Lombok's `@RequiredArgsConstructor` on `final` fields.
197+
198+
### Layered Architecture
199+
200+
Four layers: Initialization (`Application`), HTTP (`controllers`), Business (`services`), and Data (`repositories`).
201+
202+
Spring and third-party packages are placed inside the subgraph of the layer that uses them — co-residency communicates the relationship without extra arrows: `Spring Boot` and `SpringDoc` in Initialization, `Spring Validation` in HTTP, `Spring Cache` and `ModelMapper` in Business, `Spring Data JPA` in Data.
203+
204+
`models` and `converters` are cross-cutting: `models` defines the JPA entity and DTOs shared across all layers; `converters` holds the `AttributeConverter` that handles ISO-8601 date serialization for `models`. `Jakarta Persistence` and `Lombok` are their respective dependencies. `Lombok` is also used in `services` and `controllers` via `@RequiredArgsConstructor` and `@Slf4j`, though those arrows are omitted for clarity.
205+
206+
### Color Coding
207+
208+
Blue = core application packages, yellow = Spring ecosystem, red = third-party libraries, green = tests.
165209

166-
## API Endpoints
210+
## API Reference
167211

168212
Interactive API documentation is available via Swagger UI at `http://localhost:9000/swagger/index.html` when the server is running.
169213

@@ -172,7 +216,7 @@ Interactive API documentation is available via Swagger UI at `http://localhost:9
172216
- `GET /players` - List all players
173217
- `GET /players/{id}` - Get player by ID
174218
- `GET /players/search/league/{league}` - Search players by league
175-
- `GET /players/search/squadnumber/{squadNumber}` - Get player by squad number
219+
- `GET /players/squadnumber/{squadNumber}` - Get player by squad number
176220
- `POST /players` - Create new player
177221
- `PUT /players/{id}` - Update existing player
178222
- `DELETE /players/{id}` - Remove player
@@ -257,7 +301,7 @@ open target/site/jacoco/index.html
257301

258302
> 💡 **Note:** Dates are stored as ISO-8601 strings for SQLite compatibility. A JPA `AttributeConverter` handles LocalDate ↔ ISO-8601 string conversion transparently. Tests use SQLite in-memory database (jdbc:sqlite::memory:) - the converter works seamlessly with both file-based and in-memory SQLite.
259303
260-
## Docker
304+
## Containers
261305

262306
### Build and Start
263307

@@ -366,4 +410,4 @@ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for det
366410

367411
## Legal
368412

369-
This project is provided for educational and demonstration purposes and may be used in production environments at your discretion. All referenced trademarks, service marks, product names, company names, and logos are the property of their respective owners and are used solely for identification or illustrative purposes.
413+
This project is provided for educational and demonstration purposes and may be used in production at your own discretion. All trademarks, service marks, product names, company names, and logos referenced herein are the property of their respective owners and are used solely for identification or illustrative purposes.

0 commit comments

Comments
 (0)