GrapeShop
WhatsApp-native AI commerce platform
A commerce platform for merchants who already sell on WhatsApp. Sellers build a catalogue once; an AI assistant then handles customer conversations end to end — quoting live prices, assembling carts, taking bookings and issuing payment links, all inside the seller's own permissions.
Backend
AI
Clients
Platform
The problem
Millions of merchants run their entire business in WhatsApp DMs — no catalogue, no order history, no payment trail. Existing storefront tools ask them to abandon the channel their customers already use.
The approach
Rather than replace WhatsApp, I instrumented it. A modular NestJS monolith spans three isolated PostgreSQL databases joined by logical UUID references, so no distributed transactions are needed and each domain stays extractable. An MCP tool layer sits between the language model and the commerce API, giving the agent a typed, permission-scoped surface instead of raw database access.
Engineering highlights
An agent that actually transacts
Exposed the commerce API to the LLM through a Model Context Protocol server with two distinct trust boundaries — the seller's own RS256 JWT for merchant actions, a narrower service token for anonymous buyers. The agent's authority is exactly the caller's authority.
Retrieval-augmented conversation memory
Long-term memory on pgvector with HNSW cosine indexing, blending semantic recall with recency so the assistant remembers a returning customer's preferences without replaying an entire chat history into the context window.
Prompt caching without cross-tenant leakage
Anthropic prompt caching applied to shared instruction blocks only, with per-tenant data deliberately excluded from the cached prefix.
Never talk over a human
A vendor-response guard checks conversation state both before generation and again immediately before send, so the bot goes silent the moment the seller starts typing.
Two-tier AI billing
Per-feature token accounting alongside conversation credits metered against WhatsApp's own 24-hour session window, so cost is attributed to the unit the merchant actually understands.
Production WhatsApp on the Web protocol
Built on Baileys with QR and pairing-code flows, JSONB session persistence guarded by write-lock serialisation, exponential reconnect backoff, and message deduplication — the difference between a demo and a session that survives a week.
