# Data Connect Architecture Guide

## 1. Introduction
This guide provides a comprehensive overview of the Firebase Data Connect architecture for this project. It is intended for developers, architects, and technical stakeholders who need to understand the data models, relationships, and API operations. The document consolidates all major domain diagrams, sequence flows, and the complete API catalog into a single reference.

## 2. Table of Contents
- [System Overview](#3-system-overview)
- [Identity Domain](#4-identity-domain)
- [Operations Domain](#5-operations-domain)
- [Billing Domain](#6-billing-domain)
- [Teams Domain](#7-teams-domain)
- [Messaging Domain](#8-messaging-domain)
- [Compliance Domain](#9-compliance-domain)
- [Learning Domain](#10-learning-domain)
- [Operations Sequence Diagrams](#11-operations-sequence-diagrams)
- [API Catalog](#12-api-catalog)

---

## 3. System Overview

### Summary
This section provides a high-level flowchart illustrating the primary workflows and relationships between the system's core entities. It covers the connections between user roles (User, Staff, Vendor, Business), the order fulfillment lifecycle (Order, Shift, Application, Assignment, Invoice), and the communication module (Conversation, Message).

### Full Content
# System Overview Flowchart

## Description
This flowchart illustrates the high-level relationships between the main entities in the system. It shows the core workflows for user roles, order processing, and communication.

## Flowchart
```mermaid
flowchart LR
    subgraph "User Roles"
        U(User) --> S(Staff)
        U --> V(Vendor)
        U --> B(Business)
    end

    subgraph "Order & Fulfillment"
        B --> O(Order)
        V --> O(Order)
        O --> SH(Shift)
        SH --> APP(Application)
        S --> APP
        APP --> AS(Assignment)
        AS --> I(Invoice)
    end

    subgraph "Communication"
        C(Conversation) --> M(Message)
        UC(UserConversation) --> U
        UC --> C
    end

    style S fill:#f9f,stroke:#333,stroke-width:2px
    style V fill:#ccf,stroke:#333,stroke-width:2px
    style B fill:#cfc,stroke:#333,stroke-width:2px
```

---

## 4. Identity Domain

### Summary
This section details the relationships between the key identity entities. It visualizes how a central `User` record connects to different profiles like `Staff`, `Vendor`, and `Business`. The diagram also clarifies the role-based access structure, showing how `Staff` are linked to `Roles` and `RoleCategories` through the `StaffRole` entity.

### Full Content
# Identity Domain Flowchart

## Description
Este diagrama de flujo detalla las relaciones de alto nivel entre las entidades de identidad clave del sistema, como usuarios, personal, proveedores, empresas y sus roles asociados.

## Flowchart
```mermaid
flowchart LR
    U(User) --> S(Staff)
    U --> V(Vendor)
    U --> B(Business)

    S --> SR(StaffRole)
    SR --> R(Role)
    R --> RC(RoleCategory)

    style U fill:#f9f,stroke:#333,stroke-width:2px
    style S fill:#ccf,stroke:#333,stroke-width:2px
    style V fill:#cfc,stroke:#333,stroke-width:2px
    style B fill:#ffc,stroke:#333,stroke-width:2px
```

---

## 5. Operations Domain

### Summary
This section illustrates the complete lifecycle of an order, from creation to final invoicing. The flowchart shows the progression from an `Order` to a `Shift`, which then requires specific `ShiftRoles`. Staff `Users` can submit an `Application` for these roles, leading to the creation of a `WorkForce` record and a final `Assignment`, which ultimately results in an `Invoice`.

### Full Content
# Operations Domain Flowchart

## Description
This flowchart explains the lifecycle of an order, from its creation and staffing to the final invoice generation.

## Flowchart
```mermaid
flowchart TD
    O(Order) --> S(Shift)
    S --> SR(ShiftRole)
    SR --> A(Application)
    U(User) --> A
    A --> W(WorkForce)
    W --> AS(Assignment)
    AS --> I(Invoice)

    style O fill:#f9f,stroke:#333,stroke-width:2px
    style S fill:#ccf,stroke:#333,stroke-width:2px
    style A fill:#cfc,stroke:#333,stroke-width:2px
    style AS fill:#ffc,stroke:#333,stroke-width:2px
    style I fill:#f99,stroke:#333,stroke-width:2px
```

---

## 6. Billing Domain

### Summary
This section provides a data-first view of the billing process, based strictly on evidence from the GraphQL schema. It explains how an `Invoice` is generated from an `Order` and linked to a `Business` and `Vendor`. It also clarifies how financial transactions are tracked via the `RecentPayment` entity, which connects directly to an `Invoice` and `Application`.

### Full Content
# Billing Domain Flowchart

## Description
Based on the repository's schema, the billing process centers around the `Invoice` entity. An `Invoice` is generated in the context of an `Order` and is explicitly linked to both a `Business` (the client) and a `Vendor` (the provider). Each invoice captures essential details from these parent entities. Financial transactions are tracked through the `RecentPayment` entity, which is directly tied to a specific `Invoice`, creating a clear record of payments made against that invoice.

## Verified Relationships (evidence)
- `Invoice.vendorId` -> `Vendor.id` (source: `dataconnect/schema/invoice.gql`)
- `Invoice.businessId` -> `Business.id` (source: `dataconnect/schema/invoice.gql`)
- `Invoice.orderId` -> `Order.id` (source: `dataconnect/schema/invoice.gql`)
- `RecentPayment.invoiceId` -> `Invoice.id` (source: `dataconnect/schema/recentPayment.gql`)
- `RecentPayment.applicationId` -> `Application.id` (source: `dataconnect/schema/recentPayment.gql`)

## Flowchart
```mermaid
flowchart TD
    O(Order) --> I(Invoice)
    B(Business) --> I
    V(Vendor) --> I
    I --> RP(RecentPayment)
    A(Application) --> RP
```

---

## 7. Teams Domain

### Summary
This section outlines the structure of the Teams domain, showing how users are organized and managed. It details the relationships between `Team`, `TeamMember`, and `User`, and the hierarchical structure involving `TeamHub` and `TeamHudDepartment`. The documentation also clarifies how task management (`Task`, `MemberTask`, `TaskComment`) is integrated into the team structure.

### Full Content
# Teams Domain Flowchart

## Description
The Teams domain in this repository organizes users and their associated tasks. The `Team` is the central entity, with a `User` joining via the `TeamMember` join table, which defines their role. Teams can be structured using `TeamHub` (locations) and `TeamHudDepartment` (departments). The domain also includes task management. A `Task` can be assigned to a `TeamMember` through the `MemberTask` entity. Communication on tasks is handled by `TaskComment`, which is linked directly to the `TeamMember` who made the comment, providing a clear link between team structure and actionable work.

## Entities in Scope
- Team
- TeamMember
- User
- TeamHub
- TeamHudDepartment
- Task
- MemberTask
- TaskComment

## Verified Relationships (evidence)
- `TeamMember.teamId` -> `Team.id` (source: `dataconnect/schema/teamMember.gql`)
- `TeamMember.userId` -> `User.id` (source: `dataconnect/schema/teamMember.gql`)
- `TeamMember.teamHubId` -> `TeamHub.id` (source: `dataconnect/schema/teamMember.gql`)
- `TeamHub.teamId` -> `Team.id` (source: `dataconnect/schema/teamHub.gql`, implicit via field name)
- `TeamHudDepartment.teamHubId` -> `TeamHub.id` (source: `dataconnect/schema/teamHudDeparment.gql`)
- `MemberTask.teamMemberId` -> `TeamMember.id` (source: `dataconnect/schema/memberTask.gql`)
- `MemberTask.taskId` -> `Task.id` (source: `dataconnect/schema/memberTask.gql`)
- `TaskComment.teamMemberId` -> `TeamMember.id` (source: `dataconnect/schema/task_comment.gql`)
- Not found: `Team.ownerId` is a generic `String` and does not have a `@ref` to `Vendor` or `Business`.
- Not found: `TaskComment.taskId` exists but has no `@ref` to `Task.id`.

## Flowchart
```mermaid
flowchart TD
    T(Team)
    U(User)
    TK(Task)

    T --> TM(TeamMember)
    U --> TM
    T --> TH(TeamHub)
    TH --> THD(TeamHudDepartment)
    
    TM --> MT(MemberTask)
    TK --> MT
    
    TM --> TC(TaskComment)
```

---

## 8. Messaging Domain

### Summary
This section explains the architecture of the messaging system, which is built around three core entities. It describes how `Conversation` holds metadata, `Message` contains the actual content linked to a sender `User`, and `UserConversation` tracks the state (e.g., unread counts) for each participant in a conversation. The documentation includes both verified and inferred schema relationships.

### Full Content
# Messaging Domain Flowchart

## Description
The messaging system is designed around three core entities. The `Conversation` entity acts as the central container, holding metadata about a specific chat, such as its subject and type (e.g., group chat, client-vendor). The actual content of the conversation is stored in the `Message` entity, where each message is linked to its parent `Conversation` and the `User` who sent it. To track the state for each participant, the `UserConversation` entity links a `User` to a `Conversation` and stores per-user data, such as the number of unread messages and when they last read the chat.

## Entities in Scope
- Conversation
- Message
- UserConversation
- User

## Verified Relationships (evidence)
- `Message.senderId` -> `User.id` (source: `dataconnect/schema/message.gql`)
- `UserConversation.conversationId` -> `Conversation.id` (source: `dataconnect/schema/userConversation.gql`)
- `UserConversation.userId` -> `User.id` (source: `dataconnect/schema/userConversation.gql`)

## Inferred Relationships (if any)
- `Message.conversationId` -> `Conversation.id` (source: `dataconnect/schema/message.gql`, inferred from field name)

## Flowchart
```mermaid
flowchart TB
    subgraph "Conversation Metadata"
        C(Conversation)
    end

    subgraph "Message Content & User State"
        M(Message)
        UC(UserConversation)
        U(User)
    end

    C -- Inferred --- M
    C -- Verified --- UC

    U -- Verified --- UC
    U -- Verified --- M
```

---

## 9. Compliance Domain

### Summary
This section details the compliance and documentation management system for staff members. It explains how `Document` defines required document types, while `StaffDocument` tracks the submissions from `Staff`. The flowchart also illustrates how other compliance-related entities like `RequiredDoc`, `TaxForm`, and `Certificate` are linked directly to a staff member.

### Full Content
# Compliance Domain Flowchart

## Description
The compliance domain manages the necessary documentation and certifications for staff members. The system defines a list of document types via the `Document` entity. Staff members submit their compliance files through `StaffDocument`, which links a specific staff member to a generic document definition. Additionally, `RequiredDoc`, `TaxForm`, and `Certificate` entities are used to track other specific compliance items, such as mandatory documents, tax forms (like W-4s), and professional certificates, all of which are linked back to a particular staff member.

## Entities in Scope
- Document
- StaffDocument
- RequiredDoc
- TaxForm
- Certificate
- Staff

## Verified Relationships (evidence)
- `StaffDocument.documentId` -> `Document.id` (source: `dataconnect/schema/staffDocument.gql`)
- `Certificate.staffId` -> `Staff.id` (source: `dataconnect/schema/certificate.gql`)

## Inferred Relationships (if any)
- `StaffDocument.staffId` -> `Staff.id` (source: `dataconnect/schema/staffDocument.gql`, inferred from field name)
- `RequiredDoc.staffId` -> `Staff.id` (source: `dataconnect/schema/requiredDoc.gql`, inferred from field name)
- `TaxForm.staffId` -> `Staff.id` (source: `dataconnect/schema/taxForm.gql`, inferred from field name)

## Flowchart
```mermaid
flowchart TB
    subgraph "Compliance Requirements"
        D(Document)
    end

    subgraph "Staff Submissions & Documents"
        S(Staff)
        SD(StaffDocument)
        RD(RequiredDoc)
        TF(TaxForm)
        C(Certificate)
    end

    D -- Verified --> SD

    S -- Inferred --> SD
    S -- Inferred --> RD
    S -- Inferred --> TF
    S -- Verified --> C
```

---

## 10. Learning Domain

### Summary
This section describes the learning and training module for staff. It explains how `Course` represents a training module belonging to a `Category`. The `StaffCourse` entity is used to track the enrollment and progress of a `Staff` member. The documentation also notes that while a `Level` entity exists, it is not directly linked to courses in the current schema.

### Full Content
# Learning Domain Flowchart

## Description
The learning domain provides a structured training system for staff. The core component is the `Course`, which represents an individual training module with a title, description, and associated `Category`. While the `Level` entity exists to define progression tiers (e.g., based on experience points), it is not directly linked to courses in the current schema. The `StaffCourse` entity tracks the progress of a staff member in a specific course, recording their completion status and timestamps. Certificates are not explicitly linked to course completion in the schema.

## Entities in Scope
- Course
- Category
- Level
- StaffCourse
- Staff

## Verified Relationships (evidence)
- `Course.categoryId` -> `Category.id` (source: `dataconnect/schema/course.gql`)

## Inferred Relationships (if any)
- `StaffCourse.staffId` -> `Staff.id` (source: `dataconnect/schema/staffCourse.gql`, inferred from field name)
- `StaffCourse.courseId` -> `Course.id` (source: `dataconnect/schema/staffCourse.gql`, inferred from field name)

## Flowchart
```mermaid
flowchart TB
    subgraph "Training Structure"
        C(Course)
        CAT(Category)
        L(Level)
    end

    subgraph "Staff Participation"
        S(Staff)
        SC(StaffCourse)
    end

    CAT -- Verified --> C

    S -- Inferred --> SC
    C -- Inferred --> SC
```

---

## 11. Operations Sequence Diagrams

### Summary
This section provides a sequence diagram that illustrates the step-by-step operational flow from order creation to invoicing. Based on an analysis of the connector mutations, it shows the sequence of events: a `User` creates an `Order`, then a `Shift`, followed by an `Application` and `Assignment`. Finally, an `Invoice` is generated from the original `Order`.

### Full Content
# Operations Sequence Diagrams

## Flow 1: Order to Invoice

### Description
Based on the repository's connector operations, the operational flow begins when a user creates an `Order`. From this order, one or more `Shifts` are generated. A `Staff` member can then apply to a specific `Shift`, creating an `Application`. Subsequently, an `Assignment` is created, linking a `Workforce` member to that `Shift`. While this represents the staffing and fulfillment part of the process, the billing cycle is handled separately. An `Invoice` is generated directly from the parent `Order`, rather than from the individual assignments, consolidating all billing at the order level.

### Verified Steps (Evidence)
- `createOrder` (source: `dataconnect/connector/order/mutations.gql`)
- `createShift` (source: `dataconnect/connector/shift/mutations.gql`)
- `createApplication` (source: `dataconnect/connector/application/mutations.gql`)
- `CreateAssignment` (source: `dataconnect/connector/assignment/mutations.gql`)
- `createInvoice` (source: `dataconnect/connector/invoice/mutations.gql`)

### Sequence Diagram
```mermaid
sequenceDiagram
    participant User
    participant Order
    participant Shift
    participant Application
    participant Assignment
    participant Invoice

    User->>Order: createOrder()
    activate Order
    Order-->>User: new Order
    deactivate Order

    User->>Shift: createShift(orderId)
    activate Shift
    Shift-->>User: new Shift
    deactivate Shift
    
    User->>Application: createApplication(shiftId)
    activate Application
    Application-->>User: new Application
    deactivate Application

    User->>Assignment: CreateAssignment(shiftId, workforceId)
    activate Assignment
    Assignment-->>User: new Assignment
    deactivate Assignment

    User->>Invoice: createInvoice(orderId)
    activate Invoice
    Invoice-->>User: new Invoice
    deactivate Invoice
```

---

## 12. API Catalog

### Summary
This section provides a complete and exhaustive catalog of every GraphQL query and mutation available in the Data Connect API. Generated by inspecting all 48 connector folders, it lists every operation without summarization. The catalog is organized by entity and serves as a definitive reference for all available API endpoints, their purposes, and their parameters.

### Full Content
# API Catalog – Data Connect

## Overview
This document serves as a complete catalog of the available GraphQL queries and mutations for the Firebase Data Connect backend. It is generated automatically by inspecting the `queries.gql` and `mutations.gql` files within each entity's connector directory. This catalog is exhaustive and lists every operation found. Use this guide to understand the available operations, their parameters, and what they affect.

---
## Account
*Manages bank accounts for owners (vendors/businesses).*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listAccounts` | Retrieves a list of all accounts. | - | `[Account]` |
| `getAccountById` | Fetches a single account by its unique ID. | `id: UUID!` | `Account` |
| `getAccountsByOwnerId` | Finds all accounts belonging to a specific owner. | `ownerId: UUID!` | `[Account]` |
| `filterAccounts` | Searches for accounts based on bank, type, primary status, or owner. | `bank`, `type`, `isPrimary`, `ownerId` | `[Account]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createAccount` | Adds a new bank account. | `bank`, `type`, `last4`, `isPrimary`, `ownerId` | `Account` |
| `updateAccount` | Modifies an existing bank account. | `id`, `bank`, `type`, `last4`, `isPrimary` | `Account` |
| `deleteAccount` | Removes a bank account. | `id: UUID!` | `Account` |

---
## ActivityLog
*Tracks user activities and notifications.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listActivityLogs` | Retrieves all activity logs. | `offset`, `limit` | `[ActivityLog]` |
| `getActivityLogById`| Fetches a single log by its ID. | `id: UUID!` | `ActivityLog` |
| `listActivityLogsByUserId`| Lists all logs for a specific user. | `userId`, `offset`, `limit` | `[ActivityLog]` |
| `listUnreadActivityLogsByUserId`| Lists unread logs for a user. | `userId`, `offset`, `limit` | `[ActivityLog]` |
| `filterActivityLogs`| Searches logs by user, date range, read status, and type. | `userId`, `dateFrom`, `dateTo`, `isRead`, `activityType`, ... | `[ActivityLog]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createActivityLog` | Creates a new activity log entry. | `userId`, `date`, `title`, `description`, `activityType`, ... | `ActivityLog` |
| `updateActivityLog` | Modifies an existing activity log. | `id`, `title`, `description`, `isRead`, ... | `ActivityLog` |
| `markActivityLogAsRead`| Marks a single log as read. | `id: UUID!` | `ActivityLog` |
| `markActivityLogsAsRead`| Marks multiple logs as read. | `ids: [UUID!]!` | `[ActivityLog]` |
| `deleteActivityLog` | Removes an activity log. | `id: UUID!` | `ActivityLog` |

---
## Application
*Manages staff applications for shifts.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listApplications` | Retrieves all applications. | - | `[Application]` |
| `getApplicationById`| Fetches a single application by its ID. | `id: UUID!` | `Application` |
| `getApplicationsByShiftId`| Finds all applications for a specific shift. | `shiftId: UUID!` | `[Application]` |
| `getApplicationsByShiftIdAndStatus`| Filters applications for a shift by status. | `shiftId`, `status`, `offset`, `limit` | `[Application]` |
| `getApplicationsByStaffId`| Finds all applications submitted by a staff member. | `staffId`, `offset`, `limit` | `[Application]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createApplication` | Creates a new application for a shift. | `shiftId`, `staffId`, `status`, `origin`, `roleId`, ... | `Application` |
| `updateApplicationStatus`| Updates the status of an application. | `id`, `status`, ... | `Application` |
| `deleteApplication` | Deletes an application. | `id: UUID!` | `Application` |

---
## Assignment
*Manages staff assignments to shifts.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listAssignments` | Retrieves all assignments. | `offset`, `limit` | `[Assignment]` |
| `getAssignmentById` | Fetches a single assignment by ID. | `id: UUID!` | `Assignment` |
| `listAssignmentsByWorkforceId` | Lists assignments for a specific workforce member. | `workforceId`, `offset`, `limit` | `[Assignment]` |
| `listAssignmentsByWorkforceIds` | Lists assignments for a set of workforce members. | `workforceIds`, `offset`, `limit` | `[Assignment]` |
| `listAssignmentsByShiftRole` | Lists assignments for a specific role within a shift. | `shiftId`, `roleId`, `offset`, `limit` | `[Assignment]` |
| `filterAssignments` | Filters assignments by status and shift/role IDs. | `shiftIds`, `roleIds`, `status`, `offset`, `limit` | `[Assignment]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `CreateAssignment` | Creates a new assignment. | `workforceId`, `shiftId`, `roleId`, `title`, ... | `Assignment` |
| `UpdateAssignment` | Modifies an existing assignment. | `id`, `status`, `title`, ... | `Assignment` |
| `DeleteAssignment` | Removes an assignment. | `id: UUID!` | `Assignment` |

---
## AttireOption
*Manages attire options for vendors.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listAttireOptions` | Retrieves all attire options. | - | `[AttireOption]` |
| `getAttireOptionById`| Fetches a single attire option by ID. | `id: UUID!` | `AttireOption` |
| `filterAttireOptions`| Searches options by item ID, mandatory status, or vendor. | `itemId`, `isMandatory`, `vendorId` | `[AttireOption]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createAttireOption` | Adds a new attire option. | `itemId`, `label`, `isMandatory`, `vendorId`, ... | `AttireOption` |
| `updateAttireOption` | Modifies an existing attire option. | `id`, `label`, `isMandatory`, ... | `AttireOption` |
| `deleteAttireOption` | Removes an attire option. | `id: UUID!` | `AttireOption` |

---
## BenefitsData
*Tracks staff enrollment in vendor benefit plans.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listBenefitsData` | Retrieves all benefits data records. | `offset`, `limit` | `[BenefitsData]` |
| `getBenefitsDataByKey`| Fetches a record by staff and plan ID. | `staffId`, `vendorBenefitPlanId` | `BenefitsData` |
| `listBenefitsDataByStaffId`| Lists all benefit records for a staff member. | `staffId`, `offset`, `limit` | `[BenefitsData]` |
| `listBenefitsDataByVendorBenefitPlanId`| Lists all staff enrolled in a specific benefit plan. | `vendorBenefitPlanId`, `offset`, `limit` | `[BenefitsData]` |
| `listBenefitsDataByVendorBenefitPlanIds`| Lists records for a set of benefit plans. | `vendorBenefitPlanIds`, `offset`, `limit` | `[BenefitsData]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createBenefitsData` | Creates a new staff benefit enrollment record. | `vendorBenefitPlanId`, `staffId`, `current` | `BenefitsData` |
| `updateBenefitsData` | Updates a staff benefit enrollment record. | `staffId`, `vendorBenefitPlanId`, `current` | `BenefitsData` |
| `deleteBenefitsData` | Deletes a staff benefit enrollment record. | `staffId`, `vendorBenefitPlanId` | `BenefitsData` |

---
## Business
*Manages client/business entities.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listBusinesses` | Retrieves all businesses. | - | `[Business]` |
| `getBusinessesByUserId`| Fetches businesses associated with a user. | `userId: String!` | `[Business]` |
| `getBusinessById` | Fetches a single business by its ID. | `id: UUID!` | `Business` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createBusiness` | Creates a new business profile. | `businessName`, `userId`, `rateGroup`, `status`, ... | `Business` |
| `updateBusiness` | Modifies an existing business profile. | `id`, `businessName`, `status`, ... | `Business` |
| `deleteBusiness` | Deletes a business profile. | `id: UUID!` | `Business` |

---
## Category
*Manages categories for courses, roles, etc.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listCategories` | Retrieves all categories. | - | `[Category]` |
| `getCategoryById` | Fetches a single category by ID. | `id: UUID!` | `Category` |
| `filterCategories` | Searches categories by a custom `categoryId` string or label. | `categoryId`, `label` | `[Category]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createCategory` | Adds a new category. | `categoryId`, `label`, `icon` | `Category` |
| `updateCategory` | Modifies an existing category. | `id`, `label`, `icon`, ... | `Category` |
| `deleteCategory` | Removes a category. | `id: UUID!` | `Category` |

---
## Certificate
*Manages staff certifications.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listCertificates` | Retrieves all certificates. | - | `[Certificate]` |
| `getCertificateById`| Fetches a single certificate by ID. | `id: UUID!` | `Certificate` |
| `listCertificatesByStaffId`| Lists all certificates for a specific staff member. | `staffId: UUID!` | `[Certificate]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `CreateCertificate` | Adds a new certificate for a staff member. | `name`, `status`, `staffId`, ... | `Certificate` |
| `UpdateCertificate` | Modifies an existing certificate. | `id`, `name`, `status`, `expiry`, ... | `Certificate` |
| `DeleteCertificate` | Removes a certificate. | `id: UUID!` | `Certificate` |

---
## ClientFeedback
*Manages feedback from businesses about vendors.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listClientFeedbacks` | Retrieves all feedback records. | `offset`, `limit` | `[ClientFeedback]` |
| `getClientFeedbackById`| Fetches a single feedback record by ID. | `id: UUID!` | `ClientFeedback` |
| `listClientFeedbacksByBusinessId`| Lists all feedback submitted by a business. | `businessId`, `offset`, `limit` | `[ClientFeedback]` |
| `listClientFeedbacksByVendorId`| Lists all feedback received by a vendor. | `vendorId`, `offset`, `limit` | `[ClientFeedback]` |
| `listClientFeedbacksByBusinessAndVendor`| Lists feedback between a specific business-vendor pair. | `businessId`, `vendorId`, ... | `[ClientFeedback]` |
| `filterClientFeedbacks`| Searches feedback by rating and date range. | `ratingMin`, `ratingMax`, `dateFrom`, `dateTo`, ... | `[ClientFeedback]` |
| `listClientFeedbackRatingsByVendorId`| Retrieves all ratings for a vendor to calculate averages. | `vendorId`, `dateFrom`, `dateTo` | `[ClientFeedback]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createClientFeedback`| Submits new feedback. | `businessId`, `vendorId`, `rating`, `comment`, ... | `ClientFeedback` |
| `updateClientFeedback`| Modifies existing feedback. | `id`, `rating`, `comment`, ... | `ClientFeedback` |
| `deleteClientFeedback`| Removes feedback. | `id: UUID!` | `ClientFeedback` |

---
## Contact
*Manages staff emergency contacts.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listEmergencyContacts`| Retrieves all emergency contacts. | - | `[EmergencyContact]` |
| `getEmergencyContactById`| Fetches a single contact by ID. | `id: UUID!` | `EmergencyContact` |
| `getEmergencyContactsByStaffId`| Lists all emergency contacts for a staff member. | `staffId: UUID!` | `[EmergencyContact]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createEmergencyContact`| Adds a new emergency contact. | `name`, `phone`, `relationship`, `staffId` | `EmergencyContact` |
| `updateEmergencyContact`| Modifies an existing emergency contact. | `id`, `name`, `phone`, `relationship` | `EmergencyContact` |
| `deleteEmergencyContact`| Removes an emergency contact. | `id: UUID!` | `EmergencyContact` |

---
## Conversation
*Manages conversation metadata.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listConversations` | Retrieves all conversations. | `offset`, `limit` | `[Conversation]` |
| `getConversationById`| Fetches a single conversation by ID. | `id: UUID!` | `Conversation` |
| `listConversationsByType`| Lists conversations of a specific type. | `conversationType`, `offset`, `limit` | `[Conversation]` |
| `listConversationsByStatus`| Lists conversations with a specific status. | `status`, `offset`, `limit` | `[Conversation]` |
| `filterConversations`| Searches conversations by status, type, and date range. | `status`, `conversationType`, `isGroup`, ... | `[Conversation]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createConversation` | Creates a new conversation thread. | `subject`, `status`, `conversationType`, ... | `Conversation` |
| `updateConversation` | Modifies an existing conversation. | `id`, `subject`, `status`, ... | `Conversation` |
| `updateConversationLastMessage`| Updates the last message preview for a conversation. | `id`, `lastMessage`, `lastMessageAt` | `Conversation` |
| `deleteConversation` | Removes a conversation. | `id: UUID!` | `Conversation` |

---
## Course
*Manages training courses.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listCourses` | Retrieves all courses. | - | `[Course]` |
| `getCourseById` | Fetches a single course by ID. | `id: UUID!` | `Course` |
| `filterCourses` | Searches courses by category, certification status, or level. | `categoryId`, `isCertification`, `levelRequired`, ... | `[Course]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createCourse` | Adds a new course. | `title`, `categoryId`, `xpReward`, ... | `Course` |
| `updateCourse` | Modifies an existing course. | `id`, `title`, `description`, ... | `Course` |
| `deleteCourse` | Removes a course. | `id: UUID!` | `Course` |

---
## CustomRateCard
*Manages custom rate cards.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listCustomRateCards`| Retrieves all custom rate cards. | - | `[CustomRateCard]` |
| `getCustomRateCardById`| Fetches a single rate card by ID. | `id: UUID!` | `CustomRateCard` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createCustomRateCard`| Adds a new rate card. | `name`, `baseBook`, `discount`, `isDefault` | `CustomRateCard` |
| `updateCustomRateCard`| Modifies an existing rate card. | `id`, `name`, `discount`, ... | `CustomRateCard` |
| `deleteCustomRateCard`| Removes a rate card. | `id: UUID!` | `CustomRateCard` |

---
## Document
*Manages document types and definitions.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listDocuments` | Retrieves all document definitions. | - | `[Document]` |
| `getDocumentById` | Fetches a single document definition by ID. | `id: UUID!` | `Document` |
| `filterDocuments` | Searches document definitions by type. | `documentType` | `[Document]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createDocument` | Adds a new document definition. | `documentType`, `name`, `description` | `Document` |
| `updateDocument` | Modifies an existing document definition. | `id`, `name`, `description`, ... | `Document` |
| `deleteDocument` | Removes a document definition. | `id: UUID!` | `Document` |

---
## FaqData
*Manages Frequently Asked Questions.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listFaqDatas` | Retrieves all FAQ data. | - | `[FaqData]` |
| `getFaqDataById` | Fetches a single FAQ data set by ID. | `id: UUID!` | `FaqData` |
| `filterFaqDatas`| Searches FAQ data by category. | `category` | `[FaqData]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createFaqData` | Adds new FAQ data. | `category`, `questions` | `FaqData` |
| `updateFaqData` | Modifies existing FAQ data. | `id`, `category`, `questions` | `FaqData` |
| `deleteFaqData` | Removes FAQ data. | `id: UUID!` | `FaqData` |

---
## Hub
*Manages physical locations or hubs.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listHubs` | Retrieves all hubs. | - | `[Hub]` |
| `getHubById` | Fetches a single hub by ID. | `id: UUID!` | `Hub` |
| `getHubsByOwnerId` | Lists all hubs for a specific owner. | `ownerId: UUID!` | `[Hub]` |
| `filterHubs` | Searches hubs by owner, name, or NFC tag ID. | `ownerId`, `name`, `nfcTagId` | `[Hub]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createHub` | Adds a new hub. | `name`, `ownerId`, `address`, ... | `Hub` |
| `updateHub` | Modifies an existing hub. | `id`, `name`, `address`, ... | `Hub` |
| `deleteHub` | Removes a hub. | `id: UUID!` | `Hub` |

---
## Invoice
*Manages billing and invoices.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listInvoices` | Retrieves all invoices. | `offset`, `limit` | `[Invoice]` |
| `getInvoiceById` | Fetches a single invoice by ID. | `id: UUID!` | `Invoice` |
| `listInvoicesByVendorId`| Lists invoices for a vendor. | `vendorId`, `offset`, `limit` | `[Invoice]` |
| `listInvoicesByBusinessId`| Lists invoices for a business. | `businessId`, `offset`, `limit` | `[Invoice]` |
| `listInvoicesByOrderId`| Lists invoices for an order. | `orderId`, `offset`, `limit` | `[Invoice]` |
| `listInvoicesByStatus`| Lists invoices by status. | `status`, `offset`, `limit` | `[Invoice]` |
| `filterInvoices` | Searches invoices by various criteria and date ranges. | `vendorId`, `businessId`, `status`, `issueDateFrom`, ... | `[Invoice]` |
| `listOverdueInvoices`| Retrieves all overdue, unpaid invoices. | `now: Timestamp!`, `offset`, `limit` | `[Invoice]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createInvoice` | Creates a new invoice. | `status`, `vendorId`, `businessId`, `orderId`, ... | `Invoice` |
| `updateInvoice` | Modifies an existing invoice. | `id`, `status`, `notes`, `disputeReason`, ... | `Invoice` |
| `deleteInvoice` | Deletes an invoice. | `id: UUID!` | `Invoice` |

---
## InvoiceTemplate
*Manages templates for creating invoices.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listInvoiceTemplates`| Retrieves all invoice templates. | `offset`, `limit` | `[InvoiceTemplate]` |
| `getInvoiceTemplateById`| Fetches a single template by ID. | `id: UUID!` | `InvoiceTemplate` |
| `listInvoiceTemplatesByOwnerId`| Lists templates for a specific owner. | `ownerId`, `offset`, `limit` | `[InvoiceTemplate]` |
| `listInvoiceTemplatesByVendorId`| Lists templates tied to a vendor. | `vendorId`, `offset`, `limit` | `[InvoiceTemplate]` |
| `listInvoiceTemplatesByBusinessId`| Lists templates tied to a business. | `businessId`, `offset`, `limit` | `[InvoiceTemplate]` |
| `listInvoiceTemplatesByOrderId`| Lists templates tied to an order. | `orderId`, `offset`, `limit` | `[InvoiceTemplate]` |
| `searchInvoiceTemplatesByOwnerAndName`| Searches for a template by name for a specific owner. | `ownerId`, `name`, `offset`, `limit` | `[InvoiceTemplate]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createInvoiceTemplate`| Adds a new invoice template. | `name`, `ownerId`, ... | `InvoiceTemplate` |
| `updateInvoiceTemplate`| Modifies an existing template. | `id`, `name`, ... | `InvoiceTemplate` |
| `deleteInvoiceTemplate`| Removes a template. | `id: UUID!` | `InvoiceTemplate` |

---
## Level
*Manages experience levels for staff.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listLevels` | Retrieves all levels. | - | `[Level]` |
| `getLevelById` | Fetches a single level by ID. | `id: UUID!` | `Level` |
| `filterLevels` | Searches levels by name or XP required. | `name`, `xpRequired` | `[Level]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createLevel` | Adds a new level. | `name`, `xpRequired`, `icon`, `colors` | `Level` |
| `updateLevel` | Modifies an existing level. | `id`, `name`, `xpRequired`, ... | `Level` |
| `deleteLevel` | Removes a level. | `id: UUID!` | `Level` |

---
## MemberTask
*Junction table linking Team Members to Tasks.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `getMyTasks` | Retrieves all tasks assigned to a team member. | `teamMemberId: UUID!` | `[MemberTask]` |
| `getMemberTaskByIdKey`| Fetches a single assignment by team member and task ID. | `teamMemberId`, `taskId` | `MemberTask` |
| `getMemberTasksByTaskId`| Lists all members assigned to a specific task. | `taskId: UUID!` | `[MemberTask]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createMemberTask` | Assigns a task to a team member. | `teamMemberId`, `taskId` | `MemberTask` |
| `deleteMemberTask` | Unassigns a task from a team member. | `teamMemberId`, `taskId` | `MemberTask` |

---
## Message
*Manages individual messages within a conversation.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listMessages` | Retrieves all messages. | - | `[Message]` |
| `getMessageById` | Fetches a single message by ID. | `id: UUID!` | `Message` |
| `getMessagesByConversationId`| Lists all messages for a specific conversation. | `conversationId: UUID!` | `[Message]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createMessage` | Sends a new message to a conversation. | `conversationId`, `senderId`, `content`, `isSystem` | `Message` |
| `updateMessage` | Modifies an existing message. | `id`, `content`, ... | `Message` |
| `deleteMessage` | Deletes a message. | `id: UUID!` | `Message` |

---
## Order
*Manages work orders from businesses.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listOrders` | Retrieves all orders. | `offset`, `limit` | `[Order]` |
| `getOrderById` | Fetches a single order by ID. | `id: UUID!` | `Order` |
| `getOrdersByBusinessId`| Lists orders for a business. | `businessId`, `offset`, `limit` | `[Order]` |
| `getOrdersByVendorId`| Lists orders for a vendor. | `vendorId`, `offset`, `limit` | `[Order]` |
| `getOrdersByStatus`| Lists orders by status. | `status`, `offset`, `limit` | `[Order]` |
| `getOrdersByDateRange`| Lists orders within a date range. | `start`, `end`, `offset`, `limit` | `[Order]` |
| `getRapidOrders` | Retrieves all orders marked as "RAPID". | `offset`, `limit` | `[Order]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createOrder` | Creates a new order. | `vendorId`, `businessId`, `orderType`, `eventName`, ... | `Order` |
| `updateOrder` | Modifies an existing order. | `id`, `status`, `eventName`, ... | `Order` |
| `deleteOrder` | Deletes an order. | `id: UUID!` | `Order` |

---
## RecentPayment
*Tracks recent payments related to invoices and applications.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listRecentPayments` | Retrieves all recent payments. | `offset`, `limit` | `[RecentPayment]` |
| `getRecentPaymentById`| Fetches a single payment by ID. | `id: UUID!` | `RecentPayment` |
| `listRecentPaymentsByStaffId`| Lists all recent payments for a staff member. | `staffId`, `offset`, `limit` | `[RecentPayment]` |
| `listRecentPaymentsByApplicationId`| Lists payments for an application. | `applicationId`, `offset`, `limit` | `[RecentPayment]` |
| `listRecentPaymentsByInvoiceId`| Lists all payments made for an invoice. | `invoiceId`, `offset`, `limit` | `[RecentPayment]` |
| `listRecentPaymentsByStatus`| Lists recent payments by status. | `status`, `offset`, `limit` | `[RecentPayment]` |
| `listRecentPaymentsByInvoiceIds`| Lists payments for a set of invoices. | `invoiceIds`, `offset`, `limit` | `[RecentPayment]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createRecentPayment` | Creates a new recent payment record. | `staffId`, `applicationId`, `invoiceId`, `status`, ... | `RecentPayment` |
| `updateRecentPayment` | Modifies an existing payment record. | `id`, `status`, ... | `RecentPayment` |
| `deleteRecentPayment` | Deletes a payment record. | `id: UUID!` | `RecentPayment` |

---
## Reports
*Provides source data queries for client-side reports.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listShiftsForCoverage`| Fetches shift data for coverage reports. | `businessId`, `startDate`, `endDate` | `[Shift]` |
| `listApplicationsForCoverage`| Fetches application data for coverage reports. | `shiftIds` | `[Application]` |
| `listShiftsForDailyOpsByBusiness`| Fetches shift data for daily ops reports (business view). | `businessId`, `date` | `[Shift]` |
| `listShiftsForDailyOpsByVendor`| Fetches shift data for daily ops reports (vendor view). | `vendorId`, `date` | `[Shift]` |
| `listApplicationsForDailyOps`| Fetches application data for daily ops reports. | `shiftIds` | `[Application]` |
| `listShiftsForForecastByBusiness`| Fetches shift data for forecast reports (business view). | `businessId`, `startDate`, `endDate` | `[Shift]` |
| `listShiftsForForecastByVendor`| Fetches shift data for forecast reports (vendor view). | `vendorId`, `startDate`, `endDate` | `[Shift]` |
| `listShiftsForNoShowRangeByBusiness`| Fetches shift IDs for no-show reports (business view). | `businessId`, `startDate`, `endDate` | `[Shift]` |
| `listShiftsForNoShowRangeByVendor`| Fetches shift IDs for no-show reports (vendor view). | `vendorId`, `startDate`, `endDate` | `[Shift]` |
| `listApplicationsForNoShowRange`| Fetches application data for no-show reports. | `shiftIds` | `[Application]` |
| `listStaffForNoShowReport`| Fetches staff data for no-show reports. | `staffIds` | `[Staff]` |
| `listInvoicesForSpendByBusiness`| Fetches invoice data for spending reports (business view). | `businessId`, `startDate`, `endDate` | `[Invoice]` |
| `listInvoicesForSpendByVendor`| Fetches invoice data for spending reports (vendor view). | `vendorId`, `startDate`, `endDate` | `[Invoice]` |
| `listInvoicesForSpendByOrder`| Fetches invoice data for spending reports by order. | `orderId`, `startDate`, `endDate` | `[Invoice]` |
| `listTimesheetsForSpend`| Fetches timesheet (shift role) data for spending reports. | `startTime`, `endTime` | `[ShiftRole]` |
| `listShiftsForPerformanceByBusiness`| Fetches shift data for performance reports (business view). | `businessId`, `startDate`, `endDate` | `[Shift]` |
| `listShiftsForPerformanceByVendor`| Fetches shift data for performance reports (vendor view). | `vendorId`, `startDate`, `endDate` | `[Shift]` |
| `listApplicationsForPerformance`| Fetches application data for performance reports. | `shiftIds` | `[Application]` |
| `listStaffForPerformance`| Fetches staff data for performance reports. | `staffIds` | `[Staff]` |

### Mutations
> No mutations found.

---
## Role
*Manages job roles and their pay rates.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listRoles` | Retrieves all roles. | - | `[Role]` |
| `getRoleById` | Fetches a single role by ID. | `id: UUID!` | `Role` |
| `listRolesByVendorId`| Lists all roles for a specific vendor. | `vendorId: UUID!` | `[Role]` |
| `listRolesByroleCategoryId`| Lists all roles within a specific category. | `roleCategoryId: UUID!` | `[Role]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createRole` | Adds a new role. | `name`, `costPerHour`, `vendorId`, `roleCategoryId` | `Role` |
| `updateRole` | Modifies an existing role. | `id`, `name`, `costPerHour`, `roleCategoryId` | `Role` |
| `deleteRole` | Removes a role. | `id: UUID!` | `Role` |

---
## RoleCategory
*Manages categories for roles.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listRoleCategories` | Retrieves all role categories. | - | `[RoleCategory]` |
| `getRoleCategoryById`| Fetches a single role category by ID. | `id: UUID!` | `RoleCategory` |
| `getRoleCategoriesByCategory`| Lists role categories by type. | `category: RoleCategoryType!` | `[RoleCategory]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createRoleCategory` | Adds a new role category. | `roleName`, `category` | `RoleCategory` |
| `updateRoleCategory` | Modifies an existing role category. | `id`, `roleName`, `category` | `RoleCategory` |
| `deleteRoleCategory` | Removes a role category. | `id: UUID!` | `RoleCategory` |

---
## Shift
*Manages individual shifts within an order.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listShifts` | Retrieves all shifts. | `offset`, `limit` | `[Shift]` |
| `getShiftById` | Fetches a single shift by ID. | `id: UUID!` | `Shift` |
| `filterShifts` | Searches shifts by status, order, and date range. | `status`, `orderId`, `dateFrom`, `dateTo`, ... | `[Shift]` |
| `getShiftsByBusinessId`| Lists shifts for a business within a date range. | `businessId`, `dateFrom`, `dateTo`, ... | `[Shift]` |
| `getShiftsByVendorId`| Lists shifts for a vendor within a date range. | `vendorId`, `dateFrom`, `dateTo`, ... | `[Shift]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createShift` | Creates a new shift for an order. | `title`, `orderId`, `startTime`, `endTime`, ... | `Shift` |
| `updateShift` | Modifies an existing shift. | `id`, `title`, `status`, ... | `Shift` |
| `deleteShift` | Deletes a shift. | `id: UUID!` | `Shift` |

---
## ShiftRole
*Junction table for roles needed in a shift.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `getShiftRoleById` | Fetches a single shift role by its composite key. | `shiftId`, `roleId` | `ShiftRole` |
| `listShiftRolesByShiftId`| Lists all roles needed for a specific shift. | `shiftId`, `offset`, `limit` | `[ShiftRole]` |
| `listShiftRolesByRoleId`| Lists all shifts that require a specific role. | `roleId`, `offset`, `limit` | `[ShiftRole]` |
| `listShiftRolesByShiftIdAndTimeRange`| Lists roles for a shift within a time range. | `shiftId`, `start`, `end`, ... | `[ShiftRole]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createShiftRole` | Adds a role requirement to a shift. | `shiftId`, `roleId`, `count`, ... | `ShiftRole` |
| `updateShiftRole` | Modifies a role requirement on a shift. | `shiftId`, `roleId`, `count`, ... | `ShiftRole` |
| `deleteShiftRole` | Removes a role requirement from a shift. | `shiftId`, `roleId` | `ShiftRole` |

---
## Staff
*Manages staff profiles.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listStaff` | Retrieves all staff members. | - | `[Staff]` |
| `getStaffById` | Fetches a single staff member by ID. | `id: UUID!` | `Staff` |
| `getStaffByUserId` | Fetches the staff profile for a user. | `userId: String!` | `[Staff]` |
| `filterStaff` | Searches for staff by owner, name, level, or email. | `ownerId`, `fullName`, `level`, `email` | `[Staff]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `CreateStaff` | Creates a new staff profile. | `userId`, `fullName`, ... | `Staff` |
| `UpdateStaff` | Modifies an existing staff profile. | `id`, `fullName`, `phone`, `email`, ... | `Staff` |
| `DeleteStaff` | Deletes a staff profile. | `id: UUID!` | `Staff` |

---
## StaffAvailability
*Manages staff availability schedules.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listStaffAvailabilities`| Retrieves all availability records. | `offset`, `limit` | `[StaffAvailability]` |
| `listStaffAvailabilitiesByStaffId`| Lists all availability for a staff member. | `staffId`, `offset`, `limit` | `[StaffAvailability]` |
| `getStaffAvailabilityByKey`| Fetches availability for a specific day and time slot. | `staffId`, `day`, `slot` | `StaffAvailability` |
| `listStaffAvailabilitiesByDay`| Lists all staff availability for a specific day. | `day`, `offset`, `limit` | `[StaffAvailability]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createStaffAvailability`| Creates a new availability record. | `staffId`, `day`, `slot`, `status`, ... | `StaffAvailability` |
| `updateStaffAvailability`| Updates an availability record. | `staffId`, `day`, `slot`, `status`, ... | `StaffAvailability` |
| `deleteStaffAvailability`| Deletes an availability record. | `staffId`, `day`, `slot` | `StaffAvailability` |

---
## StaffAvailabilityStats
*Manages staff availability statistics.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listStaffAvailabilityStats`| Retrieves all staff availability stats. | `offset`, `limit` | `[StaffAvailabilityStats]` |
| `getStaffAvailabilityStatsByStaffId`| Fetches stats for a specific staff member. | `staffId: UUID!` | `StaffAvailabilityStats` |
| `filterStaffAvailabilityStats`| Searches stats based on various metrics and date ranges. | `needWorkIndexMin`, `utilizationMin`, `lastShiftAfter`, ... | `[StaffAvailabilityStats]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createStaffAvailabilityStats`| Creates a new stats record for a staff member. | `staffId`, `needWorkIndex`, `utilizationPercentage`, ... | `StaffAvailabilityStats` |
| `updateStaffAvailabilityStats`| Updates a stats record for a staff member. | `staffId`, `needWorkIndex`, `utilizationPercentage`, ... | `StaffAvailabilityStats` |
| `deleteStaffAvailabilityStats`| Deletes a stats record for a staff member. | `staffId: UUID!` | `StaffAvailabilityStats` |

---
## StaffCourse
*Tracks staff progress in courses.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `getStaffCourseById` | Fetches a single staff course record by ID. | `id: UUID!` | `StaffCourse` |
| `listStaffCoursesByStaffId`| Lists all courses a staff member is enrolled in. | `staffId`, `offset`, `limit` | `[StaffCourse]` |
| `listStaffCoursesByCourseId`| Lists all staff enrolled in a specific course. | `courseId`, `offset`, `limit` | `[StaffCourse]` |
| `getStaffCourseByStaffAndCourse`| Fetches the enrollment record for a specific staff/course pair. | `staffId`, `courseId` | `[StaffCourse]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createStaffCourse` | Enrolls a staff member in a course. | `staffId`, `courseId`, `progressPercent`, ... | `StaffCourse` |
| `updateStaffCourse` | Updates progress for a staff member in a course. | `id`, `progressPercent`, `completed`, ... | `StaffCourse` |
| `deleteStaffCourse` | Deletes a staff course enrollment. | `id: UUID!` | `StaffCourse` |

---
## StaffDocument
*Manages documents submitted by staff.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `getStaffDocumentByKey`| Fetches a submitted document by staff and document ID. | `staffId`, `documentId` | `StaffDocument` |
| `listStaffDocumentsByStaffId`| Lists all documents submitted by a staff member. | `staffId`, `offset`, `limit` | `[StaffDocument]` |
| `listStaffDocumentsByDocumentType`| Lists submitted documents of a specific type. | `documentType`, `offset`, `limit` | `[StaffDocument]` |
| `listStaffDocumentsByStatus`| Lists submitted documents by status. | `status`, `offset`, `limit` | `[StaffDocument]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createStaffDocument` | Creates a record for a document submitted by staff. | `staffId`, `documentId`, `status`, ... | `StaffDocument` |
| `updateStaffDocument` | Updates the status of a submitted document. | `staffId`, `documentId`, `status`, `documentUrl`, ... | `StaffDocument` |
| `deleteStaffDocument` | Deletes a submitted document record. | `staffId`, `documentId` | `StaffDocument` |

---
## StaffRole
*Junction table linking Staff to Roles.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listStaffRoles` | Retrieves all staff role assignments. | `offset`, `limit` | `[StaffRole]` |
| `getStaffRoleByKey`| Fetches a single assignment by staff and role ID. | `staffId`, `roleId` | `StaffRole` |
| `listStaffRolesByStaffId`| Lists all roles for a specific staff member. | `staffId`, `offset`, `limit` | `[StaffRole]` |
| `listStaffRolesByRoleId`| Lists all staff who have a specific role. | `roleId`, `offset`, `limit` | `[StaffRole]` |
| `filterStaffRoles` | Searches for assignments by staff and/or role. | `staffId`, `roleId`, `offset`, `limit` | `[StaffRole]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createStaffRole` | Assigns a role to a staff member. | `staffId`, `roleId`, `roleType` | `StaffRole` |
| `deleteStaffRole` | Removes a role from a staff member. | `staffId`, `roleId` | `StaffRole` |

---
## Task
*Manages tasks.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTasks` | Retrieves all tasks. | - | `[Task]` |
| `getTaskById` | Fetches a single task by ID. | `id: UUID!` | `Task` |
| `getTasksByOwnerId`| Lists all tasks for a specific owner. | `ownerId: UUID!` | `[Task]` |
| `filterTasks` | Searches tasks by status or priority. | `status`, `priority` | `[Task]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTask` | Adds a new task. | `taskName`, `priority`, `status`, `ownerId`, ... | `Task` |
| `updateTask` | Modifies an existing task. | `id`, `taskName`, `status`, ... | `Task` |
| `deleteTask` | Deletes a task. | `id: UUID!` | `Task` |

---
## TaskComment
*Manages comments on tasks.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTaskComments` | Retrieves all task comments. | - | `[TaskComment]` |
| `getTaskCommentById`| Fetches a single comment by ID. | `id: UUID!` | `TaskComment` |
| `getTaskCommentsByTaskId`| Lists all comments for a specific task. | `taskId: UUID!` | `[TaskComment]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTaskComment` | Adds a new comment to a task. | `taskId`, `teamMemberId`, `comment`, ... | `TaskComment` |
| `updateTaskComment` | Modifies an existing comment. | `id`, `comment`, ... | `TaskComment` |
| `deleteTaskComment` | Deletes a comment. | `id: UUID!` | `TaskComment` |

---
## TaxForm
*Manages staff tax forms.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTaxForms` | Retrieves all tax forms. | - | `[TaxForm]` |
| `getTaxFormById` | Fetches a single tax form by ID. | `id: UUID!` | `TaxForm` |
| `getTaxFormsBystaffId`| Lists all tax forms for a specific staff member. | `staffId: UUID!` | `[TaxForm]` |
| `filterTaxForms` | Searches tax forms by type, status, or staff. | `formType`, `status`, `staffId` | `[TaxForm]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTaxForm` | Adds a new tax form record. | `formType`, `title`, `staffId`, `formData`, ... | `TaxForm` |
| `updateTaxForm` | Modifies an existing tax form record. | `id`, `status`, `formData`, ... | `TaxForm` |
| `deleteTaxForm` | Deletes a tax form record. | `id: UUID!` | `TaxForm` |

---
## Team
*Manages teams.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTeams` | Retrieves all teams. | - | `[Team]` |
| `getTeamById` | Fetches a single team by ID. | `id: UUID!` | `Team` |
| `getTeamsByOwnerId`| Lists all teams for a specific owner. | `ownerId: String!` | `[Team]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTeam` | Adds a new team. | `teamName`, `ownerId`, `ownerName`, ... | `Team` |
| `updateTeam` | Modifies an existing team. | `id`, `teamName`, ... | `Team` |
| `deleteTeam` | Deletes a team. | `id: UUID!` | `Team` |

---
## TeamHub
*Manages hubs within a team.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTeamHubs` | Retrieves all team hubs. | - | `[TeamHub]` |
| `getTeamHubById` | Fetches a single team hub by ID. | `id: UUID!` | `TeamHub` |
| `getTeamHubsByTeamId`| Lists all hubs for a specific team. | `teamId: UUID!` | `[TeamHub]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTeamHub` | Adds a new hub to a team. | `teamId`, `hubName`, `address`, ... | `TeamHub` |
| `updateTeamHub` | Modifies an existing team hub. | `id`, `hubName`, `address`, ... | `TeamHub` |
| `deleteTeamHub` | Deletes a team hub. | `id: UUID!` | `TeamHub` |

---
## TeamHudDeparment
*Manages departments within a Team Hub.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTeamHudDepartments`| Retrieves all team hub departments. | `offset`, `limit` | `[TeamHudDepartment]` |
| `getTeamHudDepartmentById`| Fetches a single department by ID. | `id: UUID!` | `TeamHudDepartment` |
| `listTeamHudDepartmentsByTeamHubId`| Lists all departments for a specific team hub. | `teamHubId`, `offset`, `limit` | `[TeamHudDepartment]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTeamHudDepartment`| Adds a new department to a team hub. | `name`, `teamHubId`, `costCenter` | `TeamHudDepartment` |
| `updateTeamHudDepartment`| Modifies an existing department. | `id`, `name`, `costCenter`, ... | `TeamHudDepartment` |
| `deleteTeamHudDepartment`| Deletes a department. | `id: UUID!` | `TeamHudDepartment` |

---
## TeamMember
*Manages members of a team.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listTeamMembers` | Retrieves all team members. | - | `[TeamMember]` |
| `getTeamMemberById` | Fetches a single team member by ID. | `id: UUID!` | `TeamMember` |
| `getTeamMembersByTeamId`| Lists all members for a specific team. | `teamId: UUID!` | `[TeamMember]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createTeamMember` | Adds a new member to a team. | `teamId`, `userId`, `role`, ... | `TeamMember` |
| `updateTeamMember` | Modifies an existing team member. | `id`, `role`, `title`, ... | `TeamMember` |
| `updateTeamMemberInviteStatus`| Updates the invitation status for a member. | `id`, `inviteStatus` | `TeamMember` |
| `acceptInviteByCode`| Accepts an invitation to join a team. | `inviteCode: UUID!` | `TeamMember` |
| `cancelInviteByCode`| Cancels a pending invitation. | `inviteCode: UUID!` | `TeamMember` |
| `deleteTeamMember` | Removes a member from a team. | `id: UUID!` | `TeamMember` |

---
## User
*Manages system users.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listUsers` | Retrieves all users. | - | `[User]` |
| `getUserById` | Fetches a single user by their ID (Firebase UID). | `id: String!` | `User` |
| `filterUsers` | Searches for users by ID, email, or role. | `id`, `email`, `role`, `userRole` | `[User]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `CreateUser` | Creates a new user. | `id`, `email`, `fullName`, `role` | `User` |
| `UpdateUser` | Modifies an existing user. | `id`, `email`, `fullName`, `role` | `User` |
| `DeleteUser` | Deletes a user. | `id: String!` | `User` |

---
## UserConversation
*Manages user-specific state for conversations.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listUserConversations`| Retrieves all user conversation records. | `offset`, `limit` | `[UserConversation]` |
| `getUserConversationByKey`| Fetches a record by conversation and user ID. | `conversationId`, `userId` | `UserConversation` |
| `listUserConversationsByUserId`| Lists all conversations a user is part of. | `userId`, `offset`, `limit` | `[UserConversation]` |
| `listUnreadUserConversationsByUserId`| Lists conversations with unread messages for a user. | `userId`, `offset`, `limit` | `[UserConversation]` |
| `listUserConversationsByConversationId`| Lists all participants of a conversation. | `conversationId`, `offset`, `limit` | `[UserConversation]` |
| `filterUserConversations`| Searches records by user, conversation, and read status. | `userId`, `conversationId`, `unreadMin`, ... | `[UserConversation]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createUserConversation`| Adds a user to a conversation. | `conversationId`, `userId`, `unreadCount`, ... | `UserConversation` |
| `updateUserConversation`| Updates a user's state in a conversation. | `conversationId`, `userId`, `unreadCount`, ... | `UserConversation` |
| `markConversationAsRead`| Marks a conversation as read for a user. | `conversationId`, `userId`, `lastReadAt` | `UserConversation` |
| `incrementUnreadForUser`| Increments the unread count for a user. | `conversationId`, `userId`, `unreadCount` | `UserConversation` |
| `deleteUserConversation`| Removes a user from a conversation. | `conversationId`, `userId` | `UserConversation` |

---
## Vendor
*Manages vendor/partner entities.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listVendors` | Retrieves all vendors. | - | `[Vendor]` |
| `getVendorById` | Fetches a single vendor by ID. | `id: UUID!` | `Vendor` |
| `getVendorByUserId` | Fetches vendor profiles for a user. | `userId: String!` | `[Vendor]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createVendor` | Creates a new vendor profile. | `userId`, `companyName`, ... | `Vendor` |
| `updateVendor` | Modifies an existing vendor profile. | `id`, `companyName`, `email`, ... | `Vendor` |
| `deleteVendor` | Deletes a vendor profile. | `id: UUID!` | `Vendor` |

---
## VendorBenefitPlan
*Manages benefit plans offered by vendors.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listVendorBenefitPlans`| Retrieves all vendor benefit plans. | `offset`, `limit` | `[VendorBenefitPlan]` |
| `getVendorBenefitPlanById`| Fetches a single benefit plan by ID. | `id: UUID!` | `VendorBenefitPlan` |
| `listVendorBenefitPlansByVendorId`| Lists all benefit plans for a vendor. | `vendorId`, `offset`, `limit` | `[VendorBenefitPlan]` |
| `listActiveVendorBenefitPlansByVendorId`| Lists active benefit plans for a vendor. | `vendorId`, `offset`, `limit` | `[VendorBenefitPlan]` |
| `filterVendorBenefitPlans`| Searches benefit plans by vendor, title, and active status. | `vendorId`, `title`, `isActive`, ... | `[VendorBenefitPlan]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createVendorBenefitPlan`| Adds a new benefit plan. | `vendorId`, `title`, `isActive`, ... | `VendorBenefitPlan` |
| `updateVendorBenefitPlan`| Modifies an existing benefit plan. | `id`, `title`, `isActive`, ... | `VendorBenefitPlan` |
| `deleteVendorBenefitPlan`| Deletes a benefit plan. | `id: UUID!` | `VendorBenefitPlan` |

---
## VendorRate
*Manages vendor rates.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `listVendorRates` | Retrieves all vendor rates. | - | `[VendorRate]` |
| `getVendorRateById` | Fetches a single vendor rate by ID. | `id: UUID!` | `VendorRate` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createVendorRate` | Adds a new vendor rate. | `vendorId`, `roleName`, `clientRate`, `employeeWage`, ... | `VendorRate` |
| `updateVendorRate` | Modifies an existing vendor rate. | `id`, `clientRate`, `employeeWage`, ... | `VendorRate` |
| `deleteVendorRate` | Deletes a vendor rate. | `id: UUID!` | `VendorRate` |

---
## WorkForce
*Manages the workforce, linking staff to vendors.*

### Queries
| Name | Purpose | Parameters | Returns |
|---|---|---|---|
| `getWorkforceById` | Fetches a single workforce member by ID. | `id: UUID!` | `Workforce` |
| `getWorkforceByVendorAndStaff`| Fetches the workforce record for a specific vendor/staff pair. | `vendorId`, `staffId` | `[Workforce]` |
| `listWorkforceByVendorId`| Lists all workforce members for a vendor. | `vendorId`, `offset`, `limit` | `[Workforce]` |
| `listWorkforceByStaffId`| Lists all vendor associations for a staff member. | `staffId`, `offset`, `limit` | `[Workforce]` |
| `getWorkforceByVendorAndNumber`| Checks for workforce number uniqueness within a vendor. | `vendorId`, `workforceNumber` | `[Workforce]` |

### Mutations
| Name | Purpose | Parameters | Affects |
|---|---|---|---|
| `createWorkforce` | Adds a new staff member to a vendor's workforce. | `vendorId`, `staffId`, `workforceNumber`, ... | `Workforce` |
| `updateWorkforce` | Modifies a workforce member's details. | `id`, `workforceNumber`, `status`, ... | `Workforce` |
| `deactivateWorkforce`| Sets a workforce member's status to INACTIVE. | `id: UUID!` | `Workforce` |
