Skip to main content

What is VoicePact Analytics?

VoicePact Analytics provides business intelligence on voice-based contracts by extracting, transforming, and loading (ETL) operational data into a dedicated analytics database. This enables stakeholders to gain insights into contract performance, payment patterns, and user behavior without impacting the production system.

Key Capabilities

Business Metrics

The analytics system tracks critical business metrics including:
  • Contract Performance: Time to completion, completion rates, and contract statuses
  • Payment Analytics: Total amounts released, payment velocities, and escrow patterns
  • User Activity: Buyer and seller participation, contract types, and product categories
  • Temporal Patterns: Contract creation trends, completion timelines, and seasonal patterns

Data Model

The analytics database uses a dimensional model centered around a fact table that consolidates contract, party, and payment information:

Fact Table: fct_contracts_summary

This is the primary analytics table containing:
ColumnTypeDescription
contract_idStringUnique contract identifier
contract_typeStringType of contract (agricultural_supply, service_agreement, etc.)
contract_statusStringCurrent status (pending, active, completed, etc.)
contract_total_amountDecimalTotal contract value
currencyStringCurrency code (e.g., KES)
productStringProduct/service being contracted
created_atDatetimeContract creation timestamp
completed_atDatetimeContract completion timestamp
time_to_completion_daysIntegerDays from creation to completion
buyer_phoneStringBuyer’s phone number
seller_phoneStringSeller’s phone number
total_paid_releasedDecimalTotal amount released from escrow

Source Data

The ETL pipeline extracts data from three operational tables:
  1. contracts: Core contract information including terms, amounts, and status
  2. contract_parties: Buyer, seller, mediator, and witness information
  3. payments: Payment transactions and escrow releases

Example Queries

Once the ETL pipeline has run, you can query the analytics database for insights:

Total Contracts by Type

SELECT 
    contract_type,
    COUNT(*) as total_contracts,
    SUM(contract_total_amount) as total_value
FROM fct_contracts_summary
GROUP BY contract_type
ORDER BY total_value DESC;

Average Time to Completion

SELECT 
    contract_type,
    AVG(time_to_completion_days) as avg_days_to_complete,
    COUNT(*) as completed_contracts
FROM fct_contracts_summary
WHERE contract_status = 'completed'
  AND time_to_completion_days IS NOT NULL
GROUP BY contract_type;

Payment Release Rate

SELECT 
    contract_status,
    COUNT(*) as contract_count,
    SUM(contract_total_amount) as total_contracted,
    SUM(total_paid_released) as total_released,
    ROUND(100.0 * SUM(total_paid_released) / NULLIF(SUM(contract_total_amount), 0), 2) as release_rate_pct
FROM fct_contracts_summary
GROUP BY contract_status;

Top Products by Volume

SELECT 
    product,
    COUNT(*) as contract_count,
    SUM(contract_total_amount) as total_value,
    AVG(contract_total_amount) as avg_contract_value
FROM fct_contracts_summary
WHERE product IS NOT NULL
GROUP BY product
ORDER BY contract_count DESC
LIMIT 10;
SELECT 
    strftime('%Y-%m', created_at) as month,
    COUNT(*) as contracts_created,
    SUM(CASE WHEN contract_status = 'completed' THEN 1 ELSE 0 END) as contracts_completed,
    SUM(contract_total_amount) as total_value
FROM fct_contracts_summary
GROUP BY month
ORDER BY month DESC;

Architecture

Separation of Concerns

VoicePact uses a separate analytics database to:
  • Prevent query interference: Heavy analytical queries don’t impact production performance
  • Enable schema optimization: The analytics schema is denormalized for query performance
  • Support data retention: Historical snapshots can be maintained independently
  • Facilitate external integrations: BI tools can connect without production access

ETL Process

The ETL pipeline follows a classic three-stage approach:
  1. Extract: Queries the production database to retrieve raw contract, party, and payment data
  2. Transform: Cleans, enriches, and joins data to create analytics-ready summaries
  3. Load: Writes the transformed data to the analytics database
See the ETL Pipeline documentation for implementation details.

Use Cases

Business Intelligence

  • Track contract completion rates by type
  • Identify bottlenecks in the contract lifecycle
  • Monitor payment release patterns
  • Analyze seasonal trends in contract creation

Operational Monitoring

  • Detect anomalies in contract processing times
  • Monitor escrow fund flows
  • Track user engagement by phone number
  • Identify high-value contracts requiring attention

Product Development

  • Understand which contract types are most popular
  • Analyze feature usage patterns
  • Identify opportunities for automation
  • Measure the impact of product changes

Next Steps

Build docs developers (and LLMs) love