Technology Stack & Role
PropelDesk was built to show how modern SaaS architectures can leverage AI agents to automate high-volume support tasks while providing enterprise-grade multi-tenancy, security, and billing logic.
Backend & AI Pipeline
Bun + Hono API & LangGraph Agents
Drizzle ORM / pgvector / Redis
Web Application
Next.js 15 (App Router)
Tailwind CSS v4 / Zustand / React 19
Integrations
Stripe Subscriptions & Resend SMTP
Webhooks / BullMQ workers
1. The Business & Engineering Problem
Support workflows for mid-market SaaS companies are notoriously manual and error-prone. Freelance clients repeatedly request features to solve these major pain points:
- Inefficient Classification: High volumes of incoming tickets are manually categorized by staff, delaying urgent high-priority support.
- SLA Breaches: Tickets expire or miss response times because escalations aren't tracked dynamically against tenant tier rules.
- Knowledge Silos: Agents write repetitive responses to simple, well-documented queries, wasting precious developer and support hours.
- Complex Multi-Tenancy: Safely isolating customer data, user roles, billing statuses, and custom webhook configurations across tenants.
2. High-Level System Architecture
I architected a multi-tenant schema with logical database-level isolation. An event-driven queue processes incoming tickets, routes them to a LangGraph-powered AI coordinator, and issues immediate updates to client dashboards via server-sent events.
A shared PostgreSQL instance where every table containing tenant-specific data enforces a strict index-optimized tenant_id query filter, guarded by a centralized row-level API middleware layer.
Receives raw ticket content, fetches tenant knowledge base vectors using pgvector HNSW search, generates drafts, routes based on intent, or auto-resolves standard queries.
Redis-backed task scheduler setting delayed timers for active ticket SLA breaches. Automatically trigger Slack/Email alerts if tickets remain unassigned.
3. Core Engineering Implementations
A. AI Support Agentic State Machine via LangGraph
Instead of a basic single-shot LLM prompt, tickets pass through a state machine that decides whether to (1) search the semantic vector DB, (2) auto-resolve the ticket with an email reply, (3) escalate to a human agent, or (4) call external tenant tools.
/** State definition and routing node configuration **/ const supportGraph = new StateGraph({ channels: TicketState }) .addNode("triage", triageNode) .addNode("search_docs", documentRetrievalNode) .addNode("auto_resolve", autoResolveNode) .addNode("human_escalate", escalateNode) .addEdge(START, "triage") .addConditionalEdges("triage", routeTicket, { autoResolve: "search_docs", escalate: "human_escalate" }) .addEdge("search_docs", "auto_resolve") .addEdge("auto_resolve", END) .addEdge("human_escalate", END);
B. Secure Row-Level Multi-Tenant Isolation Middleware
To prevent critical data leaks between tenants, the Hono backend intercepts all requests, extracts the verified tenant session from headers, and injects a scoped DB client that auto-appends `tenantId` queries across Drizzle operations.
/** Scoped Drizzle context query injector **/ export const tenantGuard = createMiddleware(async (c, next) => { const tenantId = c.req.header("X-Tenant-ID"); if (!tenantId) throw new HTTPException(401, { message: "Unauthorized" }); -- Bind tenant-scoped db helper context c.set("db", { tickets: { findMany: (args) => db.select().from(tickets) .where(and(eq(tickets.tenantId, tenantId), args?.where)), insert: (data) => db.insert(tickets).values({ ...data, tenantId }) } }); await next(); });
C. Subscriptions & Webhook Processing
Attracting business clients requires robust payment infrastructure. PropelDesk implements **Stripe Billing** with subscription seat licenses. Hono handles Stripe signatures and publishes events to BullMQ, making payments highly reliable.
4. Performance & SLA Audit Logs
To ensure prompt agentic routing, the platform is integrated with telemetry systems that trace LLM response times, token counts, and accuracy benchmarks.
5. Key Engineering Accomplishments
Support ticket volume auto-resolved by RAG docs search without human intervention.
Multi-tenant data leaks recorded under stress testing with cross-tenant keys.
Automated SLA escalation execution coverage powered by BullMQ scheduler.
PropelDesk demonstrates how modern web applications can securely merge artificial intelligence with strict multi-tenant SaaS patterns to deliver massive business cost savings.