Skip to main content

Database Schema

The Anitone backend runs on Xano (Workspace 4) with a PostgreSQL database. Tables are organized into functional domains.

B2B Sales Tables

ar_distributor

B2B customer accounts (Nutrien Ag, Elders, etc.)
FieldTypeDescription
idintPrimary key
company_nametextCompany name
trading_nametextTrading name
abntextAustralian Business Number
billing_addressjson
shipping_addressjsonDefault shipping address
payment_termsintNet days (30, 60, 90)
credit_limitdecimalMaximum AR balance
price_tierenumstandard, gold, platinum
discount_percentagedecimal% off retail
xero_contact_idtextXero sync reference
statusenumprospect, active, on_hold, archived

ar_contact

Individual contacts at distributor accounts.
FieldTypeDescription
idintPrimary key
distributor_idint→ ar_distributor
first_nametext-
last_nametext-
emailemail-
phonetext-
roletextJob title
is_primaryboolMain contact
is_billing_contactboolReceives invoices/AR comms

ar_purchase_order

Inbound purchase orders from distributors.
FieldTypeDescription
idintPrimary key
distributor_idint→ ar_distributor
po_numbertextDistributor’s PO reference
order_datedate-
required_datedateRequested delivery
statusenumdraft, pending_review, confirmed, invoiced, shipped, delivered, cancelled
subtotaldecimal-
taxdecimalGST
totaldecimal-
shipping_methodenumparcel, pallet, pickup
sourceenummanual, ai_parsed
ai_confidencedecimalParser confidence (0-1)

ar_purchase_order_line

Line items on purchase orders.
FieldTypeDescription
idintPrimary key
purchase_order_idint→ ar_purchase_order
product_variant_idint→ ar_product_variant
quantityint-
unit_pricedecimal-
line_totaldecimal-

Financial Tables

ar_invoice

Sales invoices (B2B and B2C).
FieldTypeDescription
idintPrimary key
invoice_numbertextAuto-generated (INV-YYYY-NNNN)
invoice_typeenumb2b, b2c, credit_note
distributor_idint→ ar_distributor (B2B)
consumer_emailemailB2C customer
purchase_order_idint→ ar_purchase_order
shopify_order_idtextShopify reference
invoice_datedate-
due_datedate-
statusenumdraft, sent, viewed, partial, paid, overdue, void
subtotaldecimal-
taxdecimalGST
totaldecimal-
amount_paiddecimal-
amount_duedecimal-
xero_invoice_idtextXero sync
last_nudge_attimestampAR nudging
nudge_countintTimes nudged

ar_invoice_line

Invoice line items.
FieldTypeDescription
idintPrimary key
invoice_idint→ ar_invoice
product_variant_idint→ ar_product_variant
descriptiontext-
quantityint-
unit_pricedecimal-
discount_percentdecimal-
tax_ratedecimalGST (10%)
line_totaldecimal-

ar_payment

Payment records against invoices.
FieldTypeDescription
idintPrimary key
invoice_idint→ ar_invoice
payment_datedate-
amountdecimal-
payment_methodenumeft, credit_card, stripe, cash, cheque
referencetextBank ref / Stripe ID
xero_payment_idtextXero sync

Product Tables

ar_product

Master product catalog (Anitone + Howler & Barkes).
FieldTypeDescription
idintPrimary key
skutextStock keeping unit
nametextProduct name
descriptiontextRich description (markdown)
brandenumanitone, howler_barkes
statusenumdraft, active, archived
shopify_product_idtextShopify sync
is_hazmatboolFreight restrictions
weight_kgdecimalShipping weight

ar_product_variant

SKU-level variants (sizes).
FieldTypeDescription
idintPrimary key
product_idint→ ar_product
skutextVariant SKU (A1W, A5W)
nametextSize label (250ml, 1L, 5L)
barcodetextUPC/EAN
price_retaildecimalRRP Inc GST
price_wholesaledecimalWholesale Ex GST
wholesale_per_cartondecimalCarton price Ex GST
packagingtexte.g., “Carton of 20”
inventory_qtyintCurrent stock
low_stock_thresholdintAlert trigger
shopify_variant_idtextShopify sync

ar_product_category

Product categorization.
FieldTypeDescription
idintPrimary key
nametextCategory name
slugtextURL-friendly ID
brandenumanitone, howler_barkes, both

Anitone-Specific Tables

anitone_products

Anitone product variants and pricing (simplified view).
FieldTypeDescription
idintPrimary key
skutextSKU identifier
size_labeltextSize label
size_mlintSize in ml
price_auddecimalPrice AUD
target_markettextTarget market
shopify_variant_idtextShopify link
in_stockboolStock status

anitone_species_dosing

Species-specific dosing rules for calculator.
FieldTypeDescription
idintPrimary key
species_keytexthorses, cattle, sheep_goats, etc.
display_nametextHuman-readable name
dosage_ml_per_kgdecimalDosage rate
dosage_unittextUnit description
min_weight_kgintWeight range min
max_weight_kgintWeight range max
default_weight_kgintDefault for quick calc
key_benefitstext[]Benefits list
shopify_collection_handletextCollection link

Integration Tables

ar_integration_config

External system credentials and settings.
FieldTypeDescription
idintPrimary key
integration_typeenumshopify, xero, stripe, starshipit, northline
is_enabledboolActive flag
credentialsjsonEncrypted API keys
settingsjsonIntegration config
last_sync_attimestampLast sync time
sync_statusenumok, error, never

ar_integration_log

API call audit trail.
FieldTypeDescription
idintPrimary key
integration_typeenumshopify, xero, stripe, etc.
operationtextOperation description
directionenuminbound, outbound
request_payloadjsonRequest data
response_payloadjsonResponse data
status_codeintHTTP status
duration_msintPerformance

ar_xero_sync_log

Xero-specific sync audit.
FieldTypeDescription
idintPrimary key
sync_typeenuminvoice, payment, contact
directionenumpush, pull
xero_idtextXero reference
local_tabletextLocal table name
local_idintLocal record ID
statusenumpending, success, failed

Supporting Tables

ar_document

Central file storage.
FieldTypeDescription
idintPrimary key
document_typeenumpo_pdf, invoice_pdf, contract, other
titletextDocument title
file_urltextStorage URL
file_nametextOriginal filename
related_tabletextPolymorphic reference
related_idintRelated record ID

ar_team_member

Staff/contractor directory.
FieldTypeDescription
idintPrimary key
user_idint→ user (optional)
first_nametext-
last_nametext-
emailemail-
roletextJob title
typeenumstaff, contractor
departmentenumoperations, sales, admin, management
statusenumactive, inactive