Time-based scheduling, availability, and appointment management
| Tier | domain |
| Role | unclassified (baselined) |
| Path | crates/domain/scheduling |
| Edition | 2021 |
| Targets | domain_scheduling |
| Public items | 0 across 0 modules |
| Tests | 83 |
What it is for
domain-scheduling: Time-based scheduling, availability, and appointment management
Overview
This crate provides scheduling capabilities including availability management, time slots, and appointment booking with conflict detection and exception handling.
Layer
Domain - depends on: foundation-basemodels
Key Concepts
- Schedule - Defines when a resource/person is available for bookings
- AvailabilityBlock - Recurring or one-time availability windows
- TimeSlot - Specific bookable time windows with optional capacity
- Appointment - Confirmed bookings at specific times
- ScheduleException - Blocked time, holidays, vacations, etc.
Key Types
Schedule- A schedule defining availabilityTimeSlot- A specific bookable time windowAppointment- A confirmed bookingSchedulingService- High-level business operations
Example
use domain_scheduling::{
SchedulingService, CreateScheduleRequest, CreateAppointmentRequest
};
use chrono::{Duration, Utc, Weekday, NaiveTime};
let service = SchedulingService::new(pool);
// Create a schedule
let (schedule, event) = service.create_schedule(CreateScheduleRequest {
tenant_id,
name: "Office Hours".to_string(),
default_duration_minutes: Some(30),
..Default::default()
}).await?;
// Add availability (Mon-Fri 9am-5pm)
let start = NaiveTime::from_hms_opt(9, 0, 0).unwrap();
let end = NaiveTime::from_hms_opt(17, 0, 0).unwrap();
service.add_availability(tenant_id, schedule.id, Weekday::Mon, start, end).await?;
// Book an appointment
let (appointment, events) = service.create_appointment(CreateAppointmentRequest {
tenant_id,
schedule_id: schedule.id,
party_id: user_id,
starts_at: Utc::now() + Duration::days(1),
ends_at: Utc::now() + Duration::days(1) + Duration::hours(1),
..Default::default()
}).await?;
println!("Confirmation: {}", appointment.confirmation_code);
Capabilities
No public items.
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into foundation.
Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (41 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | domain |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/domain/scheduling |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_domain["domain"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, serde | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full, test-util | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_scheduling["application-scheduling"] -->|uses| SELF SELF["domain-scheduling"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | domain_scheduling | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-scheduling.
Verification
| Kind | Count |
|---|---|
| Unit tests | 83 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
test_already_cancelled—src/errors.rstest_appointment_not_found—src/errors.rstest_beyond_booking_window—src/errors.rstest_blocked_by_exception—src/errors.rstest_insufficient_notice—src/errors.rstest_invalid_time_range—src/errors.rstest_outside_availability—src/errors.rstest_schedule_not_accepting—src/errors.rstest_schedule_not_found—src/errors.rstest_terminal_status—src/errors.rstest_time_conflict—src/errors.rstest_time_slot_full—src/errors.rstest_time_slot_not_available—src/errors.rstest_time_slot_not_found—src/errors.rstest_validation_error—src/errors.rstest_appointment_cancelled_event—src/events.rstest_appointment_created_event—src/events.rstest_appointment_rescheduled_event—src/events.rstest_availability_added_event—src/events.rstest_event_serialization—src/events.rstest_exception_created_event—src/events.rstest_schedule_created_event—src/events.rstest_schedule_updated_event—src/events.rstest_time_slot_booked_event—src/events.rstest_time_slot_created_event—src/events.rstest_appointment_cancel—src/lib.rstest_appointment_complete—src/lib.rstest_appointment_confirm_pending—src/lib.rstest_appointment_creation—src/lib.rstest_appointment_from_time_slot—src/lib.rs- _… 53 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 6 |
| Source lines | 3994 |
| Code lines | 3285 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 83 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 8 |
| Workspace reverse dependencies | 1 |
pie showData
title Rust source composition
"Code" : 3285
"Blank or comment" : 709
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.