This document defines the essential use cases of the system. It describes the expected business rules that impact schema, queries, and validations.
Note on actors: All actors in this document represent roles played by system Users. Client is the user who makes reservations. Barber is a specialized user with their own schedule. Administrative Process represents internal or administrative system actions.
Actor: User (Registration)
- System receives email and password
- System validates email format
- System generates and validates the password hash
- User is successfully created
- Email must have a valid format
- Email must be unique
- Password is not stored in plain text
- User is created as the system's base entity
Actor: Administrative Process
- System receives a
userId - System verifies if the user exists
- System verifies if the user is already a barber
- System creates the barber associated with the user
- Barber is a user specialization
- A user can be a barber at most once
- The barber's identity is derived from the user's identity
- Barber is created as active by default
Actor: Client
- Client selects a barber
- Provides
start_timeandend_time - System validates:
- valid time interval
- active barber
- System attempts to create the reservation
- Reservation is successfully created
start_timemust be beforeend_time- The interval must represent a valid reservation time
- The barber must be active
- The system does not pre-check availability beforeband
- Schedule conflicts are handled via database constraint
- Constraint violation results in a reservation conflict error
Actor: Client or Barber
- System verifies if the reservation exists
- System verifies authorization:
- belongs to the client or
- to the barber
- Reservation is marked as cancelled (soft state)
- Reservation is not deleted
- Cancellation persistence (e.g.,
status,canceled_at) not yet implemented
Actor: Barber
- System receives a date range (
start_time/end_time) - Returns the barber's reservations in the period
- Result sorted by
start_time
- Inclusion of cancelled reservations
- Visibility policy per period
Actor: Client
- Returns the client's reservations
- Paginated result
- Sorted by
start_time
- Inclusion of cancelled reservations
- Visibility policy for past reservations
- Dates and times are handled in UTC
Actor: Client (or Public)
- System queries all active barbers
- Returns the list of barbers with their public profile data
- Response must not expose sensitive user data (e.g., password hashes)
- Reflects the architectural decision that Barber is a specialization of User (see ADR-0007)
- Only active barbers are included in the result
Actor: Client or Barber
- System receives a reservation ID and the actor's ID
- System verifies if the reservation exists
- System validates authorization:
- Client can only view their own reservation
- Barber can only view reservations assigned to them
- Returns the reservation details
- IDOR protection must be enforced — actors cannot access reservations they do not own
- Unauthorized access results in an authorization error, not a not-found error (to avoid information leakage)
Actor: User
- System receives credentials (email and password)
- System looks up the user by email
- System verifies the provided password against the stored Argon2 hash
- On success, system issues an Access Token and a Refresh Token
- Refresh token hash is persisted in the database
- Passwords are verified via Argon2 — never compared in plain text
- Access tokens are stateless JWTs with a short expiration (see ADR-0013)
- Refresh tokens are stateful and stored as a hash in the database (see ADR-0014)
- Refresh tokens must never be persisted in plain text
- Invalid credentials result in a generic authentication error (no distinction between wrong email and wrong password)
Actor: Client or Barber
- System receives a reservation ID, the actor's ID, new
start_time, and newend_time - System verifies if the reservation exists
- System validates authorization:
- Client can only reschedule their own reservation
- Barber can only reschedule reservations assigned to them
- System validates the reservation is not in the past (
currentTime >= original start_timeis rejected) - System validates client did not request a reschedule with less than 1 hour of notice
- System validates that
new_end_time > new_start_time - System checks for scheduling conflicts for the barber in the new time window
- Reservation times are updated successfully
- Cancelled reservations cannot be rescheduled — throws a conflict error
- IDOR protection must be enforced — only the owning client or the assigned barber may reschedule
- Reservations whose original
start_timeis already in the past cannot be rescheduled - Clients cannot reschedule with less than 1 hour of notice before the original
start_time - Barbers are not subject to the 1-hour notice restriction
new_end_timemust be strictly afternew_start_time- Rescheduling to a conflicting time window (overlap with another active reservation for the same barber) is rejected via database exclusion constraint