Data Model
camply shares one SQLAlchemy model set and Alembic migration graph (camply.db) across both SQLite (standalone) and PostgreSQL (distributed).
Storage boundaries
camply.db depends only on base package dependencies plus the optional postgres extra (psycopg). It never imports camply.server or camply.worker.
In standalone mode, SQLite runs with foreign keys enabled, WAL journaling, and a 1,000 ms busy timeout. Long-running provider and notification HTTP calls stay outside database write transactions.
Core data hierarchy
Provider-owned records use composite keys (id, provider_id) so native IDs from different reservation systems never collide:
providers: Supported booking services and a monotoniccatalog_revisioncounter.recreation_areas: Parks or regions with optional descriptions, locations, and cachedDestinationDetailsJSON.campgrounds: Bookable facilities linked to a parent recreation area and provider, with discovery capability columns (campsite_types,has_electric,has_water,has_sewer,pets_allowed,ada_accessible,max_rv_length).search: Denormalized catalog view (EntityType/ProviderID/RecAreaID/CampgroundID) carrying aggregated discovery capabilities for Explore and autocomplete.
On PostgreSQL, search uses a weighted simple-dictionary full-text vector (pg_trgm + GIN indexes) maintained transactionally on catalog sync. On SQLite, search falls back to portable substring matching.
Polling, subscriptions, and results
unique_targets: Shared polling targets keyed by a SHA-256 hash of(provider_id, campground_id, start_date, end_date)withlast_checked_at.user_scans: User subscriptions storingdestination_type(campgroundorrecreation_area),coverage_mode(allorselected), date range,definition_hash, monotonic version counters (definition_revision,coverage_revision,row_version), and fail-closed filters (min_stay_length,preferred_types,require_electric,require_accessible,min_rv_length,allowed_weekdays).scan_targets: Maps recreation-areaUserScanrows to memberUniqueTargetrows, tracking per-round outcomes (pending,retrying,success,failed).scan_results: Latest successful campsite availability snapshot perunique_target, storing site name, standardized type, electric/accessibility flags,permitted_equipment,max_vehicle_length,available_dates, andfound_at.
Successful empty checks clear scan_results; failed checks keep the prior snapshot. User-facing queries and alerts discard nights before the current UTC day and outside the scan window before evaluating filters, allowed_weekdays, and min_stay_length.
Delivery, auth, and access tables
notification_outbox: Durable standalone delivery queue storing credential-free JSON payloads,payload_kind(campgroundorarea),scan_revision,delivery_key, attempt counts (0–4), and allowlisted error categories. Terminal rows expire after 24 hours; pending retries survive restarts.usersanduser_sessions: User accounts (linked viaauth0_idor local session auth), invitation flags (is_early_access_usermapped tois_invited), notification settings, and revocable sessionjtirows.access_requests: Invite-only access requests (pending,approved,rejected) linked to reviewing admins and resulting user accounts.