erDiagram
%% ============ OBSTOJEČE GROWIYO TABELE (read vir) ============
ACCOUNTS ||--o{ PRODUCTS : has
ACCOUNTS ||--o{ ORDERS : has
ACCOUNTS ||--o{ COMPANY_INFO : has
PRODUCTS ||--o{ STOCK : tracks
PRODUCTS ||--o{ PRICES : has
ACCOUNTS {
bigint id PK
string name
string subscription_tier
}
COMPANY_INFO {
bigint account_id FK
string contact
json working_hours
json policies
}
PRODUCTS {
bigint id PK
bigint account_id FK
string name
text description "WRITE: generator opisov"
json attributes "product finder rabi to"
}
PRICES {
bigint product_id FK
decimal price
}
STOCK {
bigint product_id FK
int quantity
}
ORDERS {
bigint id PK
bigint account_id FK
bigint customer_id
decimal total
timestamp created_at
}
%% ============ JEDRO: ORCHESTRATOR / FEATURE FLAGS ============
ACCOUNTS ||--o{ ACCOUNT_AGENT_FEATURES : configures
ACCOUNT_AGENT_FEATURES {
bigint id PK
bigint account_id FK
string agent "chatbot|assistant|booking|email"
string feature "core|lead_qualifier|..."
boolean enabled
json config
}
%% ============ JEDRO 1: CHATBOT (kupec, zunanji) ============
ACCOUNTS ||--o{ CHAT_SESSIONS : has
CHAT_SESSIONS ||--o{ CHAT_MESSAGES : contains
CHAT_SESSIONS ||--o{ CHAT_LEADS : captures
ACCOUNTS ||--o{ FAQS : has
CHAT_SESSIONS {
bigint id PK
bigint account_id FK
string session_id
bigint customer_id "nullable"
string channel
timestamp started_at
}
CHAT_MESSAGES {
bigint id PK
bigint session_id FK
string role
text content
int tokens
timestamp created_at
}
CHAT_LEADS {
bigint id PK
bigint account_id FK
bigint session_id FK
string email
string phone
string source_addon
}
FAQS {
bigint id PK
bigint account_id FK
text question
text answer
string category
string status "WRITE: faq generator"
}
%% ============ JEDRO 2: ASISTENT (lastnik, bodoči agent) ============
ACCOUNTS ||--o{ ASSISTANT_SESSIONS : has
ASSISTANT_SESSIONS ||--o{ ASSISTANT_MESSAGES : contains
ACCOUNTS ||--o{ ASSISTANT_ACTIONS : logs
ACCOUNTS ||--o{ ASSISTANT_MEMORY : remembers
ACCOUNTS ||--o{ ANALYTICS_DAILY : aggregates
ASSISTANT_SESSIONS {
bigint id PK
bigint account_id FK
timestamp started_at
}
ASSISTANT_MESSAGES {
bigint id PK
bigint session_id FK
string role
text content
timestamp created_at
}
ASSISTANT_ACTIONS {
bigint id PK
bigint account_id FK
string action_type
json payload
string status "suggested|approved|executed|rejected"
timestamp executed_at
}
ASSISTANT_MEMORY {
bigint id PK
bigint account_id FK
string key
json value
}
ANALYTICS_DAILY {
bigint id PK
bigint account_id FK
date day
decimal revenue
int orders_count
decimal avg_cart
decimal conversion
int abandoned_carts
json top_products
}
%% ============ JEDRO 3: BOOKING (orodje, piše od začetka) ============
ACCOUNTS ||--o{ SERVICES : offers
ACCOUNTS ||--o{ STAFF_RESOURCES : has
SERVICES ||--o{ BOOKINGS : booked
STAFF_RESOURCES ||--o{ BOOKINGS : assigned
ACCOUNTS ||--o{ AVAILABILITY_RULES : defines
SERVICES {
bigint id PK
bigint account_id FK
string name
int duration_min
decimal price
}
STAFF_RESOURCES {
bigint id PK
bigint account_id FK
string name
}
AVAILABILITY_RULES {
bigint id PK
bigint account_id FK
json rules
string calendar_sync
}
BOOKINGS {
bigint id PK
bigint account_id FK
bigint service_id FK
bigint staff_id FK
string customer
timestamp slot_from
timestamp slot_to
string status
string source "web|chatbot|assistant"
}
%% ============ JEDRO 4: EMAIL / SENDY AGENT ============
ACCOUNTS ||--o{ EMAIL_DRAFTS : drafts
EMAIL_DRAFTS {
bigint id PK
bigint account_id FK
string subject
text body
string type
string status "draft|approved|sent"
string sendy_campaign_id
}
%% ============ ADD-ON TABELE ============
ACCOUNTS ||--o{ SUPPORT_TICKETS : has
ACCOUNTS ||--o{ PRICING_RULES : has
ACCOUNTS ||--o{ SIZE_CHARTS : has
ACCOUNTS ||--o{ STOCK_NOTIFICATIONS : has
ACCOUNTS ||--o{ RFQ_REQUESTS : has
ACCOUNTS ||--o{ LEAD_SCORES : has
ACCOUNTS ||--o{ FINDER_RESPONSES : has
SUPPORT_TICKETS {
bigint id PK
bigint account_id FK
bigint session_id FK
string status
text issue
string addon "reklamacijski (chatbot)"
}
PRICING_RULES {
bigint id PK
bigint account_id FK
json params
string addon "cenovni kalkulator (chatbot)"
}
SIZE_CHARTS {
bigint id PK
bigint account_id FK
string category
json chart
string addon "velikostni svetovalec (chatbot)"
}
STOCK_NOTIFICATIONS {
bigint id PK
bigint account_id FK
bigint product_id FK
string email
string addon "razprodaja/zaloga (chatbot)"
}
RFQ_REQUESTS {
bigint id PK
bigint account_id FK
json details
bigint draft_action_id FK
string addon "B2B (asistent)"
}
LEAD_SCORES {
bigint id PK
bigint account_id FK
bigint lead_id FK
int score
string addon "lead qualifier (asistent)"
}
FINDER_RESPONSES {
bigint id PK
bigint account_id FK
json answers
string addon "product finder (chatbot)"
}