Skip to content

Accounts Application ER Diagram


erDiagram
    USER {
        int id PK
        string email UNIQUE
        string phone UNIQUE
        bool has_initial_profile
        string photo
        text address
        int gender_id FK
        int country_id FK
        date birthday
        datetime created_at
        datetime updated_at
        string role
    }
    GENDER {
        int id PK
        string gender_type
    }
    COUNTRY {
        int id PK
        string country_name
        string iso_code
    }
    STATE {
        int id PK
        string name
        int country_id FK
    }
    VENDOR {
        int user_id PK, FK
        string company_name
        string telephone
        date company_created_at
        text company_address
        string certificate_image
        string pan_vat_certificate_image
        datetime created_at
        datetime updated_at
    }
    TWO_FACTOR_AUTH {
        int id PK
        int user_id FK
        bool is_enabled
        string totp_secret
        datetime created_at
        datetime updated_at
    }
    DEVICE {
        int id PK
        int two_factor_auth_id FK
        UUID device_uuid 
        string device_name
        datetime login_time
        datetime last_used
        bool is_trusted
        datetime created_at
        datetime updated_at
    }
    ADDRESS {
        int id PK
        int user_id FK
        string name
        string mobile
        string address_line_1
        string address_line_2
        string landmark
        string pincode
        int country_id FK
        int state_id FK
        string town_city
        bool is_default
        datetime created_at
        datetime updated_at
    }
    USER_PROFILE {
        int id PK
        int user_id FK
        string alternative_mobile_number
        text alternative_address_line
        string landmark
        string zipcode
        string city
    }
    VENDOR_BANK_DETAILS {
        int id PK
        int vendor_id FK
        string bank_name
        string account_name
        string account_number 
        string branch_name
        string cheque_book_image
        string swift_code
        datetime created_at
        datetime updated_at
    }
    VENDOR_ONBOARDING_STATUS {
        int id PK
        int vendor_id FK
        string status
        text comment
        bool has_approved
        datetime requested_at
        datetime approved_at
    }
    VENDOR_ROLE {
        int id PK
        string name
    }
    VENDOR_ROLE_PERMISSIONS {
        int id PK
        int user_id FK
        int vendor_id FK
        int assigned_title_id FK
        int role_id FK
        int created_by_id FK
        bool is_active
        bool is_deleted
        datetime created_at
        datetime updated_at
    }
    VENDOR_ASSIGNED_TITLE {
        int id PK
        string name
        string description
    }

    USER ||--o{ GENDER : has
    USER ||--o{ COUNTRY : lives_in
    USER ||--|| VENDOR : is
    COUNTRY ||--o{ STATE : has
    ADDRESS ||--|| USER : belongs_to
    ADDRESS ||--o{ COUNTRY : is_in
    ADDRESS ||--o{ STATE : is_in
    DEVICE ||--|| TWO_FACTOR_AUTH : belongs_to
    USER_PROFILE ||--|| USER : is
    USER_PROFILE ||--o{ ADDRESS : has
    TWO_FACTOR_AUTH ||--o{ DEVICE : secures
    USER ||--o{ TWO_FACTOR_AUTH : enables
    VENDOR ||--|| VENDOR_BANK_DETAILS : has
    VENDOR ||--|| VENDOR_ONBOARDING_STATUS : has
    VENDOR_ROLE ||--o{ VENDOR_ROLE_PERMISSIONS : has
    VENDOR_ASSIGNED_TITLE ||--o{ VENDOR_ROLE_PERMISSIONS : has
    USER ||--o{ VENDOR_ROLE_PERMISSIONS : assigned
    VENDOR ||--o{ VENDOR_ROLE_PERMISSIONS : manages