Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.
shipping_config_example.yaml · 2.2 KB · 103 lines
| 1 | # DBBasic Config Example: Shipping Calculator |
| 2 | # This replaces 50+ lines of Python code with 20 lines of config |
| 3 | |
| 4 | name: shipping_calculator |
| 5 | description: "Calculate shipping costs with carrier rates and business rules" |
| 6 | |
| 7 | # Data model (optional - for storing rate tables) |
| 8 | data: |
| 9 | carrier_rates: |
| 10 | - carrier: USPS |
| 11 | service: standard |
| 12 | rate_per_pound: 2.50 |
| 13 | base_fee: 3.00 |
| 14 | - carrier: UPS |
| 15 | service: express |
| 16 | rate_per_pound: 4.00 |
| 17 | base_fee: 5.00 |
| 18 | - carrier: FedEx |
| 19 | service: overnight |
| 20 | rate_per_pound: 8.00 |
| 21 | base_fee: 10.00 |
| 22 | |
| 23 | # Business rules as config |
| 24 | rules: |
| 25 | free_shipping: |
| 26 | condition: "order_total >= 100" |
| 27 | action: "set shipping_cost = 0" |
| 28 | |
| 29 | fragile_handling: |
| 30 | condition: "is_fragile == true" |
| 31 | action: "add 5.00 to shipping_cost" |
| 32 | |
| 33 | weight_calculation: |
| 34 | formula: "base_fee + (weight * rate_per_pound)" |
| 35 | |
| 36 | carrier_selection: |
| 37 | standard: "USPS" |
| 38 | express: "UPS" |
| 39 | overnight: "FedEx" |
| 40 | |
| 41 | # Input/output specification |
| 42 | inputs: |
| 43 | - name: weight |
| 44 | type: number |
| 45 | required: true |
| 46 | - name: shipping_speed |
| 47 | type: string |
| 48 | default: "standard" |
| 49 | options: [standard, express, overnight] |
| 50 | - name: is_fragile |
| 51 | type: boolean |
| 52 | default: false |
| 53 | - name: order_total |
| 54 | type: number |
| 55 | default: 0 |
| 56 | |
| 57 | outputs: |
| 58 | - name: shipping_cost |
| 59 | type: number |
| 60 | - name: carrier |
| 61 | type: string |
| 62 | - name: estimated_days |
| 63 | type: integer |
| 64 | - name: free_shipping_applied |
| 65 | type: boolean |
| 66 | |
| 67 | # Service endpoint configuration |
| 68 | endpoint: |
| 69 | path: "/ai/calculate_shipping" |
| 70 | method: POST |
| 71 | rate_limit: 1000/hour |
| 72 | |
| 73 | # Test cases as config |
| 74 | tests: |
| 75 | - name: "basic_shipping" |
| 76 | input: |
| 77 | weight: 2.5 |
| 78 | shipping_speed: "standard" |
| 79 | is_fragile: false |
| 80 | order_total: 75 |
| 81 | expected: |
| 82 | shipping_cost: 9.25 # 3.00 + (2.5 * 2.50) |
| 83 | carrier: "USPS" |
| 84 | free_shipping_applied: false |
| 85 | |
| 86 | - name: "free_shipping" |
| 87 | input: |
| 88 | weight: 5.0 |
| 89 | shipping_speed: "express" |
| 90 | order_total: 150 |
| 91 | expected: |
| 92 | shipping_cost: 0 |
| 93 | free_shipping_applied: true |
| 94 | |
| 95 | - name: "fragile_item" |
| 96 | input: |
| 97 | weight: 1.0 |
| 98 | shipping_speed: "standard" |
| 99 | is_fragile: true |
| 100 | order_total: 50 |
| 101 | expected: |
| 102 | shipping_cost: 10.50 # 3.00 + (1.0 * 2.50) + 5.00 |
| 103 | carrier: "USPS" |