name goravel-crud-review description Review and audit a Goravel CRUD implementation for completeness, correctness, and best practices. Checks all API operations, permissions, error handling, query efficiency, route registration, and response consistency. argument-hint [EntityName] allowed-tools Read, Grep, Glob
Goravel CRUD Backend Review
Review CRUD implementation for $ARGUMENTS.
Files to Review
app/http/controllers/<entities>/<entity>_controller.go — API controller
app/services/<entity>_service.go — Service layer
app/models/<entity>.go — Model definition
app/http/requests/<entity>_request.go — Request validators (create + update)
app/auth/permission_constants.go — Permission registration
routes/api.go — Route registration
routes/web.go — Page route (if Inertia page exists)
tests/feature/crud/<entity>*_test.go — Test coverage
Checklist
1. CRUD Operations Completeness
2. Route Registration (routes/api.go)
optionalAuthRouter.Get("/entity-names" , controller.Index)
optionalAuthRouter.Get("/entity-names/search" , controller.Search)
optionalAuthRouter.Get("/entity-names/filters" , controller.FilterMetadata)
optionalAuthRouter.Get("/entity-names/{id}" , controller.Show)
protectedRouter.Post("/entity-names" , controller.Store)
protectedRouter.Put("/entity-names/{id}" , controller.Update)
protectedRouter.Delete("/entity-names/{id}" , controller.Delete)
3. Controller Review
Extends contracts.CrudController[Model, *CreateRequest, *UpdateRequest]
WithAuthChecker configured with correct auth.Service* constant
Permission mapping covers: viewAny, view, create, update, delete
Uses auth.GetScopedPermissionHelper() for scoped permissions
SetBeforeStore sets created_by from authenticated user
All custom endpoints have permission checks (CheckAuth)
Custom endpoints validate input (ID, pagination, etc.)
Proper HTTP status codes (200 OK, 201 Created, 204 No Content, 400 Bad Request, 403 Forbidden, 404 Not Found, 422 Unprocessable)
4. Service Review
5. Model Review
Extends BaseAuditableModel (provides ID, CreatedAt, UpdatedAt, DeletedAt, CreatedBy, UpdatedBy, Creator, Updater)
JSON tags use camelCase: json:"fieldName"
GORM tags specify column names for non-standard fields: gorm:"column:field_name"
Nullable fields use pointer types: *string, *float64, *time.Time
SearchFields() method returns searchable field names
TableName() method returns correct table name
MarshalJSON() custom marshaler handles date formatting (RFC3339)
Array/JSON fields: virtual field with gorm:"-" + storage field with json:"-"
GORM hooks (BeforeSave, AfterFind) for JSON array serialization
6. Request Validation Review
7. Permission Review
Check app/auth/permission_constants.go:
8. Error Handling
9. Query Efficiency
10. Audit Fields
11. Test Coverage
Check tests/feature/crud/:
Test suite exists with SetupSuite, TearDownSuite, SetupTest, TearDownTest
Tests cover all CRUD operations (create, read, update, delete, list)
Tests cover search with min query length
Tests cover pagination (empty, single page, multi-page)
Tests cover sorting (ASC, DESC, multiple fields)
Tests cover filtering
Tests cover permission-based access (authorized vs unauthorized)
Tests cover validation errors (missing required fields, invalid values)
Tests cover not-found scenarios (invalid ID)
Test data properly initialized (arrays as []string{}, not nil)
Database cleaned between tests
Common Issues to Flag
Critical
Missing permission checks on any endpoint
Service constant mismatch between controller and permission_constants.go
Search endpoint registered after {id} route (will never match)
Validation bypass (missing rules on required fields)
Important
Missing WithSearchFields (search returns no results)
Missing sort field mapping (sorting on camelCase fields fails)
Create request missing created_by in ToCreateData
Nullable fields not using pointer types in update request
Array fields not initialized to empty array (causes nil JSON)
Nice-to-have
Missing Swagger annotations
Missing custom error messages in request validation
Statistics endpoint not implemented
Filter metadata not returning enum options
Output
After review, produce a report with:
Summary : Overall implementation quality (Complete / Partial / Missing)
Critical Issues : Must fix before production
Important Issues : Should fix soon
Minor Issues : Nice-to-have improvements
Missing Features : Expected endpoints/functionality not implemented
Test Coverage Gaps : Untested scenarios
Reference
Canonical controller: app/http/controllers/books/book_controller.go
Canonical service: app/services/book_service.go
Canonical model: app/models/book.go
Canonical request: app/http/requests/book_request.go
Canonical test: tests/feature/crud/lender_crud_test.go
Route patterns: routes/api.go