Enterprise decision intelligence platform featuring self-correcting LangGraph NL2SQL agents, MotherDuck OLAP, and real-time OEE & MRO spare-part forecasting.
In large-scale automotive component manufacturing (e.g., leaf springs, coil springs, stabilizer bars), operational delays and unplanned machine downtime carry massive financial penalties. Industrial data is traditionally fragmented across legacy ERPs, Warehouse Management Systems (WMS), supplier procurement portals, and shopfloor IoT telemetry.
The Supply Chain Intelligence Center (SCIC) is an enterprise-grade AI decision intelligence platform designed to bridge these silos. Built on a Decoupled Cloud-Native Hybrid Intelligence architecture, SCIC converts multi-source industrial data into actionable, real-time insights.
CALL try_bind(?)) against MotherDuck, eliminating SQL hallucination and mutation vectors.+----------------------------------------------------------------------------------------------------+
| FRONTEND LAYER (Next.js 15 & React 19) |
| /dashboard β Executive Control Tower & OEE | /demand-intelligence β Smart ROP & Stock Balancing |
| /chat β AI Copilot & NL2SQL Assistant | /agent-logs β Real-time Execution Audit Traces |
+-------------------------------------------------+--------------------------------------------------+
| HTTPS REST API & SSE Token Streaming
v
+----------------------------------------------------------------------------------------------------+
| APPLICATION BACKEND SERVICES (FastAPI) |
| FastAPI REST Gateway β’ Pydantic v2 β’ SQLAlchemy 2.0 β’ ARQ Asynchronous Task Engine |
| Business Domain Services: OEE Engine (Avail/Perf/Qual), 3-Way Triad Matching, Dynamic Smart ROP |
+-----------------------+----------------------------------------------------+-----------------------+
| |
v v
+-----------------------------------------------+ +------------------------------------------------+
| OPERATIONAL STORE (Supabase PG) | | ANALYTICAL STORE (MotherDuck OLAP) |
| - Supabase Auth (JWT & RBAC Policies) | | - 34 Unified Analytical Tables |
| - Chat Sessions & Message Persistences | | - Sub-second DuckDB Columnar Vectorized Engine|
| - Immutable Audit Trail (Human Decisions) | | - Pre-computed OEE & Reconciliation Views |
+-----------------------------------------------+ +------------------------------------------------+
| |
+-----------------------+----------------------------+
v
+-----------------------------------------------+
| CACHE & QUEUE (Upstash Redis) |
| - Distributed Token-Bucket Rate Limiter |
| - Pre-computed KPI Cache Layer |
+-----------------------------------------------+End-to-end architectural topology of SCIC, highlighting the separation of OLAP analytics (MotherDuck) from transactional state persistence (Supabase) and async LLM orchestration.
admin, manager, analyst, viewer), persistent chat sessions, execution traces, and audit logs.The data model unifies shopfloor manufacturing execution with end-to-end supply chain logistics across 8 domain modules (34 tables):

supplier_master, product_master, dim_machines, dim_skus, dim_spare_parts, dim_bom_compatibility).fact_downtime_logs, fact_production_outputs, fact_quality_inspections, fact_shift_manpower).fact_machine_telemetry, fact_anomaly_events, fact_part_consumptions).To provide plant managers and supply chain directors with an autonomous yet deterministic analytics copilot, we implemented a custom state machine using LangGraph StateGraph.

