Scheduling API
Delivery scheduling is more than storing dates: availability, permissions and conflicts in a Go API.
- API project, public code
- Go API development
- Prototype; build blocked
- Go / Gin / GORM / PostgreSQL
what it is
The API models appointments between suppliers and employees. The repository contains JWT authentication, operation and product models, validation services and GORM queries.
the problem
Accepting a delivery requires checking entities, operating hours and overlaps in both employee and supplier schedules. An isolated availability query does not guarantee exclusivity under concurrency.
the constraints
- Validation before writing
- The service checks entities and hours; the repository checks conflicts before creating an appointment.
- Two calendars
HasConflictqueries employees and suppliers, ignoring cancelled appointments.
the architecture
Layers identifiable in the prototype code.
HTTP
Gin, handlers and JWT/RBAC middleware.
Service
Entities, operating hours and appointment state.
Repository
Conflict queries and GORM writes.
Domain
Appointment, employee, supplier and operation.
This is a code map, not evidence of a production service. Files contain truncated sections and the clone does not build.
technical decisions
Separate transport, rules and data
- Handlers delegate to the service; queries live in the repository. This makes each validation location explicit.
- Keeping data access and rules in HTTP handlers.
- The separation has no tests protecting its contracts yet.
Query conflicts before inserting
HasConflictqueries overlaps without loading the entire schedule into memory.- Enforcing exclusivity through a PostgreSQL exclusion constraint.
- The check precedes the write transaction. Concurrent requests can pass the same check.
limits and lessons
The clone does not build
go.sum contains invalid comments. Repository and service files also contain truncated sections and duplicate declarations. The first build error is transcribed below.
Untested rule
There are no _test.go files. The central rule needs cases for boundaries, overlap, cancellation and concurrency.
current state
The available artifact is a backend prototype and its domain model. There is no deployment, usage or performance evidence. Review on 1 October 2026 reproduced the initial build failure.
next questions
- Restore files and go.sum before expanding the domain.
- Test intervals and concurrency; evaluate database-level overlap exclusion.
evidence
go build ./... · 2026-10-01state
malformed go.sum:
go.sum:1: wrong number of fields 7internal/repository/appointment_repository.go
hasConflict, err := r.HasConflict(appointment)
// ...
err = r.db.Transaction(func(tx *gorm.DB) error {
if err := tx.Create(appointment).Error; err != nil {
return err
}
return nil
})sources and review
next: PsyPredict