User Tools

Site Tools


ai:prompt:review-pr-golang

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ai:prompt:review-pr-golang [2026/06/11 14:08] phong2018ai:prompt:review-pr-golang [2026/06/11 14:20] (current) phong2018
Line 15: Line 15:
 ``` ```
 Presentation (HTTP handler) Presentation (HTTP handler)
-    ↓ calls via ITodoUsecase+    ↓ calls via TodoUsecase
 Usecase Usecase
     ↓ imports domain only     ↓ imports domain only
 Domain Domain
   model/       — entities, value objects, domain errors, domain rule constants   model/       — entities, value objects, domain errors, domain rule constants
-  repository/  — ITodoRepository        (method signatures use domain/model types only) +  repository/  — TodoRepository        (method signatures use domain/model types only) 
-  service/     — INotificationClient    (method signatures use domain/model types only) +  service/     — NotificationClient    (method signatures use domain/model types only) 
-               — IFileStorage           (method signatures use stdlib primitives only)+               — FileStorage           (method signatures use stdlib primitives only)
     ↑ implemented by     ↑ implemented by
 Infrastructure Infrastructure
Line 49: Line 49:
 | Interface | Lives in | Reason | | Interface | Lives in | Reason |
 |-----------|----------|--------| |-----------|----------|--------|
-| `ITodoRepository` | `domain/repository/` | usecase consumes it — contract owned by domain | +| `TodoRepository` | `domain/repository/` | usecase consumes it — contract owned by domain | 
-| `INotificationClient` | `domain/service/` | usecase consumes it — named after business intent, not vendor | +| `NotificationClient` | `domain/service/` | usecase consumes it — named after business intent, not vendor | 
-| `IFileStorage` | `domain/service/` | usecase consumes it — vendor-neutral name | +| `FileStorage` | `domain/service/` | usecase consumes it — vendor-neutral name | 
-| `ITodoUsecase` | `usecase/` | presentation consumes it — uses `usecase/dto` types, cannot live in domain | +| `TodoUsecase` | `usecase/` | presentation consumes it — uses `usecase/dto` types, cannot live in domain | 
-| `ITransaction` | `usecase/` | transaction boundary is application orchestration, not a domain rule |+| `Transaction` | `usecase/` | transaction boundary is application orchestration, not a domain rule |
  
-Flag `ITodoUsecase` placed in `domain/` — it would force domain to import `usecase/dto`, breaking the stdlib-only rule.+Flag `TodoUsecase` placed in `domain/` — it would force domain to import `usecase/dto`, breaking the stdlib-only rule.
  
 ### DTO placement rules ### DTO placement rules
Line 76: Line 76:
     → usecase/dto.CreateTodoInput     → usecase/dto.CreateTodoInput
     → map (usecase impl) → domain/model.Todo     → map (usecase impl) → domain/model.Todo
-    → ITodoRepository.Create(ctx, *model.Todo)+    → TodoRepository.Create(ctx, *model.Todo)
     → map (usecase impl) → usecase/dto.TodoOutput     → map (usecase impl) → usecase/dto.TodoOutput
     → JSON response     → JSON response
Line 101: Line 101:
  
 - [ ] Domain sentinel errors live in `domain/model/xxx_error.go` (e.g. `ErrTodoNotFound = errors.New(...)`). - [ ] Domain sentinel errors live in `domain/model/xxx_error.go` (e.g. `ErrTodoNotFound = errors.New(...)`).
-- [ ] Infrastructure returns domain sentinels — never `apperror` types directly (e.g. `sql.ErrNoRows` → `domainModel.ErrTodoNotFound`). 
 - [ ] Presentation middleware maps domain sentinels → HTTP codes via `errors.Is` / `errors.As` — this mapping lives only in middleware, never in usecase or infrastructure. - [ ] Presentation middleware maps domain sentinels → HTTP codes via `errors.Is` / `errors.As` — this mapping lives only in middleware, never in usecase or infrastructure.
 - [ ] `AppError.Err` (internal error) must never be serialized to the client response. - [ ] `AppError.Err` (internal error) must never be serialized to the client response.
-- [ ] No raw SQL errors, gRPC status codes, or stack traces in HTTP responses. 
  
 --- ---
Line 136: Line 134:
  
 - [ ] Define interfaces in the **consumer package**, not in the implementor's package. - [ ] Define interfaces in the **consumer package**, not in the implementor's package.
 +  - **Exception for this project:** `TodoRepository`, `NotificationClient`, `FileStorage` live in `domain/` because the consumer (usecase) depends on domain — this is intentional per the architecture, not a violation.
 - [ ] Keep interfaces minimal — only the methods the consumer actually calls. - [ ] Keep interfaces minimal — only the methods the consumer actually calls.
 - [ ] Flag any interface with 5+ methods as a potential fat interface violation. - [ ] Flag any interface with 5+ methods as a potential fat interface violation.
ai/prompt/review-pr-golang.1781186937.txt.gz · Last modified: by phong2018