> ## Documentation Index
> Fetch the complete documentation index at: https://docs.equa.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Entity Relationship Diagrams

> Visual ER diagrams for core domain objects in the Equa platform

# Entity Relationship Diagrams

## Core Domain: Users, Organizations, and Members

```mermaid theme={null}
erDiagram
    Users {
        uuid id PK
        citext email UK
        string username
        string passwordHash
        boolean emailVerified
        boolean twoFactorEnabled
        date acceptedTerms
    }

    Profiles {
        uuid id PK
        string fullName
        citext email
        date dateOfBirth
        string phone
        jsonb links
    }

    Organizations {
        uuid id PK
        string name
        Hash operatingAgreement
        int companyType
        int equityStructure
        uuid creator
        string website
        string ein
    }

    Members {
        uuid id PK
        string fullName
        citext email
        uuid organization FK
        uuid user FK
        boolean isIndividual
        string title
    }

    Users ||--|| Profiles : "has profile"
    Users ||--o{ Members : "is member"
    Organizations ||--o{ Members : "has members"
    Users ||--o{ Organizations : "creates"
```

## Cap Table Domain

```mermaid theme={null}
erDiagram
    Organizations ||--o{ SecurityTypes : "defines"
    Organizations ||--o{ Shareholdings : "contains"
    Organizations ||--o{ FundingRounds : "has rounds"
    Organizations ||--o{ Plans : "has ESOP plans"
    Members ||--o{ Shareholdings : "holds"

    SecurityTypes {
        Hash hash PK
        uuid organization FK
        string shareClass
        int shareType
        string name
        boolean certifiedShares
        boolean votingShares
        numeric price
    }

    Shareholdings {
        Hash hash PK
        uuid member FK
        uuid organization FK
        numeric shares
        Hash securityType FK
        date issueDate
        int serialNumber
        string shareholderName
    }

    FundingRounds {
        uuid id PK
        uuid organization FK
        int number
        date endDate
        numeric totalCommon
        numeric totalPreferred
        string name
    }

    CapitalChanges {
        Hash hash PK
        numeric mod
        date timestamp
        uuid organization FK
    }

    Transfers {
        Hash hash PK
        Hash inputs
        Hash outputs
    }

    TransferOutputs {
        Hash hash PK
        Hash holding FK
        uuid owner FK
        numeric value
    }

    Shareholdings ||--o{ Transfers : "transferred via"
    Transfers ||--o{ TransferOutputs : "produces"
```

## ESOP and Vesting Domain

```mermaid theme={null}
erDiagram
    Plans {
        Hash hash PK
        uuid organization FK
        string name
        date boardApprovalDate
        int termYears
        jsonb approvedEquities
    }

    Pools {
        Hash hash PK
        uuid organization FK
        Hash security FK
        numeric shares
        numeric pricePerShare
        string name
    }

    Options {
        Hash hash PK
        uuid organization FK
        Hash security FK
        uuid member FK
        numeric shares
        date startDate
        Hash vestingSchedule FK
    }

    ContinuousVestingSchedules {
        Hash hash PK
        int durationMonths
        int frequencyMonths
        int cliffMonths
        numeric cliffAmount
    }

    DiscreteVestingSchedules {
        Hash hash PK
        Hash events FK
        uuid entity
        string name
    }

    Plans ||--o{ Pools : "creates"
    Plans ||--o{ Options : "grants"
    Options }o--|| Members : "granted to"
    Options }o--|| ContinuousVestingSchedules : "vests per"
    Pools }o--|| SecurityTypes : "of type"
```

## Convertible Instruments Domain

```mermaid theme={null}
erDiagram
    ConvertibleInstruments {
        Hash hash PK
        numeric authorizedRaiseAmount
        string instrumentType
        numeric interestRate
        date maturityDate
        numeric valuationMax
        numeric conversionDiscount
    }

    InstrumentConversions {
        Hash hash PK
        Hash convertibleInstrument FK
        numeric shares
        numeric valuation
    }

    NoteConversions {
        Hash hash PK
        Hash conversion FK
        Hash source FK
        Hash destination FK
        numeric sharesOwed
        numeric value
    }

    Repayments {
        Hash hash PK
        Hash convertibleInstrument FK
        date issueDate
    }

    ConvertibleInstruments ||--o{ InstrumentConversions : "converts to"
    InstrumentConversions ||--o{ NoteConversions : "allocates"
    ConvertibleInstruments ||--o{ Repayments : "repaid via"
```

## Roles and Permissions Domain

```mermaid theme={null}
erDiagram
    Roles {
        uuid id PK
        string name
        string description
        uuid owner
        boolean isShared
    }

    Permissions {
        uuid id PK
        string name
    }

    PermissionsRoles {
        uuid permission FK
        uuid role FK
    }

    MembersRoles {
        uuid member FK
        uuid role FK
    }

    OrganizationsRoles {
        uuid organization FK
        uuid role FK
    }

    GlobalRolesUsers {
        uuid user FK
        int role
    }

    Roles ||--o{ PermissionsRoles : "grants"
    Permissions ||--o{ PermissionsRoles : "assigned via"
    Members ||--o{ MembersRoles : "has roles"
    Roles ||--o{ MembersRoles : "assigned to"
    Organizations ||--o{ OrganizationsRoles : "has roles"
    Users ||--o{ GlobalRolesUsers : "global role"
```

## Files and Data Room Domain

```mermaid theme={null}
erDiagram
    Files {
        uuid id PK
        Hash hash
        string filename
        string url
        string extension
        string contentType
        int size
        uuid owner FK
    }

    DirectoryItems {
        uuid organization PK
        string parentPath PK
        string name PK
        int type
        uuid file FK
        int size
    }

    DataRoomsMembers {
        string dataRoomName PK
        uuid member PK
        uuid permission PK
    }

    Organizations ||--o{ DirectoryItems : "has files in"
    Files ||--o{ DirectoryItems : "referenced by"
    Members ||--o{ DataRoomsMembers : "has access"
```

## Google Drive Integration Domain

```mermaid theme={null}
erDiagram
    GoogleDriveConnections {
        uuid id PK
        uuid organization FK
        uuid connectedBy FK
        string accessToken
        string refreshToken
        string googleEmail
        boolean isActive
    }

    GoogleDriveSyncConfigurations {
        uuid id PK
        uuid organization FK
        uuid connection FK
        string googleFolderId
        string targetDataRoomPath
        boolean syncEnabled
    }

    GoogleDriveSyncHistory {
        uuid id PK
        uuid organization FK
        uuid configuration FK
        string status
        int filesProcessed
        int filesAdded
    }

    GoogleDriveSyncedFiles {
        uuid id PK
        uuid organization FK
        string googleFileId
        uuid localFileId FK
        string syncStatus
    }

    Organizations ||--o{ GoogleDriveConnections : "connects"
    GoogleDriveConnections ||--o{ GoogleDriveSyncConfigurations : "configures"
    GoogleDriveSyncConfigurations ||--o{ GoogleDriveSyncHistory : "tracks"
    GoogleDriveSyncConfigurations ||--o{ GoogleDriveSyncedFiles : "syncs"
    Files ||--o{ GoogleDriveSyncedFiles : "local copy"
```
