DEV Community

Cover image for Building TFCRM: Guarded LangGraph Swarms, Postgres MCP, and Durable Churn Analysis for the OpenAI Hackathon
Avi Sharma
Avi Sharma

Posted on

Building TFCRM: Guarded LangGraph Swarms, Postgres MCP, and Durable Churn Analysis for the OpenAI Hackathon

The Problem: Traditional CRMs Are Data Cemeteries

Most B2B SaaS companies, subscription startups, and agencies suffer from the same operational bottleneck: stale CRM data. Traditional CRMs record historical transactions and basic communication logs perfectly, but they fail to act on live application health metrics before a customer decides to churn.

Worse yet, spinning up AI agents to solve this problem introduces massive security anxieties. Granting a Large Language Model direct write access to a production database or an automated email dispatcher is an invitation for operational chaos.

For the OpenAI Hackathon, I built TFCRM—a stateful, customer-success CRM engineered to turn scattered telemetry events and bulk data imports into guarded, evidence-based retention workflows. It bridges the gap between automated AI insights and strict operational discipline.


The Technical Architecture

TFCRM is split into a high-performance web ledger, a real-time event ingestion engine, and a database-backed background execution queue.

Layer Technology Stack Responsibility
Frontend React 19 + Vite Multi-tenant dashboards, role-aware action mapping, and real-time agent token streams over WebSockets.
Backend FastAPI + Python 3.12 Asynchronous token verification, workspace-scoped RBAC, and background execution polling loops.
Database Neon PostgreSQL + pgvector Relational business ledger and durable checkpoint storage for long-running LangGraph state machines.
AI Swarm LangGraph + OpenAI Guarded routing, semantic resolution caching, and autonomous evidence collection.
Outreach Resend API Human-in-the-loop delivery engine restricted to verified domain identities.

mermaid
flowchart TD
    User[CSM / Workspace Owner] -->|Interactive UI| UI[React + Vite Frontend]
    UI -->|JWT Authenticated Requests| API[FastAPI Application]
    API -->|Async State Management| Queue[Durable Background Dispatcher]
    Queue -->|State Machine Isolation| Agents[LangGraph AI Swarm]
    Agents -->|Restricted Handshake| MCP[Postgres MCP Server]
    MCP -->|Read-Only Queries| DB[(Neon PostgreSQL + pgvector)]
    API -->|Transactional Actions| DB
    API -->|Human-Approved Outreach| Resend[Resend Email API]
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev

The guarded part is what makes this kind of CRM agent credible. Churn analysis touches enough messy business context that the system needs durable memory, source links, and clear human approval points. Otherwise it becomes a confident summarizer over fragile assumptions.