Klaviyo Reference Architecture
SkillDev tools'Implement Klaviyo reference architecture with best-practice project
Use Klaviyo Reference Architecture in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Klaviyo Reference Architecture and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Klaviyo Reference Architecture skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by jeremylongshore/tons-of-skills-marketplace in skills/.curated/klaviyo-reference-architecture/SKILL.md and read by Ahel’s review.
Overview
Production-ready architecture for Klaviyo integrations: a layered project structure, service patterns, event-driven sync, and the klaviyo-api SDK wired into a real application. SKILL.md gives you the four-layer contract and the skeleton you scaffold from; the deep material lives in references/ so you pull code only when you reach that layer.
- Layout & layering (full directory tree, layer contract, data flow): architecture.md
- Working code for every layer (config, profile sync, event tracker): implementation.md
Prerequisites
- TypeScript project with
klaviyo-apiinstalled - Understanding of layered architecture
- Redis (for caching/queuing) and database (for audit/sync state)
Instructions
Use Write to scaffold the directory tree, then fill each layer bottom-up. The four layers and their one-way call rule:
API / Webhook Layer → routes + webhook handlers (calls Service only)
Service Layer → profile-sync, event-tracker, campaigns (calls SDK + Infra)
Klaviyo SDK Layer → ApiKeySession, ProfilesApi, EventsApi (never calls upward)
Infrastructure Layer → Redis cache, BullMQ queue, Prisma DB, OTel monitoring
- Scaffold the tree. Create the
src/{klaviyo,services,webhooks,jobs,middleware,config,health}layout. Full annotated tree: architecture.md. - Config layer first. A single
loadConfig()returns environment-specific keys, rate limits, and cache TTLs — every other layer reads from it. Code: implementation.md Step 1. - Service layer. Build
ProfileSyncService(bidirectional upsert) andEventTracker(server-sidePlaced Order/ custom events). Both route Klaviyo calls throughwithRateLimitRetry. Code: implementation.md Steps 2–3. - Wire the data flow. Signup →
syncToKlaviyo(), purchase →trackPurchase(), inboundprofile.updatedwebhook →WebhookRouter.routeEvent()→ local DB. Diagram: architecture.md.
When reviewing an existing project, Read its src/ tree and Grep for cross-layer imports that break the one-way rule (SDK importing a service, a route importing the SDK directly).
Output
Applying this skill produces:
- A scaffolded
src/tree matching the four-layer contract, with SDK, service, webhook, job, middleware, config, and health directories. - A working
config/klaviyo.tsplusProfileSyncServiceandEventTrackerservice classes ready to call from routes and jobs. - For a review pass: a list of layering violations (upward SDK calls, direct SDK use from routes) and sync-safety gaps to fix.
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Circular deps | Wrong layering | Services call SDK, never the reverse |
| Sync conflicts | Both sides update | Last-write-wins with sync timestamp |
| Queue backlog | Klaviyo slow/down | Circuit breaker + dead letter queue |
| Type mismatches | SDK version mismatch | Pin SDK version, run tsc --noEmit in CI |
Examples
Scaffold a new integration — "Set up a Klaviyo integration for our Node app." Create the layered tree, drop in loadConfig(), then ProfileSyncService and EventTracker. Full code per step: implementation.md.
Track a purchase from your backend:
await new EventTracker().trackPurchase({
email: order.email,
orderId: order.id,
total: order.total,
items: order.lineItems,
});
Review project structure — "Is our Klaviyo code layered correctly?" Grep for imports that violate the one-way call rule and check webhook handlers verify HMAC signatures. Layer contract: architecture.md.
Resources
Next Steps
For multi-environment configuration and per-stage key management, see the klaviyo-multi-env-setup skill in this pack.
Signals
- GitHub stars
- 3k
- Forks
- 415
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
klaviyo-reference-architecture- Source
- github.com/jeremylongshore/tons-of-skills-marketplace
github.com/jeremylongshore/tons-of-skills-marketplace
Related picks
Skill · mattpocock
The pick for TypeScripttypescript-pro
Skill · jeffallan
The pick for TypeScriptnodejs-backend-patterns
Skill · wshobson
The pick for Noderun-node-tests
Skill · hiroro-work
The pick for Nodeteach
Skill · mattpocock
More in Dev toolscaveman
Skill · juliusbrussee
More in Dev tools