Complete LangGraph workflow graph illustrating the 10 nodes, deterministic branch routing, and dual self-correction feedback loops.
AgentState)class AgentState(TypedDict):
# Session & Conversation Context
messages: Annotated[List[BaseMessage], operator.add]
session_id: str
user_query: str
augmented_history: Optional[str]
last_executed_sql: Optional[str]
# Tier 1: Router & Planner
intent: Literal["ANALYTICS_QUERY", "FOLLOW_UP_INTERPRETATION", "CLARIFICATION_NEEDED", "OUT_OF_SCOPE", "CHIT_CHAT"]
selected_domain: Literal["manufacturing", "supply_chain", "inventory_mro", "demand_balancing", "finance", "general"]
normalized_query: Optional[str]
# Tier 2: Domain Context & Pruning
relevant_tables: List[str]
schema_context: str
business_glossary: str
# Tier 3: SQL Generation & Sandboxed OLAP Execution
generated_sql: Optional[str]
sql_is_valid: bool
sql_validation_error: Optional[str]
sql_retry_count: int
sql_result_records: Optional[List[Dict[str, Any]]]
sql_execution_time_ms: float
draft_answer: Optional[str]
# Tier 4: Senior Expert Critic & Refinement
expert_critique_score: float
expert_critique_status: Literal["PASSED", "NEEDS_REFINEMENT"]
expert_critique_feedback: Optional[str]
expert_recommendations: List[str]
# Telemetry & UI Payload
action_steps_trace: Annotated[List[str], operator.add]
final_payload: Optional[Dict[str, Any]]sql_validatorΒ ββΒ sql_generator)Insert, Update, Delete, Drop, Alter, Pragma) is immediately rejected.CALL try_bind(?). If a column or table is invalid, the exact compiler diagnostic is routed back to sql_generator for an automatic retry (capped at 3 iterations).senior_expert_validatorΒ ββΒ expert_refinement)/dashboard)The executive dashboard serves as the central command cockpit for Operations Directors and Plant GMs, continuously calculating a composite health index across manufacturing and delivery nodes.

Control Tower UI showing the Composite Health Index (95.2/100 - Healthy) with its 4-factor contribution breakdown and AI Executive Prescriptive Summary.
HealthΒ Index=0.35ΓOTD+0.30ΓProdΒ Achievement+0.20Γ(100βRiskΒ Penalty)+0.15ΓForecastΒ Accuracy
/demand-intelligence)Unplanned downtime in automotive stamping and heat-treatment is predominantly caused by missing MRO spare parts. This module combines predictive consumption forecasting with dynamic stock balancing.

Demand Intelligence module displaying stockout risks, 91.8% forecast accuracy, MRO readiness levels (90.0%), and interactive Reorder Point (ROP) tabular controls.
SmartΒ ROP=(AvgΒ DailyΒ PartΒ ConsumptionΓSupplierΒ LeadΒ Time)+DynamicΒ SafetyΒ StockΒ BufferSmartΒ ROP=(AvgΒ DailyΒ PartΒ ConsumptionΓSupplierΒ LeadΒ Time)+DynamicΒ SafetyΒ StockΒ Buffer
/chat)The AI Assistant Copilot provides natural language querying over 34 OLAP tables with complete transparency over execution logic and data lineage.

AI Copilot answering an OEE breakdown query, displaying the 7-step Execution Action Trace, AST/try_bind validation pass, 259.1ms MotherDuck execution, Senior Expert Critic score (84.0/100), and structured markdown table.
[ANALYTICS_QUERY] in Domain [manufacturing]. Query normalized: "Berapa OEE per lini produksi beserta penyebab downtime..."try_bind() with 100% compliance.Enterprise AI deployment requires strict operational boundaries to prevent autonomous errors:
[ Natural Language Query ]
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Layer 1: SQLGlot AST Safety Parse β βββΊ [ Mutation Blocked ] (DROP / UPDATE / INSERT)
βββββββββββββββββββββββββββββββββββββββββ
β (SELECT / CTE Only)
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Layer 2: MotherDuck CALL try_bind(?) β βββΊ [ Catalog Error ] βββΊ (Self-Correction Retry)
βββββββββββββββββββββββββββββββββββββββββ
β (Valid Schema Binding)
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Layer 3: Read-Only Connection Pool β βββΊ Sub-second Aggregation
βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Layer 4: Senior Expert Critic (LLM) β βββΊ Quality Score >= 80
βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Layer 5: Human Review & Approval Gate β βββΊ Writes to Supabase `audit_log`
βββββββββββββββββββββββββββββββββββββββββaudit_log.