AI Agents

Four agents, one data platform

Purpose-built AI agents that connect EFI's Airtable CRM and PostgreSQL ERP to deliver market intelligence, trade analytics, sourcing gap analysis, and pricing optimization — all running on a self-hosted TypeScript monorepo with a centralized REST data layer.

Runtime Node.js / TypeScript
AI Models Claude Sonnet 4.6 + Gemini 2.5
Status 4 Agents Live

Architecture

Each agent follows the same pattern: purpose-built fetchers pull data from Airtable and PostgreSQL in parallel, a service layer computes the business logic, and an Express web server renders the results. AI augments the pipeline — Claude writes narratives, validates confidence, and generates recommendations.

AirtableCRM
PostgreSQLERP
AI PipelineWeb Search
DatamyneBOL Data
Data API29 endpoints
Market Research
Sourcing
Pricing
Web Dashboard
PDF Export
Mobile PWA

Self-hosted, not platform-managed. Unlike hosted AI platforms (Google ADK, CrewAI), EFI's agents run on the application server. ERP data never passes through third-party orchestration — only specific prompt data is sent to model APIs. Cost: ~$0.03–0.50 per agent run.

The Four Agents

Monorepo Structure

directory
AGENTS_mono/
├── packages/
│   ├── shared/              # @efi/shared — DB clients, models, types
│   ├── market-research/     # Customer insights — fetchers, AI pipeline, web
│   ├── sourcing/            # Gap dashboard — demand/supply/inventory analysis
│   ├── pricing/             # Pricing optimizer — LP model, scenario runner
│   ├── trade-intel/         # Competitive intelligence — Datamyne BOL analysis
│   ├── data-api/            # Centralized REST API — 27 endpoints, 6 route groups
│   └── data-platform/       # This site — static HTML documentation
├── docs/                    # Technical guides and architecture docs
└── .env                     # Shared environment variables

Shared Infrastructure

  • Airtable CRM client — lazy-init, queryTable with formula builder
  • PostgreSQL ERP client — pool with SSL/DigitalOcean compat
  • Anthropic Claude client — singleton, configurable model
  • Data API client — typed REST client for all 28 endpoints
  • Datamyne API client — singleton with 24hr cache, rate-limit protection
  • Product name normalization — fuzzy match across systems

Build System

  • npm workspaces + TypeScript project references
  • tsc -b builds all packages in dependency order
  • Each agent has its own Express server on a separate port
  • Shared .env at monorepo root via dotenv/config

Data Sources

Airtable CRM

TableUsed By
CustomersMarket Research
Sales OrdersMarket Research, Sourcing
Contract Line ItemsMarket Research, Sourcing
Sales Rep ForecastsSourcing
Inventory AvailabilitySourcing
WarehousesSourcing
ProductsMarket Research

PostgreSQL ERP

TableUsed By
supplier_purchase_ordersMarket Research, Sourcing
productsAll agents
ref_sales_monthsMarket Research, Sourcing
ref_otw_transit_timesMarket Research
ref_landed_cost_estimatesMarket Research
ref_efi_portsMarket Research, Sourcing

External APIs

SourceCachePurpose
Datamyne US Maritime Imports (idApp 44)24hBOL records, importer/supplier totals, entity resolution
Datamyne US Import Census (idApp 127)24hFOB pricing by country and month
USDA MPR DataMart (report 2991)30dDairy component prices (butterfat, protein, Class III/IV)