---
config:
  theme: mc
  layout: dagre
---
classDiagram
direction TB
    class User {
	    id: String
	    email: String
    }

    class Business {
	    id: UUID
	    userId: String
	    businessName: String
	    status: BusinessStatus
    }

    class Vendor {
	    id: UUID
	    userId: String
	    companyName: String
    }

    class Order {
	    id: UUID
	    businessId: UUID
	    vendorId: UUID
	    status: OrderStatus
    }

    class Shift {
	    id: UUID
	    orderId: UUID
	    status: ShiftStatus
    }

    class ShiftRole {
	    shiftId: UUID
	    roleId: UUID
    }

    class Role {
	    id: UUID
	    name: String
	    vendorId: UUID
    }

    class Application {
	    id: UUID
	    shiftId: UUID
	    staffId: UUID
	    roleId: UUID
    }

    class Invoice {
	    id: UUID
	    businessId: UUID
	    vendorId: UUID
	    orderId: UUID
	    status: InvoiceStatus
    }

    class InvoiceTemplate {
	    id: UUID
	    name: String
	    ownerId: UUID
	    businessId: UUID
	    vendorId: UUID
    }

    class RecentPayment {
	    id: UUID
	    invoiceId: UUID
	    applicationId: UUID
	    staffId: UUID
    }

    class ClientFeedback {
	    id: UUID
	    businessId: UUID
	    vendorId: UUID
	    rating: Int
    }

    class Team {
	    id: UUID
	    teamName: String
	    ownerId: String
    }

    class TeamMember {
	    id: UUID
	    teamId: UUID
	    userId: String
	    role: TeamMemberRole
    }

    class TeamHub {
	    id: UUID
	    teamId: UUID
	    hubName: String
    }

    class Staff {
	    id: UUID
	    userId: String
    }

	note for Staff "business can create a staff too"

    Business "1" -- "*" Order : places
    Business "1" -- "*" Invoice : receives
    Business "1" -- "*" ClientFeedback : gives
    Business "1" --o "1" Team : (ownerId)
    Business "1" --o "*" InvoiceTemplate : (ownerId)
    User "1" -- "1" Business : owns
    Vendor "1" -- "*" Order : fulfills
    Vendor "1" -- "*" Invoice : issues
    Order "1" -- "*" Shift : contains
    Order "1" -- "1" Invoice : billed via
    Shift "1" -- "*" ShiftRole : requires
    ShiftRole "1" -- "1" Role
    ShiftRole "1" -- "*" Application : target for
    Application "1" -- "1" Staff
    Application "1" -- "1" RecentPayment
    Invoice "1" -- "*" RecentPayment : paid through
    Team "1" -- "*" TeamHub : contains
    Team "1" -- "*" TeamMember : has