MyTrainingAtlas Data Model

Full documentation of all entities, fields, types, relationships, and access control rules.

# MyTrainingAtlas — Data Model Documentation
Generated: 2026-09-23

All entities include built-in fields: id, created_date, updated_date, created_by

═══════════════════════════════════════════════════════════
CORE DIRECTORY
═══════════════════════════════════════════════════════════

──────────────────────────────────────
MartialArt
──────────────────────────────────────
Top-level taxonomy for martial arts styles.

Fields:
  name *                string       e.g. Aikido, Judo
  description           string       Short description
  default_terminology   string       Term for a training location (default: "school")

RLS: Public read. Admin-only create/update/delete.

──────────────────────────────────────
LineageIsland
──────────────────────────────────────
A major lineage grouping within a martial art (e.g. "Aikikai").

Fields:
  name *          string    
  martial_art     string    FK → MartialArt.id
  description     string    

RLS: Public read. Admin-only create/update/delete.

──────────────────────────────────────
LineageBranch
──────────────────────────────────────
A sub-branch within a lineage island (e.g. "Hombu Aikikai").

Fields:
  name *            string    
  island            string    FK → LineageIsland.id
  description       string    
  hombu_location    string    Location of the main hombu dojo

RLS: Public read. Admin-only create/update/delete.

──────────────────────────────────────
Dojo
──────────────────────────────────────
The central entity — a martial arts training school.

Fields:
  name *                    string      
  status                    enum        pending_review | active | inactive | needs_review
  martial_art               string      FK → MartialArt.id
  lineage_island            string      FK → LineageIsland.id
  lineage_branch            string      FK → LineageBranch.id
  chief_instructor          string      
  address                   string      Street address / line 1
  address_line2             string      Suburb, suite, etc.
  postal_code               string      
  city *                    string      
  country *                 string      
  latitude                  number      GPS coordinate
  longitude                 number      GPS coordinate
  visitor_policy            enum        open | selective | by_request | closed
  contact_email             string      
  email_verified            boolean     Default: false
  email_source              enum        public | traveller | admin | claimed
  contact_phone             string      
  website_url               string      
  facebook_url              string      
  instagram_url             string      
  google_maps_url           string      
  badge_url                 string      Dojo icon/logo image URL
  notes                     string      Additional notes
  is_featured               boolean     Default: false
  extraction_source         enum        facebook | website | maps | combined | manual
  extraction_confidence     object      Per-field confidence scores from extraction
  affiliate_link_1          string      Optional affiliate link
  affiliate_link_2          string      Optional affiliate link
  location_verified         boolean     Verified by travellers
  location_feedback         array       [{issue, timestamp}] — pin_slightly_off | wrong_building | wrong_street | dojo_has_moved
  last_location_check       datetime    
  schedule_verified         boolean     
  schedule_feedback         array       [{issue, timestamp}] — started_earlier | started_later | cancelled | different_class_type
  last_schedule_check       datetime    
  facilities_verified       boolean     
  facilities_feedback       array       [{issue, timestamp}] — change_room_available | shower_available | no_change_room | no_shower | parking_different
  last_facilities_check     datetime    
  visitor_notes             array       [{note, timestamp}] — factual tips from travellers
  claimed                   boolean     Default: false
  claimed_at                datetime    
  claimed_by                string      Email of claimant

RLS: Public read. Admin-only create/update/delete.

──────────────────────────────────────
TrainingSchedule
──────────────────────────────────────
Weekly class schedule entries for a dojo.

Fields:
  dojo *          string    FK → Dojo.id
  day_of_week *   enum      Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
  start_time      string    HH:MM
  end_time        string    HH:MM
  class_type      string    e.g. "Beginner", "Weapons"

RLS: No restrictions (open).

═══════════════════════════════════════════════════════════
TRAVELLER
═══════════════════════════════════════════════════════════

──────────────────────────────────────
Traveller
──────────────────────────────────────
A registered travelling martial artist.

Fields:
  user_email *              string    Links to Base44 User (email)
  name *                    string    
  home_city                 string    
  home_country              string    
  reliability_score         number    Default: 100
  traveller_training_notes  string    Private notes (visible to owner only)

RLS: Users can only read/update their own record. Admin can see all. Admin-only delete.

──────────────────────────────────────
TravellerQualification
──────────────────────────────────────
A martial arts rank/credential for a traveller.

Fields:
  traveller_id *    string    FK → Traveller.id
  art *             string    e.g. Aikido
  rank *            string    e.g. 1st kyu
  lineage *         string    Style/lineage
  instructor        string    
  years_training    number    
  notes             string    

