refactor: move createPerson logic into PersonService
Controller was directly calling personRepository.save() for person creation. Extracted into PersonService.createPerson() to enforce Controller → Service → Repository layering. Also documented the layering rules in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
CLAUDE.md
14
CLAUDE.md
@@ -89,6 +89,20 @@ Database migrations live in `src/main/resources/db/migration/` (Flyway). Configu
|
||||
|
||||
Authentication: form login → backend sets session → `auth_token` cookie → hooks.server.ts injects into all backend requests.
|
||||
|
||||
### Backend Layering Rules
|
||||
|
||||
Strict layering must be respected at all times:
|
||||
|
||||
```
|
||||
Controller → Service → Repository → DB
|
||||
```
|
||||
|
||||
- **Controllers** must never inject or call repositories directly. All business logic goes through a service.
|
||||
- **Services** must never reach into another domain's repository directly. If Service A needs data owned by domain B, it calls Service B — not Repository B.
|
||||
- ✅ `DocumentService` → `PersonService.findById()` → `PersonRepository`
|
||||
- ❌ `DocumentService` → `PersonRepository` (bypasses the service layer)
|
||||
- This keeps domain boundaries clear and business logic testable in isolation.
|
||||
|
||||
### Key Design Patterns
|
||||
|
||||
- **Search**: `DocumentSpecifications` (Spring Data JPA Specification pattern) enables composable, dynamic query building for the document search endpoint
|
||||
|
||||
Reference in New Issue
Block a user