How heymustafa02/zapy works
Project Type and Purpose
• This is a full-stack, event-driven automation platform (“zapy”) where users define “zaps” (trigger → action workflows).
• Key user flows: signup/login, create/manage zaps, trigger execution (e.g. send email, interact with blockchain).
• Implementation uses:
• Frontend: Next.js + TypeScript + Tailwind
• Primary-backend: Node.js + Prisma + REST/Router for user, zap, trigger, action
• Hooks service: processes real-time trigger events (outbox pattern)
• Processor service: orchestrates zap runs and scheduling
• Worker service: performs side-effects (email, Ethereum, Solana)
File-Structure Analysis
• frontend/: Next.js app with pages (dashboard, login, signup, zap creation) and reusable UI components
• hooks/: Node.js microservice (Prisma + migrations) that reads outbox entries and emits hook events
• primary-backend/: Core REST API + Prisma schema + user/zap/trigger/action routers + middleware
• processor/: Lightweight orchestrator microservice managing the lifecycle of zap runs
• worker/: Background worker microservice handling external integrations (email.ts, eth.ts, solana.ts, parser.ts)
• All services use Prisma migrations for their own database schema → each may share a central database or have isolated schemas.
Important Architectural Patterns
• Microservices: each logical component is its own service folder
• Event-driven / Outbox Pattern: primary-backend writes triggers/actions to an outbox table; hooks or processor pick them up
• Shared Database (Prisma) vs service-specific schemas
• Background workers for side-effects and blockchain interactions
• API-driven frontend communicating via REST endpoints
Main Components and Interactions
a. Frontend (Next.js)
• UI pages + component library
• Calls Primary-backend via HTTP (e.g. /api/login, /api/zaps)
b. Primary-backend (API)
• Exposes user/zap/trigger/action endpoints
• Persists to central relational DB via Prisma
• Writes “outbox” records for events (new trigger, run zap)
c. Hooks Service
• Polls or subscribes to outbox table for trigger events
• Emits webhooks or internal events to Processor
d. Processor Service
• Receives trigger events
• Reads zap definitions and scheduling logic
• Enqueues jobs for Worker
e. Worker Service
• Listens to job queue or outbox for tasks
• Executes side-effects:
• Email service (verification, password reset)
• Blockchain integrations (Ethereum, Solana)
f. Database
• Central PostgreSQL (or similar) accessed by Prisma in all services
g. External Services
• SMTP/email provider
• Ethereum node / RPC provider
• Solana RPC provider