RLS: No restrictions defined (open).

═══════════════════════════════════════════════════════════
INTRODUCTION FLOW
═══════════════════════════════════════════════════════════

──────────────────────────────────────
Introduction
──────────────────────────────────────
A traveller's request to visit and train at a dojo.

Fields:
  traveller_id *            string    FK → Traveller.id
  dojo_id *                 string    FK → Dojo.id
  qualification_id *        string    FK → TravellerQualification.id
  training_date *           date      Requested visit date
  status                    enum      pending | approved_by_dojo | declined_by_dojo | cancelled_by_traveller
  message_from_traveller    string    Optional message to the dojo
  decline_reason            string    Reason for decline (if declined)
  approved_at               datetime  
  declined_at               datetime  
  traveller_attended        boolean   Post-visit attendance confirmation

RLS: No restrictions defined (open).

──────────────────────────────────────
MagicLinkToken
──────────────────────────────────────
Secure one-time token for dojo approval/decline of an introduction request.

Fields:
  introduction_id *   string      FK → Introduction.id
  token_hash *        string      SHA-256 hash of raw token (raw never stored)
  expires_at *        datetime    72 hours from creation
  used_at             datetime    When consumed (null = still valid)

RLS: Public create/update. Admin-only read/delete.

═══════════════════════════════════════════════════════════
DOJO CLAIM FLOW
═══════════════════════════════════════════════════════════

──────────────────────────────────────
DojoClaimToken
──────────────────────────────────────
Secure one-time token to verify dojo ownership via email.

Fields:
  dojo_id *       string      FK → Dojo.id
  email *         string      Email the token was sent to
  token_hash *    string      SHA-256 hash of raw token
  expires_at *    datetime    30 minutes from creation
  used_at         datetime    When consumed (null = unused)

RLS: Public create/update. Admin-only read/delete.

──────────────────────────────────────
DojoClaimRequest  [LEGACY / UNUSED]
──────────────────────────────────────
Early-stage claim request record (superseded by DojoClaimToken flow).

Fields:
  dojo_name *   string    Name of the dojo being claimed
  email *       string    Contact email
  message       string    Message from claimant

RLS: No restrictions defined (open).

═══════════════════════════════════════════════════════════
DOJO UPDATE FLOW
═══════════════════════════════════════════════════════════

──────────────────────────────────────
DojoPendingUpdates
──────────────────────────────────────
Proposed updates to a dojo's data, pending admin review.

Fields:
  dojo_id *                 string      FK → Dojo.id
  submitted_by_email *      string      Email of submitter
  payload *                 object      JSON object of proposed field changes
  submitted_at *            datetime    
  status                    enum        pending_review | approved | rejected
  reviewed_at               datetime    
  reviewed_by_admin_id      string      Admin email/ID who reviewed
  admin_notes               string      

RLS: Public create. Admin-only read/update/delete.

──────────────────────────────────────
DojoUpdateToken
──────────────────────────────────────
Secure one-time token allowing a dojo owner to submit updates.

Fields:
  dojo_id *     string      FK → Dojo.id
  token *       string      UUID token for the update request
  expires_at *  datetime    30 minutes from creation
  used          boolean     Default: false

RLS: Public create/update. Admin-only read/delete.

──────────────────────────────────────
DojoEmailAuditLog
──────────────────────────────────────
Audit trail for admin changes to a dojo's contact email.

Fields:
  dojo_id *       string      FK → Dojo.id
  admin_email *   string      Email of the admin who made the change
  old_email       string      Previous email (null if first entry)
  new_email *     string      New email address
  reason          string      Reason for the change
  changed_at *    datetime    

RLS: Admin-only create/read/delete. No restrictions on update.

═══════════════════════════════════════════════════════════
RELATIONSHIPS SUMMARY
═══════════════════════════════════════════════════════════

MartialArt ──< LineageIsland ──< LineageBranch
MartialArt ──< Dojo
LineageIsland ──< Dojo
LineageBranch ──< Dojo
Dojo ──< TrainingSchedule
Dojo ──< Introduction
Dojo ──< DojoClaimToken
Dojo ──< DojoPendingUpdates
Dojo ──< DojoUpdateToken
Dojo ──< DojoEmailAuditLog
Traveller ──< TravellerQualification
Traveller ──< Introduction
TravellerQualification ──< Introduction
Introduction ──< MagicLinkToken

* = required field