Sales Analytics
A complete working example of an Akili data product. Ingests order and customer data from a source database via change data capture, aggregates into daily metrics by region and segment, enforces quality gates, and serves via the analytics engine and a lookup store.
%%{init: {'flowchart': {'curve': 'basis'}}}%%
flowchart LR
subgraph Source["Source Database"]
ORDERS[orders]
CUSTOMERS[customers]
end
subgraph Akili["Akili Platform"]
CDC[Change Data Capture] --> TRANSFORM[SQL Transform]
TRANSFORM --> QUALITY[Quality Gates]
QUALITY --> LAKE[Data Lake]
end
subgraph Serving["Serving Stores"]
SR[Analytics Engine]
PG[Lookup Store]
end
ORDERS --> CDC
CUSTOMERS --> CDC
LAKE --> SR
LAKE --> PG
Manifest Files
Section titled “Manifest Files”Every Akili data product is defined by 6 YAML manifests in a .akili/ directory. Here is the complete set for the sales analytics product.
product.yaml
Section titled “product.yaml”Product identity — name, schedule, tier, and ownership.
apiVersion: akili/v1kind: DataProductmetadata: name: daily-order-summary description: > Daily aggregated order metrics by region and product category. Sources from the production orders database via change data capture. owner: data-engineering@acme-corp.com tags: - sales - analytics - dailyspec: schedule: "0 6 * * *" # Daily at 6 AM UTC tier: silversources.yaml
Section titled “sources.yaml”Two source tables from a production relational database. Orders use change data capture; customers use incremental sync.
apiVersion: akili/v1kind: Sourcessources: - name: orders connection: production_db resource: public.orders strategy: cdc columns: - order_id - customer_id - product_id - quantity - unit_price - total_amount - region - order_date - created_at
- name: customers connection: production_db resource: public.customers strategy: incremental columns: - customer_id - name - segment - countrytransforms.yaml
Section titled “transforms.yaml”References a SQL file that joins orders with customers and aggregates into daily metrics.
apiVersion: akili/v1kind: Transformstransforms: - name: daily_summary type: sql sql_file: transforms/daily_summary.sqlThe SQL transform uses {{ ref() }} to reference upstream sources:
-- transforms/daily_summary.sqlSELECT DATE_TRUNC('day', o.order_date) AS date, o.region, c.segment AS customer_segment, COUNT(DISTINCT o.order_id) AS order_count, COUNT(DISTINCT o.customer_id) AS unique_customers, SUM(o.quantity) AS total_units, SUM(o.total_amount) AS total_revenue, AVG(o.total_amount) AS avg_order_valueFROM {{ ref('orders') }} oLEFT JOIN {{ ref('customers') }} c ON o.customer_id = c.customer_idGROUP BY 1, 2, 3quality.yaml
Section titled “quality.yaml”Quality checks enforced after every pipeline run. Critical checks block data promotion; warnings are logged but don’t block.
apiVersion: akili/v1kind: Qualitychecks: - name: no_null_dates type: sql sql: "SELECT COUNT(*) FROM {{ this }} WHERE date IS NULL" severity: critical threshold: 0
- name: positive_revenue type: sql sql: "SELECT COUNT(*) FROM {{ this }} WHERE total_revenue < 0" severity: critical threshold: 0
- name: reasonable_order_count type: sql sql: "SELECT COUNT(*) FROM {{ this }} WHERE order_count > 1000000" severity: warning threshold: 0sla: freshness: 24h completeness: 0.99serving.yaml
Section titled “serving.yaml”Analytical intent routes queries to the analytics engine (StarRocks). Materialization keeps results fresh.
apiVersion: akili/v1kind: Servingintent: analyticalmaterialization: enabled: true refresh_interval: "1h"governance.yaml
Section titled “governance.yaml”Internal classification with owner and reader access grants.
apiVersion: akili/v1kind: Governanceclassification: internalaccess: - team: data-engineering role: owner - team: analytics role: readerDeploy This Example
Section titled “Deploy This Example”-
Initialize the project
Terminal window mkdir daily-order-summary && cd daily-order-summaryakili init --name daily-order-summaryReplace the generated manifest templates with the files above.
-
Validate manifests
Terminal window akili validate .akili/ -
Create the product in the platform
Terminal window akili product create \--name daily-order-summary \--namespace sales -
Deploy
Terminal window akili product deploy daily-order-summary -
Trigger an execution
Terminal window akili run trigger daily-order-summary -
Query results via API
Terminal window curl -H "Authorization: Bearer $TOKEN" \"https://api.akili.systems/api/v1/analytics/query" \-d '{"sql": "SELECT region, SUM(total_revenue) FROM daily_order_summary GROUP BY region"}'
Related
Section titled “Related”- Pilot Onboarding — full tenant onboarding walkthrough using this example
- Write Manifests — field-by-field manifest reference
- Quality Rules — built-in checks, custom SQL, severity levels
- Serving Configuration — intent-based store routing