Skip to content

Tax Practice AI - Logical Data Model

Version 1.0 | December 2024


Overview

This document defines the logical data model for the Tax Practice AI system. It describes all entities, their attributes, relationships, and constraints without specifying physical implementation details.

Database: Aurora PostgreSQL (single transactional database) Document Storage: S3 (PDFs, images, signed documents) Retention: 7-year minimum with table partitioning by year


Table of Contents

  1. High-Level Entity Relationship Diagram
  2. Core Domain Entities
  3. Workflow Entities
  4. Communication Entities
  5. Engagement & Compliance Entities
  6. Financial Entities
  7. E-Filing Entities
  8. Identity Verification Entities
  9. Integration Entities
  10. Enum Definitions

1. High-Level Entity Relationship Diagram

erDiagram
    CLIENT ||--o{ CLIENT_CONTACT : has
    CLIENT ||--o{ TAX_RETURN : has
    CLIENT ||--o{ DOCUMENT : owns
    CLIENT ||--o{ ENGAGEMENT : signs
    CLIENT ||--o{ INVOICE : receives
    CLIENT ||--o{ IDENTITY_VERIFICATION : undergoes
    CLIENT ||--o{ FORM_7216_CONSENT : provides

    USER ||--o{ TAX_RETURN : prepares
    USER ||--o{ TAX_RETURN : reviews
    USER ||--|| PTIN_RECORD : has
    USER ||--o{ WORKFLOW_HISTORY : performs
    USER ||--o{ AUDIT_LOG : creates

    TAX_RETURN ||--o{ DOCUMENT : contains
    TAX_RETURN ||--|| WORKFLOW_STATE : has_current
    TAX_RETURN ||--o{ WORKFLOW_HISTORY : has
    TAX_RETURN ||--o{ CLIENT_QUESTION : generates
    TAX_RETURN ||--o{ PREPARER_NOTES : has
    TAX_RETURN ||--o{ ESTIMATED_TAX_PAYMENT : produces
    TAX_RETURN ||--o| EFILING_TRANSMISSION : files
    TAX_RETURN ||--o| EXTENSION : extends
    TAX_RETURN ||--o| SUREPREP_BINDER : processes
    TAX_RETURN ||--o| INVOICE : bills

    DOCUMENT ||--o{ DOCUMENT_EXTRACTION : extracts
    DOCUMENT ||--o| SMARTVAULT_DOCUMENT : syncs

    DOCUMENT_EXTRACTION ||--o{ EXTRACTED_FIELD : contains

    EFILING_TRANSMISSION ||--o{ EFILING_ACKNOWLEDGEMENT : receives
    EFILING_ACKNOWLEDGEMENT ||--o| EFILING_REJECTION : has

    INVOICE ||--o{ PAYMENT : receives

    ESTIMATED_TAX_PAYMENT ||--o{ ESTIMATED_TAX_REMINDER : triggers

    IDENTITY_VERIFICATION ||--o| GOOGLE_MEET_SESSION : uses

    SUREPREP_BINDER ||--o{ SUREPREP_EXTRACTION : contains

    TRANSMITTER_ACCOUNT ||--o{ TRANSMITTER_STATE_COVERAGE : covers
    EFILING_TRANSMISSION }o--|| TRANSMITTER_ACCOUNT : uses

    CLIENT ||--o{ SMARTVAULT_FOLDER : has
    SMARTVAULT_FOLDER ||--o{ SMARTVAULT_DOCUMENT : contains

    TAX_RETURN ||--o{ GOOGLE_SIGNATURE_REQUEST : requires
    TAX_RETURN ||--o| AMENDED_RETURN : amends

    INVOICE ||--o| STRIPE_PAYMENT_INTENT : processes

2. Core Domain Entities

2.1 CLIENT

Master record for all clients (individuals, businesses, trusts).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
account_number VARCHAR(20) UNIQUE, NOT NULL Firm-assigned account number
client_type client_type_enum NOT NULL individual, business, trust, nonprofit
name VARCHAR(255) NOT NULL Display name (individual or business)
email VARCHAR(255) NOT NULL Primary email address
phone VARCHAR(20) Primary phone number
address_line1 VARCHAR(255) Street address
address_line2 VARCHAR(255) Suite/Apt
city VARCHAR(100) City
state VARCHAR(2) State code
zip VARCHAR(10) ZIP code
ssn_last4 VARCHAR(4) Last 4 of SSN (for verification)
ein VARCHAR(10) EIN for business clients
status client_status_enum NOT NULL, DEFAULT 'active' active, inactive, closed
prior_year_agi DECIMAL(12,2) Prior year AGI (for Tier 1 verification)
preferred_contact_method contact_method_enum DEFAULT 'email' email, sms, phone, portal
created_at TIMESTAMP NOT NULL, DEFAULT NOW() Record creation
updated_at TIMESTAMP NOT NULL, DEFAULT NOW() Last modification

Indexes: - account_number (unique) - email - (state, status) for geographic queries


2.2 CLIENT_CONTACT

Additional contacts associated with a client (spouse, dependents, representatives).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Parent client
relationship relationship_enum NOT NULL spouse, dependent, representative, other
first_name VARCHAR(100) NOT NULL First name
last_name VARCHAR(100) NOT NULL Last name
email VARCHAR(255) Contact email
phone VARCHAR(20) Contact phone
ssn_last4 VARCHAR(4) Last 4 of SSN
date_of_birth DATE DOB (for dependents)
is_primary BOOLEAN DEFAULT FALSE Primary contact flag
can_receive_documents BOOLEAN DEFAULT FALSE Can access tax documents
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - (client_id, relationship)


2.3 USER

Staff user accounts (preparers, reviewers, admins).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
email VARCHAR(255) UNIQUE, NOT NULL Login email
first_name VARCHAR(100) NOT NULL First name
last_name VARCHAR(100) NOT NULL Last name
role user_role_enum NOT NULL admin, preparer, reviewer, ea_cpa
ptin VARCHAR(10) PTIN (Pxxxxxxxx format)
is_active BOOLEAN DEFAULT TRUE Account active flag
mfa_enabled BOOLEAN DEFAULT FALSE MFA requirement
last_login_at TIMESTAMP Last successful login
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - email (unique) - role

Business Rules: - Users with role 'ea_cpa' must have valid PTIN - MFA required for all users accessing client data


2.4 TAX_RETURN

Individual tax return record for a specific client and tax year.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client owning this return
tax_year INTEGER NOT NULL Tax year (e.g., 2024)
return_type return_type_enum NOT NULL 1040, 1120, 1120S, 1065, 1041, 990
filing_status filing_status_enum single, married_joint, married_separate, head_of_household, qualifying_widow
assigned_preparer_id UUID FK → USER Assigned preparer
assigned_reviewer_id UUID FK → USER Assigned reviewer (EA/CPA)
completion_percentage INTEGER DEFAULT 0, CHECK 0-100 Progress indicator
priority priority_enum DEFAULT 'normal' low, normal, high, rush
due_date DATE Filing deadline
extended_due_date DATE Extended deadline if applicable
filed_date TIMESTAMP When return was e-filed
accepted_date TIMESTAMP When IRS accepted
federal_refund_amount DECIMAL(12,2) Federal refund (negative = owed)
state_refund_amount DECIMAL(12,2) State refund (negative = owed)
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - (tax_year, return_type) - assigned_preparer_id - (client_id, tax_year) unique constraint

Partitioning: By tax_year for 7-year retention


2.5 DOCUMENT

Metadata for uploaded tax documents (actual content stored in S3).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Owning client
tax_return_id UUID FK → TAX_RETURN Associated return (if known)
document_type document_type_enum NOT NULL W-2, 1099-INT, K-1, etc.
original_filename VARCHAR(255) NOT NULL Original upload filename
s3_key VARCHAR(500) NOT NULL S3 object key
s3_bucket VARCHAR(100) NOT NULL S3 bucket name
file_size_bytes BIGINT NOT NULL File size
mime_type VARCHAR(100) NOT NULL MIME type
file_hash VARCHAR(64) NOT NULL SHA-256 hash for integrity
source document_source_enum NOT NULL client_upload, smartvault, email, preparer
is_native_pdf BOOLEAN True if native PDF (not scanned)
malware_scanned BOOLEAN DEFAULT FALSE Malware scan completed
malware_scan_date TIMESTAMP When scanned
malware_clean BOOLEAN Scan result
status document_status_enum DEFAULT 'uploaded' uploaded, scanning, processing, verified, quarantined
tax_year INTEGER Tax year for this document
uploaded_by UUID FK → USER User who uploaded (if staff)
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - tax_return_id - (client_id, tax_year) - document_type - s3_key (unique)


2.6 DOCUMENT_EXTRACTION

Extracted structured data from a document.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
document_id UUID FK → DOCUMENT, NOT NULL Source document
tax_return_id UUID FK → TAX_RETURN Target return
extraction_source extraction_source_enum NOT NULL sureprep, claude_bedrock, manual
sureprep_binder_id UUID FK → SUREPREP_BINDER SurePrep binder reference
overall_confidence DECIMAL(3,2) CHECK 0.00-1.00 Overall extraction confidence
verification_status verification_status_enum NOT NULL verified, auto_verified, pending_review, partially_verified, unverified, error
verified_by UUID FK → USER User who verified
verified_at TIMESTAMP Verification timestamp
extracted_data JSONB Full extracted data as JSON
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - document_id - tax_return_id - verification_status


2.7 EXTRACTED_FIELD

Individual field extracted from a document.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
extraction_id UUID FK → DOCUMENT_EXTRACTION, NOT NULL Parent extraction
field_name VARCHAR(100) NOT NULL Field identifier (e.g., 'wages', 'employer_ein')
field_value TEXT Extracted value
form_box VARCHAR(20) Tax form box reference (e.g., '1', '2a')
confidence DECIMAL(3,2) CHECK 0.00-1.00 Field-level confidence
source field_source_enum NOT NULL text_layer, ocr_high, ocr_medium, ocr_low, manual
is_verified BOOLEAN DEFAULT FALSE Manually verified
original_value TEXT Value before correction
created_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - extraction_id - (extraction_id, field_name)


3. Workflow Entities

3.1 WORKFLOW_STATE

Current workflow state for a tax return (one per return).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, UNIQUE, NOT NULL Associated return
current_state workflow_state_enum NOT NULL Current state
entered_at TIMESTAMP NOT NULL When entered current state
assigned_to UUID FK → USER Current assignee
progress_percentage INTEGER DEFAULT 0 Derived progress
notes TEXT Current state notes
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id (unique) - current_state - assigned_to


3.2 WORKFLOW_HISTORY

Audit trail of all workflow state transitions.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Associated return
from_state workflow_state_enum Previous state (null for initial)
to_state workflow_state_enum NOT NULL New state
transitioned_at TIMESTAMP NOT NULL, DEFAULT NOW() Transition time
transitioned_by UUID FK → USER User who triggered
transition_reason TEXT Reason for transition
duration_seconds INTEGER Time spent in from_state
metadata JSONB Additional context

Indexes: - tax_return_id - transitioned_at - to_state

Partitioning: By transitioned_at (monthly)


4. Communication Entities

4.1 CLIENT_QUESTION

Questions generated for clients during preparation.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Associated return
client_id UUID FK → CLIENT, NOT NULL Target client
question_text TEXT NOT NULL Question content
question_category question_category_enum NOT NULL income_verification, deduction_clarification, life_event, dependents, business, other
source question_source_enum NOT NULL ai_generated, preparer_created
priority priority_enum DEFAULT 'normal' low, normal, high
status question_status_enum DEFAULT 'pending' pending, answered, expired, withdrawn
asked_by UUID FK → USER Preparer who asked
asked_at TIMESTAMP NOT NULL, DEFAULT NOW() When asked
due_date DATE Response due date
response_text TEXT Client's response
responded_at TIMESTAMP When responded
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - client_id - status - (status, due_date) for escalation queries


4.2 CLIENT_MESSAGE

Messages exchanged with clients via portal/email/SMS.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client
tax_return_id UUID FK → TAX_RETURN Associated return
question_id UUID FK → CLIENT_QUESTION Related question
direction message_direction_enum NOT NULL inbound, outbound
channel communication_channel_enum NOT NULL portal, email, sms
message_type message_type_enum NOT NULL question_response, document_submission, status_update, general
subject VARCHAR(255) Message subject
body TEXT NOT NULL Message content
sent_by UUID FK → USER Staff sender (if outbound)
read_at TIMESTAMP When client read (outbound)
created_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - tax_return_id - question_id - (client_id, created_at)


4.3 PREPARER_NOTES

Internal notes on tax returns (not visible to clients).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Associated return
document_id UUID FK → DOCUMENT Related document
created_by UUID FK → USER, NOT NULL Note author
note_text TEXT NOT NULL Note content
note_type note_type_enum NOT NULL general, flag_for_review, research_needed, client_followup
is_resolved BOOLEAN DEFAULT FALSE Issue resolved
resolved_by UUID FK → USER Who resolved
resolved_at TIMESTAMP When resolved
created_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - (tax_return_id, note_type) - (is_resolved, note_type) for open issues


5. Engagement & Compliance Entities

5.1 ENGAGEMENT

Signed engagement letters for client relationships.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client
tax_year INTEGER NOT NULL Engagement year
engagement_type engagement_type_enum NOT NULL tax_prep, advisory, representation
template_id VARCHAR(50) NOT NULL Template used
status engagement_status_enum DEFAULT 'draft' draft, sent, viewed, signed, expired
generated_at TIMESTAMP When generated
sent_at TIMESTAMP When sent for signature
signed_at TIMESTAMP When signed
signer_name VARCHAR(255) Name of signer
signer_email VARCHAR(255) Email of signer
unsigned_s3_key VARCHAR(500) S3 key for unsigned doc
signed_s3_key VARCHAR(500) S3 key for signed doc
google_signature_id VARCHAR(100) Google Workspace signature ID
expires_at DATE Engagement expiration
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - (client_id, tax_year) - status


IRS Form 7216 consent tracking for disclosure.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client
tax_year INTEGER NOT NULL Consent year
consent_scope TEXT NOT NULL What is being disclosed
status consent_status_enum DEFAULT 'pending' pending, signed, expired, revoked
generated_at TIMESTAMP When generated
signed_at TIMESTAMP When signed
expires_at DATE NOT NULL Consent expiration
consent_s3_key VARCHAR(500) S3 key for signed consent
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - (client_id, tax_year) - (status, expires_at)


5.3 PTIN_RECORD

Preparer Tax Identification Number tracking.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
user_id UUID FK → USER, UNIQUE, NOT NULL Staff member
ptin VARCHAR(10) NOT NULL PTIN (Pxxxxxxxx)
issue_date DATE When issued
expiration_date DATE NOT NULL Expiration date
is_active BOOLEAN DEFAULT TRUE Currently valid
last_verified_at TIMESTAMP Last IRS verification
renewal_alert_sent BOOLEAN DEFAULT FALSE 60-day alert sent
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - user_id (unique) - expiration_date


5.4 AUDIT_LOG

Immutable audit trail for all system activity.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
correlation_id UUID NOT NULL Request correlation ID
actor_id UUID User ID (null for system)
actor_type actor_type_enum NOT NULL user, system, ai
action audit_action_enum NOT NULL create, read, update, delete, export, print, sign, file
resource_type VARCHAR(50) NOT NULL Entity type affected
resource_id UUID Entity ID affected
client_id UUID Client context
tax_return_id UUID Return context
before_value JSONB State before change
after_value JSONB State after change
ip_address INET Client IP
user_agent VARCHAR(500) Browser/client info
outcome audit_outcome_enum NOT NULL success, failure, denied
error_message TEXT Error details if failed
created_at TIMESTAMP NOT NULL, DEFAULT NOW() Immutable timestamp

Indexes: - correlation_id - actor_id - (resource_type, resource_id) - client_id - created_at

Partitioning: By created_at (monthly), 7-year retention

Note: This table is append-only. No UPDATE or DELETE operations permitted.


6. Financial Entities

6.1 INVOICE

Client billing records.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Billed client
tax_return_id UUID FK → TAX_RETURN Associated return
invoice_number VARCHAR(20) UNIQUE, NOT NULL Invoice number
tax_year INTEGER Tax year billed
invoice_date DATE NOT NULL Invoice date
due_date DATE NOT NULL Payment due date
base_fee DECIMAL(10,2) NOT NULL Base preparation fee
complexity_adjustment DECIMAL(10,2) DEFAULT 0 Complexity add/subtract
rush_fee DECIMAL(10,2) DEFAULT 0 Rush processing fee
discount DECIMAL(10,2) DEFAULT 0 Discounts applied
subtotal DECIMAL(10,2) NOT NULL Pre-tax total
tax_amount DECIMAL(10,2) DEFAULT 0 Sales tax if applicable
total_amount DECIMAL(10,2) NOT NULL Grand total
amount_paid DECIMAL(10,2) DEFAULT 0 Total payments received
balance_due DECIMAL(10,2) GENERATED total_amount - amount_paid
status invoice_status_enum DEFAULT 'draft' draft, sent, viewed, partial, paid, overdue, void
sent_at TIMESTAMP When sent to client
paid_at TIMESTAMP When fully paid
stripe_invoice_id VARCHAR(100) Stripe invoice ID
notes TEXT Invoice notes
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - tax_return_id - invoice_number (unique) - status - (status, due_date) for overdue queries


6.2 PAYMENT

Payment records (linked to Stripe).

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
invoice_id UUID FK → INVOICE, NOT NULL Associated invoice
amount DECIMAL(10,2) NOT NULL Payment amount
payment_method payment_method_enum NOT NULL card, ach, check, cash, other
status payment_status_enum DEFAULT 'pending' pending, completed, failed, refunded
stripe_payment_id VARCHAR(100) Stripe payment intent ID
stripe_charge_id VARCHAR(100) Stripe charge ID
payment_date TIMESTAMP When payment completed
confirmation_number VARCHAR(50) Confirmation for display
refund_amount DECIMAL(10,2) Amount refunded
refund_date TIMESTAMP When refunded
refund_reason TEXT Refund reason
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - invoice_id - stripe_payment_id - status


6.3 ESTIMATED_TAX_PAYMENT

Quarterly estimated tax payment tracking.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client
tax_return_id UUID FK → TAX_RETURN, NOT NULL Source return
tax_year INTEGER NOT NULL Tax year for estimates
quarter INTEGER NOT NULL, CHECK 1-4 Quarter (1-4)
due_date DATE NOT NULL Payment due date
federal_amount DECIMAL(10,2) Federal estimate
state_code VARCHAR(2) State (if applicable)
state_amount DECIMAL(10,2) State estimate
total_amount DECIMAL(10,2) NOT NULL Total due
voucher_s3_key VARCHAR(500) S3 key for 1040-ES
state_voucher_s3_key VARCHAR(500) S3 key for state voucher
status estimated_payment_status_enum DEFAULT 'scheduled' scheduled, reminder_sent, confirmed_paid, missed
confirmed_paid_at TIMESTAMP When client confirmed payment
payment_confirmation VARCHAR(100) Client's confirmation number
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - tax_return_id - (tax_year, quarter) - (status, due_date)


6.4 ESTIMATED_TAX_REMINDER

Reminders sent for estimated tax payments.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
estimated_payment_id UUID FK → ESTIMATED_TAX_PAYMENT, NOT NULL Payment reference
reminder_type reminder_type_enum NOT NULL 14_day, 3_day
channel communication_channel_enum NOT NULL email, sms, both
sent_at TIMESTAMP NOT NULL When sent
email_sent BOOLEAN DEFAULT FALSE Email delivered
sms_sent BOOLEAN DEFAULT FALSE SMS delivered
created_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - estimated_payment_id - (reminder_type, sent_at)


7. E-Filing Entities

7.1 EFILING_TRANSMISSION

E-file submission record.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Return being filed
transmitter_account_id UUID FK → TRANSMITTER_ACCOUNT, NOT NULL Transmitter used
transmission_type transmission_type_enum NOT NULL original, resubmission, amended
status transmission_status_enum DEFAULT 'queued' queued, transmitting, transmitted, error
queued_at TIMESTAMP NOT NULL When queued
transmitted_at TIMESTAMP When sent to IRS
federal_submission_id VARCHAR(50) IRS submission ID
state_submissions JSONB {state_code: submission_id}
error_message TEXT Transmission error details
retry_count INTEGER DEFAULT 0 Number of retries
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - status - transmitted_at


7.2 EFILING_ACKNOWLEDGEMENT

IRS/State acknowledgement of e-filed return.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
transmission_id UUID FK → EFILING_TRANSMISSION, NOT NULL Transmission
jurisdiction VARCHAR(10) NOT NULL 'federal' or state code
ack_type ack_type_enum NOT NULL accepted, rejected, pending
ack_date TIMESTAMP NOT NULL Acknowledgement timestamp
confirmation_number VARCHAR(50) Acceptance confirmation
irs_submission_id VARCHAR(50) IRS-assigned ID
raw_response JSONB Full response payload
created_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - transmission_id - (jurisdiction, ack_type) - ack_date


7.3 EFILING_REJECTION

Details of e-file rejection.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
acknowledgement_id UUID FK → EFILING_ACKNOWLEDGEMENT, NOT NULL Rejection ack
error_code VARCHAR(20) NOT NULL IRS/state error code
error_category rejection_category_enum NOT NULL data_mismatch, missing_info, duplicate, technical, fraud_indicator
error_message TEXT NOT NULL Human-readable error
field_name VARCHAR(100) Specific field if applicable
is_auto_correctable BOOLEAN DEFAULT FALSE Can system auto-fix
resolution_status resolution_status_enum DEFAULT 'pending' pending, in_progress, resolved, escalated
assigned_to UUID FK → USER Assigned for resolution
resolution_notes TEXT Resolution details
resolved_at TIMESTAMP When resolved
resolved_by UUID FK → USER Who resolved
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - acknowledgement_id - error_category - resolution_status - assigned_to


7.4 EXTENSION

Form 4868 extension filing.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Return being extended
client_id UUID FK → CLIENT, NOT NULL Client
tax_year INTEGER NOT NULL Tax year
original_due_date DATE NOT NULL Original deadline
extended_due_date DATE NOT NULL Extended deadline
estimated_tax_liability DECIMAL(12,2) Estimated tax owed
payment_amount DECIMAL(12,2) Amount paid with extension
form_s3_key VARCHAR(500) S3 key for Form 4868
status extension_status_enum DEFAULT 'draft' draft, filed, accepted, rejected
filed_at TIMESTAMP When filed
confirmation_number VARCHAR(50) IRS confirmation
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - client_id - (tax_year, status)


8. Identity Verification Entities

8.1 IDENTITY_VERIFICATION

Client identity verification record.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client being verified
verification_tier verification_tier_enum NOT NULL tier1, tier2, tier3
status id_verification_status_enum DEFAULT 'initiated' initiated, in_progress, passed, failed, expired
initiated_at TIMESTAMP NOT NULL, DEFAULT NOW() When started
completed_at TIMESTAMP When completed
method verification_method_enum prior_year_agi, magic_link, id_document, video_call, in_person, notarized
persona_inquiry_id VARCHAR(100) Persona.com inquiry ID
persona_confidence_score DECIMAL(3,2) Persona score (0.00-1.00)
fraud_indicators JSONB Any fraud flags
verified_by UUID FK → USER Staff who verified (Tier 3)
notes TEXT Verification notes
expires_at TIMESTAMP Verification expiration
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - status - (client_id, verification_tier)


8.2 GOOGLE_MEET_SESSION

Video verification session for Tier 3.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
verification_id UUID FK → IDENTITY_VERIFICATION, NOT NULL Parent verification
client_id UUID FK → CLIENT, NOT NULL Client
scheduled_at TIMESTAMP NOT NULL Meeting time
meet_link VARCHAR(255) NOT NULL Google Meet URL
calendar_event_id VARCHAR(100) Google Calendar event ID
status meet_session_status_enum DEFAULT 'scheduled' scheduled, in_progress, completed, no_show, cancelled
conducted_by UUID FK → USER, NOT NULL Staff conducting
started_at TIMESTAMP Actual start time
ended_at TIMESTAMP Actual end time
recording_drive_id VARCHAR(100) Google Drive recording ID
outcome meet_outcome_enum verified, not_verified
notes TEXT Session notes
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - verification_id - client_id - scheduled_at - conducted_by


9. Integration Entities

9.1 SMARTVAULT_DOCUMENT

Cached SmartVault document metadata.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
document_id UUID FK → DOCUMENT Our document record
smartvault_id VARCHAR(100) UNIQUE, NOT NULL SmartVault document ID
folder_path VARCHAR(500) NOT NULL SmartVault folder path
filename VARCHAR(255) NOT NULL Filename in SmartVault
file_size BIGINT File size
smartvault_modified_at TIMESTAMP SV modification time
sync_status sync_status_enum DEFAULT 'synced' synced, pending, error
last_synced_at TIMESTAMP Last successful sync
sync_error TEXT Last sync error
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - document_id - smartvault_id (unique) - folder_path - sync_status


9.2 SMARTVAULT_FOLDER

SmartVault folder structure cache.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
client_id UUID FK → CLIENT, NOT NULL Client owner
smartvault_folder_id VARCHAR(100) UNIQUE, NOT NULL SmartVault folder ID
folder_path VARCHAR(500) NOT NULL Full path
folder_name VARCHAR(255) NOT NULL Folder name
folder_type folder_type_enum source_docs, final_returns, engagement, other
tax_year INTEGER Tax year if applicable
parent_folder_id UUID FK → SMARTVAULT_FOLDER Parent folder
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - client_id - smartvault_folder_id (unique) - (client_id, tax_year)


9.3 SUREPREP_BINDER

SurePrep processing binder.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Associated return
sureprep_binder_id VARCHAR(100) UNIQUE, NOT NULL SurePrep's binder ID
binder_status binder_status_enum DEFAULT 'created' created, uploading, processing, ready, exported, error
created_at TIMESTAMP NOT NULL, DEFAULT NOW() When created
submitted_at TIMESTAMP When submitted for processing
processing_complete_at TIMESTAMP When processing finished
export_complete_at TIMESTAMP When exported to UltraTax
document_count INTEGER DEFAULT 0 Documents in binder
error_message TEXT Processing error
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - sureprep_binder_id (unique) - binder_status


9.4 SUREPREP_EXTRACTION

Extraction result from SurePrep.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
binder_id UUID FK → SUREPREP_BINDER, NOT NULL Parent binder
document_id UUID FK → DOCUMENT, NOT NULL Source document
sureprep_doc_id VARCHAR(100) NOT NULL SurePrep document ID
document_type document_type_enum NOT NULL Detected type
extraction_status sureprep_extraction_status_enum NOT NULL verified, auto_verified, pending_review, unverified, error
confidence_score DECIMAL(3,2) Overall confidence
is_native_pdf BOOLEAN Native PDF flag
extracted_fields JSONB All extracted fields
extracted_at TIMESTAMP When extracted
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - binder_id - document_id - extraction_status


9.5 GOOGLE_SIGNATURE_REQUEST

Google Workspace e-signature request.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
tax_return_id UUID FK → TAX_RETURN, NOT NULL Return context
document_id UUID FK → DOCUMENT, NOT NULL Document to sign
document_type signature_doc_type_enum NOT NULL form_8879, engagement, consent, other
signer_email VARCHAR(255) NOT NULL Signer email
signer_name VARCHAR(255) NOT NULL Signer name
google_doc_id VARCHAR(100) Google Doc ID
signature_status signature_status_enum DEFAULT 'pending' pending, sent, viewed, signed, declined, expired
sent_at TIMESTAMP When sent
viewed_at TIMESTAMP When viewed
signed_at TIMESTAMP When signed
signed_document_s3_key VARCHAR(500) S3 key for signed doc
reminder_count INTEGER DEFAULT 0 Reminders sent
last_reminder_at TIMESTAMP Last reminder time
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - tax_return_id - document_id - signature_status - signer_email


9.6 STRIPE_PAYMENT_INTENT

Stripe payment intent tracking.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
invoice_id UUID FK → INVOICE, NOT NULL Associated invoice
stripe_id VARCHAR(100) UNIQUE, NOT NULL Stripe payment intent ID
amount_cents INTEGER NOT NULL Amount in cents
currency VARCHAR(3) DEFAULT 'usd' Currency code
status stripe_status_enum NOT NULL requires_payment_method, requires_action, processing, succeeded, canceled
payment_method_type VARCHAR(50) card, us_bank_account, etc.
receipt_url VARCHAR(500) Stripe receipt URL
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - invoice_id - stripe_id (unique) - status


9.7 TRANSMITTER_ACCOUNT

E-filing transmitter configuration.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
transmitter_name VARCHAR(100) NOT NULL Column Tax, April, Drake, etc.
efin VARCHAR(10) NOT NULL Electronic Filing ID
api_endpoint VARCHAR(255) NOT NULL API base URL
is_active BOOLEAN DEFAULT TRUE Currently active
is_primary BOOLEAN DEFAULT FALSE Primary transmitter
configuration JSONB Transmitter-specific config
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - is_active - is_primary

Note: API credentials stored in AWS Secrets Manager, not in database.


9.8 TRANSMITTER_STATE_COVERAGE

State e-file capabilities per transmitter.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
transmitter_id UUID FK → TRANSMITTER_ACCOUNT, NOT NULL Transmitter
state_code VARCHAR(2) NOT NULL State code
return_types return_type_enum[] NOT NULL Supported return types
is_active BOOLEAN DEFAULT TRUE Currently supported
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - transmitter_id - state_code - (transmitter_id, state_code) unique


9.9 AMENDED_RETURN

Form 1040-X amended return tracking.

Attribute Type Constraints Description
id UUID PK, NOT NULL Primary identifier
original_return_id UUID FK → TAX_RETURN, NOT NULL Original return
amended_return_id UUID FK → TAX_RETURN, NOT NULL New return record
client_id UUID FK → CLIENT, NOT NULL Client
tax_year INTEGER NOT NULL Tax year
amendment_reason TEXT NOT NULL Why amending
original_refund DECIMAL(12,2) Original refund/owed
amended_refund DECIMAL(12,2) Amended refund/owed
difference DECIMAL(12,2) Change amount
created_at TIMESTAMP NOT NULL, DEFAULT NOW()
updated_at TIMESTAMP NOT NULL, DEFAULT NOW()

Indexes: - original_return_id - amended_return_id - client_id


10. Enum Definitions

Client & User Enums

CREATE TYPE client_type_enum AS ENUM ('individual', 'business', 'trust', 'nonprofit');
CREATE TYPE client_status_enum AS ENUM ('active', 'inactive', 'closed');
CREATE TYPE contact_method_enum AS ENUM ('email', 'sms', 'phone', 'portal');
CREATE TYPE relationship_enum AS ENUM ('spouse', 'dependent', 'representative', 'other');
CREATE TYPE user_role_enum AS ENUM ('admin', 'preparer', 'reviewer', 'ea_cpa');

Tax Return Enums

CREATE TYPE return_type_enum AS ENUM ('1040', '1120', '1120S', '1065', '1041', '990', '706', '709');
CREATE TYPE filing_status_enum AS ENUM ('single', 'married_joint', 'married_separate', 'head_of_household', 'qualifying_widow');
CREATE TYPE priority_enum AS ENUM ('low', 'normal', 'high', 'rush');

Document Enums

CREATE TYPE document_type_enum AS ENUM (
    'W-2', 'W-2G',
    '1099-INT', '1099-DIV', '1099-B', '1099-R', '1099-MISC', '1099-NEC', '1099-K', '1099-G', 'SSA-1099',
    'K-1_1065', 'K-1_1120S', 'K-1_1041',
    '1098', '1098-E', '1098-T',
    'BANK_STATEMENT', 'BROKERAGE_STATEMENT', 'PROPERTY_TAX',
    'ENGAGEMENT_LETTER', 'FORM_8879', 'FORM_7216',
    'DRAFT_RETURN', 'FINAL_RETURN', 'EFILE_CONFIRMATION',
    'ID_DOCUMENT', 'OTHER'
);
CREATE TYPE document_source_enum AS ENUM ('client_upload', 'smartvault', 'email', 'preparer');
CREATE TYPE document_status_enum AS ENUM ('uploaded', 'scanning', 'processing', 'verified', 'quarantined');

Extraction Enums

CREATE TYPE extraction_source_enum AS ENUM ('sureprep', 'claude_bedrock', 'manual');
CREATE TYPE verification_status_enum AS ENUM ('verified', 'auto_verified', 'pending_review', 'partially_verified', 'unverified', 'error');
CREATE TYPE field_source_enum AS ENUM ('text_layer', 'ocr_high', 'ocr_medium', 'ocr_low', 'manual');

Workflow Enums

CREATE TYPE workflow_state_enum AS ENUM (
    'intake',
    'documents_pending',
    'ready_for_prep',
    'ai_analysis',
    'in_prep',
    'pending_client_response',
    'ready_for_review',
    'in_review',
    'revisions_needed',
    'approved',
    'pending_signature',
    'ready_to_file',
    'filed',
    'accepted',
    'rejected',
    'complete',
    'needs_review'  -- Exception state
);

Communication Enums

CREATE TYPE question_category_enum AS ENUM ('income_verification', 'deduction_clarification', 'life_event', 'dependents', 'business', 'other');
CREATE TYPE question_source_enum AS ENUM ('ai_generated', 'preparer_created');
CREATE TYPE question_status_enum AS ENUM ('pending', 'answered', 'expired', 'withdrawn');
CREATE TYPE message_direction_enum AS ENUM ('inbound', 'outbound');
CREATE TYPE communication_channel_enum AS ENUM ('portal', 'email', 'sms');
CREATE TYPE message_type_enum AS ENUM ('question_response', 'document_submission', 'status_update', 'general');
CREATE TYPE note_type_enum AS ENUM ('general', 'flag_for_review', 'research_needed', 'client_followup');

Engagement & Compliance Enums

CREATE TYPE engagement_type_enum AS ENUM ('tax_prep', 'advisory', 'representation');
CREATE TYPE engagement_status_enum AS ENUM ('draft', 'sent', 'viewed', 'signed', 'expired');
CREATE TYPE consent_status_enum AS ENUM ('pending', 'signed', 'expired', 'revoked');
CREATE TYPE actor_type_enum AS ENUM ('user', 'system', 'ai');
CREATE TYPE audit_action_enum AS ENUM ('create', 'read', 'update', 'delete', 'export', 'print', 'sign', 'file');
CREATE TYPE audit_outcome_enum AS ENUM ('success', 'failure', 'denied');

Financial Enums

CREATE TYPE invoice_status_enum AS ENUM ('draft', 'sent', 'viewed', 'partial', 'paid', 'overdue', 'void');
CREATE TYPE payment_method_enum AS ENUM ('card', 'ach', 'check', 'cash', 'other');
CREATE TYPE payment_status_enum AS ENUM ('pending', 'completed', 'failed', 'refunded');
CREATE TYPE estimated_payment_status_enum AS ENUM ('scheduled', 'reminder_sent', 'confirmed_paid', 'missed');
CREATE TYPE reminder_type_enum AS ENUM ('14_day', '3_day');

E-Filing Enums

CREATE TYPE transmission_type_enum AS ENUM ('original', 'resubmission', 'amended');
CREATE TYPE transmission_status_enum AS ENUM ('queued', 'transmitting', 'transmitted', 'error');
CREATE TYPE ack_type_enum AS ENUM ('accepted', 'rejected', 'pending');
CREATE TYPE rejection_category_enum AS ENUM ('data_mismatch', 'missing_info', 'duplicate', 'technical', 'fraud_indicator');
CREATE TYPE resolution_status_enum AS ENUM ('pending', 'in_progress', 'resolved', 'escalated');
CREATE TYPE extension_status_enum AS ENUM ('draft', 'filed', 'accepted', 'rejected');

Identity Verification Enums

CREATE TYPE verification_tier_enum AS ENUM ('tier1', 'tier2', 'tier3');
CREATE TYPE id_verification_status_enum AS ENUM ('initiated', 'in_progress', 'passed', 'failed', 'expired');
CREATE TYPE verification_method_enum AS ENUM ('prior_year_agi', 'magic_link', 'id_document', 'video_call', 'in_person', 'notarized');
CREATE TYPE meet_session_status_enum AS ENUM ('scheduled', 'in_progress', 'completed', 'no_show', 'cancelled');
CREATE TYPE meet_outcome_enum AS ENUM ('verified', 'not_verified');

Integration Enums

CREATE TYPE sync_status_enum AS ENUM ('synced', 'pending', 'error');
CREATE TYPE folder_type_enum AS ENUM ('source_docs', 'final_returns', 'engagement', 'other');
CREATE TYPE binder_status_enum AS ENUM ('created', 'uploading', 'processing', 'ready', 'exported', 'error');
CREATE TYPE sureprep_extraction_status_enum AS ENUM ('verified', 'auto_verified', 'pending_review', 'unverified', 'error');
CREATE TYPE signature_doc_type_enum AS ENUM ('form_8879', 'engagement', 'consent', 'other');
CREATE TYPE signature_status_enum AS ENUM ('pending', 'sent', 'viewed', 'signed', 'declined', 'expired');
CREATE TYPE stripe_status_enum AS ENUM ('requires_payment_method', 'requires_action', 'processing', 'succeeded', 'canceled');

Appendix: Key Relationships Summary

Parent Child Cardinality Description
CLIENT CLIENT_CONTACT 1:N Client has multiple contacts
CLIENT TAX_RETURN 1:N Client has returns across years
CLIENT DOCUMENT 1:N Client owns all their documents
CLIENT ENGAGEMENT 1:N Client signs engagements per year
CLIENT INVOICE 1:N Client receives invoices
CLIENT IDENTITY_VERIFICATION 1:N Client may be verified multiple times
USER TAX_RETURN (preparer) 1:N User prepares multiple returns
USER TAX_RETURN (reviewer) 1:N User reviews multiple returns
USER PTIN_RECORD 1:1 User has one PTIN
TAX_RETURN DOCUMENT 1:N Return has multiple documents
TAX_RETURN WORKFLOW_STATE 1:1 Return has one current state
TAX_RETURN WORKFLOW_HISTORY 1:N Return has state history
TAX_RETURN EFILING_TRANSMISSION 1:1 Return has one primary transmission
TAX_RETURN SUREPREP_BINDER 1:1 Return has one SurePrep binder
DOCUMENT DOCUMENT_EXTRACTION 1:N Document may have multiple extractions
DOCUMENT_EXTRACTION EXTRACTED_FIELD 1:N Extraction contains many fields
EFILING_TRANSMISSION EFILING_ACKNOWLEDGEMENT 1:N Transmission gets multiple acks
EFILING_ACKNOWLEDGEMENT EFILING_REJECTION 1:1 Rejection ack has rejection details
INVOICE PAYMENT 1:N Invoice may have multiple payments
ESTIMATED_TAX_PAYMENT ESTIMATED_TAX_REMINDER 1:N Payment gets multiple reminders

Last updated: December 2024