This is a submission for the Agentic Postgres Challenge with Tiger Data
TigerData Agentic Postgres in Action
Making PostgreSQL Think, Reason, and Decide About Financial Risk
What I Built
Credit AI is an intelligent credit decisioning system that showcases TigerData's revolutionary Agentic Postgres capabilities. I wanted to create a product that companies like Buy Now, Pay Later (BNPL) Companies, Credit Card Issuers, Consumer Finance Companies, Credit Unions & Commercial Banks could not ignore.
The database doesn't just store dataβit actively participates in decision-making through four specialized TigerData agents:
- Feature Agent: TimescaleDB continuous aggregates that maintain 20+ real-time financial metrics
- Rule Agent: PostgreSQL functions that evaluate adaptive credit rules based on customer type
- Pattern Agent: SQL functions that detect behavioral anomalies and trends
- Trend Agent: Time-series analysis functions that identify income/spending trajectories
π― Problem Solved
Traditional Credit Systems:
- β Point-in-time snapshot analysis
- β Static rules that miss context
- β Unfairly reject freelancers/non-traditional applicants
- β Black-box decisions without explanations
Credit AI Innovation with TigerData:
- β Time-series behavioral understanding
- β Dynamic rules that adapt to applicant type
- β Multi-agent database collaboration
- β Fully explainable decisions with reason codes
Demo
π Live Demo: https://credit-ai-tigerdb.netlify.app/
π API Endpoint: https://docker-credit-ai-api-dev-855607505295.europe-west4.run.app
πΉ Demo Video: [6-minute system walkthrough showcasing agentic capabilities]
π GitHub: https://github.com/bayurzx/credit_ai
Key Demo Features:
- Interactive API Playground: Test credit decisions for different customer types
- Conversational Analytics: Ask questions like "Show me freelancers with improving cash flow"
- Real-time Feature Extraction: Watch 28+ financial metrics compute in <1 second
- Explainable Decisions: See exactly why each decision was made
How I Used TigerData's Agentic Postgres
I leveraged TigerData's revolutionary capabilities to transform PostgreSQL into a thinking, reasoning financial brain. Here's how I used TigerData's core features:
π€ TigerData Feature #1: TimescaleDB Continuous Aggregates (The Feature Agent)
-- This materialized view actively maintains 28+ financial metrics
CREATE MATERIALIZED VIEW financial_features_30d
WITH (timescaledb.continuous) AS
SELECT
customer_id,
-- Income Intelligence
AVG(amount) FILTER (WHERE amount > 0) as avg_income_30d,
STDDEV(amount) FILTER (WHERE amount > 0) as income_volatility,
-- Cash Flow Intelligence
SUM(amount) as net_cash_flow_30d,
AVG(balance_after) as avg_balance_30d,
-- Behavioral Intelligence
COUNT(*) as transaction_count_30d
FROM transactions
GROUP BY customer_id, time_bucket('1 day', transaction_date);
-- Auto-refresh every hour - the database maintains itself!
SELECT add_continuous_aggregate_policy('financial_features_30d',
start_offset => INTERVAL '90 days',
end_offset => INTERVAL '1 hour',
schedule_interval => INTERVAL '1 hour');
Impact: Feature extraction went from 5-10 seconds to <1 second - a 10x performance improvement!
π§ TigerData Feature #2: Advanced PostgreSQL Functions (The Rule Agent)
-- This function adapts its analysis based on customer type
CREATE OR REPLACE FUNCTION calculate_income_stability(
p_customer_id INT,
p_customer_type TEXT DEFAULT 'salaried'
)
RETURNS TABLE(volatility DECIMAL, trend DECIMAL, confidence TEXT) AS $$
DECLARE
lookback_days INT := CASE
WHEN p_customer_type = 'freelancer' THEN 180 -- Longer for freelancers
ELSE 90
END;
BEGIN
RETURN QUERY
SELECT
STDDEV(amount)::DECIMAL as volatility,
REGR_SLOPE(amount, EXTRACT(epoch FROM transaction_date))::DECIMAL as trend,
CASE
WHEN COUNT(*) >= 12 THEN 'HIGH'
WHEN COUNT(*) >= 6 THEN 'MEDIUM'
ELSE 'LOW'
END::TEXT as confidence
FROM transactions
WHERE customer_id = p_customer_id
AND transaction_date > NOW() - (lookback_days || ' days')::INTERVAL
AND amount > 0;
END;
$$ LANGUAGE plpgsql STABLE;
Innovation: The database automatically adjusts its analysis - freelancers get 180-day lookbacks while salaried workers get 90-day analysis!
π― TigerData Feature #3: TimescaleDB Hyperfunctions (The Pattern Agent)
-- Detects spending anomalies and behavioral patterns
CREATE OR REPLACE FUNCTION analyze_spending_patterns(p_customer_id INT)
RETURNS TABLE(
discretionary_ratio DECIMAL,
spending_trend DECIMAL,
anomaly_count INT,
warning_signs TEXT[]
) AS $$
BEGIN
RETURN QUERY
WITH spending_analysis AS (
SELECT
-- Discretionary spending ratio
COUNT(*) FILTER (WHERE category IN ('entertainment', 'dining', 'travel')) * 100.0 /
NULLIF(COUNT(*), 0) as disc_ratio,
-- Trend detection using linear regression
REGR_SLOPE(ABS(amount), EXTRACT(epoch FROM transaction_date)) as trend,
-- Anomaly detection (2-sigma rule)
COUNT(*) FILTER (WHERE ABS(amount) > AVG(ABS(amount)) + 2 * STDDEV(ABS(amount))) as anomalies
FROM transactions
WHERE customer_id = p_customer_id
AND transaction_date > NOW() - INTERVAL '90 days'
AND amount < 0
)
SELECT
disc_ratio::DECIMAL,
trend::DECIMAL,
anomalies::INT,
ARRAY[
CASE WHEN disc_ratio > 40 THEN 'High discretionary spending' END,
CASE WHEN trend > 50 THEN 'Increasing spending trend' END,
CASE WHEN anomalies > 3 THEN 'Multiple large expenses detected' END
]::TEXT[]
FROM spending_analysis;
END;
$$ LANGUAGE plpgsql STABLE;
π£οΈ TigerData Feature #4: Tiger MCP Integration (The Conversation Agent)
# Multi-provider LLM integration with intelligent routing
class NLPtoSQLConverter:
def convert_async(self, query: str, use_llm: bool = None):
# Strategy 1: Template matching (80% success, <100ms)
template_result = self._try_template_match(query)
if template_result.success:
return template_result
# Strategy 2: Tiger MCP integration (15% additional, <1s)
if self.tiger_mcp_available:
mcp_result = self._try_tiger_mcp(query)
if mcp_result.success:
return mcp_result
# Strategy 3: Multi-provider LLM (4% additional, <5s)
if use_llm and self.llm_service.is_available():
return await self._try_llm_conversion(query)
# Strategy 4: Intelligent suggestions
return self._generate_suggestions(query)
TigerData Magic: Used mcp_tiger_semantic_search_tiger_docs for development assistance and TimescaleDB setup guidance. Achieved 99%+ query success rate by combining Tiger MCP with multi-provider LLM integration!
TigerData Agentic Postgres Architecture
How TigerData Powers the Intelligence
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Application β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Decision Orchestrator β Analytics Engine β ML Pipeline β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π
TigerData Agentic Postgres β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β β TimescaleDB β β PostgreSQL β β Tiger MCP ββ
β β Continuous β β Functions β β Integration ββ
β β Aggregates β β (Adaptive Rules)β β (NLP-to-SQL) ββ
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β TigerData Cloud (PostgreSQL 17.6 + TS 2.22.1) ββ
β β Hypertables: 1000 customers, 4395 accounts, 10K+ ββ
β β payment records (30-day chunks) ββ
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Performance Achievements
- Feature Extraction: 45.9ms P95 (target: <1s) β
- Credit Decisions: ~800ms P95 (target: <2s) β
- Analytics Queries: ~2s P95 (target: <5s) β
- LLM Cost: $0.003/query (target: <$0.01) β
- Query Success Rate: 99%+ (target: 95%) β
TigerData Innovations Implemented
1. TimescaleDB Continuous Aggregates - The Game Changer
Instead of expensive on-demand calculations, the database proactively maintains financial intelligence:
-- The database automatically knows each customer's financial health
SELECT
customer_id,
avg_income_30d, -- Updated hourly
income_volatility, -- Trend-aware
cash_flow_health, -- Multi-factor score
debt_to_income_estimate -- Risk indicator
FROM customer_latest_features
WHERE customer_id = 1001;
-- Returns in 2ms instead of 2000ms!
2. TigerData Schema Migration Strategy
I designed a credit-focused database schema that leverages TigerData's full potential:
Migration Strategy with TigerData:
-
001_create_credit_tables.sql- All 3 core tables (customers, credit_accounts, payment_history) -
002_create_credit_hypertables.sql- Convert payment_history to TimescaleDB hypertable (30-day chunks) -
003_create_credit_aggregates.sql- Implement credit_profile_current with exact ML feature names -
004_create_credit_functions.sql- Returns all 10 ML features, portfolio analysis, delinquency patterns
Results:
- β 1000 customers with complete credit profiles
- β 4395 credit accounts with realistic utilization
- β 10,272 payment records with risk-based patterns
- β All 10 ML model features ready for extraction
3. Tiger MCP + Multi-Provider LLM Strategy
I implemented a 4-strategy NLP-to-SQL pipeline that showcases TigerData's versatility:
Strategy 1: Template matching (80% success - fast, reliable)
Strategy 2: Tiger MCP integration (15% additional - medium complexity)
Strategy 3: Multi-provider LLM (OpenAI, Gemini, Claude) (4% additional - complex queries)
Strategy 4: Intelligent error suggestions (1% fallback)
Tiger MCP Usage:
- Used
mcp_tiger_semantic_search_tiger_docsfor development assistance - Got TimescaleDB setup guidance and best practices
- Leveraged Tiger MCP for complex query understanding
LLM Cost Optimization:
- Achieved $0.003/query average cost (target: <$0.01)
- 99%+ query success rate through intelligent routing
- Multi-provider fallback ensures reliability
What I Learned About TigerData
TigerData's Revolutionary Capabilities
- TimescaleDB Continuous Aggregates: The killer feature! Moving from on-demand to pre-computed features delivered 10x performance improvement
- Agentic SQL Functions: PostgreSQL functions in TigerData can embody business intelligence and adapt their behavior
-
Tiger MCP Integration: Seamless development assistance through
mcp_tiger_semantic_search_tiger_docs - Hypertable Performance: 30-day chunks with compression policies made 10K+ payment records lightning fast
TigerData Performance Achievements
- Feature Extraction: 45.9ms P95 (target: <1s) β - Thanks to continuous aggregates!
- Credit Decisions: ~800ms P95 (target: <2s) β - Powered by hypertables!
- Analytics Queries: ~2s P95 (target: <5s) β - Tiger MCP + LLM integration!
- ML Model: AUC = 0.8840 (target: >0.70) β - LightGBM on TigerData!
- Query Success: 99%+ (target: 95%) β - Multi-strategy with Tiger MCP!
TigerData's Future Potential
Credit AI demonstrates what's possible when you unleash TigerData's Agentic Postgres capabilities:
What TigerData Enables:
- Real-time Intelligence: TimescaleDB continuous aggregates provide insights the moment data arrives
- Scalable Analytics: Database-native computation scales with data volume
- Conversational Interfaces: Tiger MCP makes complex databases accessible through natural language
- Multi-Agent Coordination: Different database functions act as specialized reasoning agents
Next Applications with TigerData:
- Fraud Detection: Real-time behavioral anomaly detection with hyperfunctions
- Customer Churn Prediction: Proactive retention using continuous aggregates
- Dynamic Pricing: Risk-based pricing with real-time feature computation
- Regulatory Reporting: Automated compliance through intelligent SQL functions
TigerData doesn't just store data - it thinks about data!
TigerData-Powered Technical Stack
- π TigerData Cloud: PostgreSQL 17.6 + TimescaleDB 2.22.1 (The Star!)
- π Tiger MCP: Development assistance and semantic search integration
- π TimescaleDB Features: Continuous aggregates, hypertables, hyperfunctions
- Backend: FastAPI with async/await for high concurrency
- ML: LightGBM (AUC: 0.884) with SHAP explainability
- LLM: Multi-provider (OpenAI, Gemini, Claude) with Tiger MCP integration
- Frontend: Vanilla JavaScript showcasing TigerData capabilities
- Infrastructure: Docker containerization optimized for TigerData
Special Thanks to TigerData
- π TigerData Team: For creating the revolutionary Agentic Postgres platform that made this entire vision possible
- π TimescaleDB Integration: For the seamless time-series capabilities that power our continuous aggregates
- π Tiger MCP: For the development assistance that accelerated our implementation
- π TigerData Cloud: For the robust, scalable infrastructure that handles our complex workloads
Why TigerData Won This Challenge
TigerData didn't just provide a database - they provided a thinking partner. The continuous aggregates eliminated our performance bottlenecks, the hyperfunctions enabled sophisticated analysis, and Tiger MCP guided our development process. This isn't just PostgreSQL - this is PostgreSQL with superpowers.
π Credit AI proves that TigerData's Agentic Postgres is the future of intelligent applications. We didn't just build a credit system - we built a financial reasoning engine that thinks, adapts, and explains its decisions.
π Ready to see TigerData's Agentic Postgres in action? Try the live demo!
Live Demo: https://credit-ai-tigerdb.netlify.app/
GitHub: https://github.com/bayurzx/credit_ai
API: https://docker-credit-ai-api-dev-855607505295.europe-west4.run.app
Top comments (0)