askrobots / dbbasic Public

Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.

0 downloads

dbbasic/examples/ai_powered.dbbasic
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add DBBasic crate engine logo and update README 0d628db 1 year, 2 months ago History
ai_powered.dbbasic · 4.0 KB · 121 lines
1# AI-Powered DBBasic Config
2# Services are defined by description, not code
3
4name: "AI-Powered E-commerce"
5version: 3.0
6
7model:
8 orders:
9 fields: [id, customer_id, subtotal, tax, total, status]
10 hooks:
11 before_save: "ai://calculate_order_total"
12 after_create: "ai://send_order_confirmation"
13 after_update: "ai://sync_inventory"
14
15 customers:
16 fields: [id, name, email, lifetime_value, segment]
17 hooks:
18 after_create: "ai://send_welcome_email"
19 after_update: "ai://recalculate_customer_segment"
20
21 products:
22 fields: [id, name, price, cost, stock]
23 hooks:
24 before_save: "ai://validate_pricing"
25 after_update: "ai://update_search_index"
26
27# AI Service Definitions - Just describe what you want
28ai_services:
29 calculate_order_total:
30 description: "Calculate tax based on customer location and add to subtotal for total"
31 inputs: [subtotal, customer_location]
32 outputs: [tax, total]
33
34 send_order_confirmation:
35 description: "Send a nice order confirmation email with order details and tracking link"
36 inputs: [customer_email, order_id, items]
37 outputs: [email_sent, message_id]
38
39 sync_inventory:
40 description: "Reduce stock levels for ordered items and trigger reorder if below threshold"
41 inputs: [items, quantities]
42 outputs: [stock_levels, reorder_triggered]
43
44 send_welcome_email:
45 description: "Send personalized welcome email with 10% discount code valid for 30 days"
46 inputs: [customer_name, customer_email]
47 outputs: [email_sent, discount_code]
48
49 recalculate_customer_segment:
50 description: "Segment customer as bronze/silver/gold/platinum based on lifetime value and order frequency"
51 inputs: [customer_id, lifetime_value, order_count]
52 outputs: [segment, benefits]
53
54 validate_pricing:
55 description: "Ensure price is at least 20% above cost and within market range"
56 inputs: [price, cost, product_category]
57 outputs: [valid, suggested_price]
58
59 update_search_index:
60 description: "Update Elasticsearch with product changes, boost popular items"
61 inputs: [product_id, product_data]
62 outputs: [indexed, search_rank]
63
64# Even complex business logic becomes a description
65workflows:
66 order_fulfillment:
67 states: [placed, paid, packed, shipped, delivered]
68 transitions:
69 placed_to_paid:
70 service: "ai://process_payment"
71 description: "Charge credit card, handle failures, retry if needed"
72
73 paid_to_packed:
74 service: "ai://assign_to_warehouse"
75 description: "Find closest warehouse with stock, create pick list"
76
77 packed_to_shipped:
78 service: "ai://create_shipping_label"
79 description: "Choose cheapest shipping method that meets delivery date"
80
81 shipped_to_delivered:
82 service: "ai://track_delivery"
83 description: "Monitor tracking, notify customer of delays"
84
85# Scheduled AI agents
86agents:
87 demand_forecaster:
88 schedule: "0 0 * * *" # Daily
89 service: "ai://forecast_demand"
90 description: "Analyze sales trends and predict next 30 days demand by product"
91
92 price_optimizer:
93 schedule: "0 */4 * * *" # Every 4 hours
94 service: "ai://optimize_prices"
95 description: "Adjust prices based on competitor pricing, demand, and margin targets"
96
97 customer_retention:
98 trigger: "customer.last_order > 60 days"
99 service: "ai://retention_campaign"
100 description: "Send personalized win-back offer based on purchase history"
101
102 fraud_detector:
103 trigger: "new order"
104 service: "ai://detect_fraud"
105 description: "Score order for fraud risk using customer history and patterns"
106
107# AI can even handle integrations
108integrations:
109 stripe:
110 adapter: "ai://stripe_adapter"
111 description: "Handle all Stripe payment operations and webhooks"
112
113 shopify:
114 adapter: "ai://shopify_sync"
115 description: "Two-way sync of products, orders, and inventory"
116
117 chatgpt:
118 adapter: "ai://customer_support"
119 description: "Answer customer questions using order and product data"
120
121# The entire business logic is descriptions, not code