# shubha-9051/zapier architecture

> Architecture diagram of the GitHub repository shubha-9051/zapier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shubha-9051/zapier
- Repository: https://github.com/shubha-9051/zapier

## Overview

##### Main Components Identification
The system consists of five major components that should be prominently displayed:

a) Frontend (Next.js Application)
b) Primary Backend (API Server)
c) Worker Service
d) Processor Service
e) Hooks Service

##### Component Details

Frontend (Blue Section):
- Main routes: Dashboard, Login, Signup, Zap Creation
- Components structure
- Connection to the Primary Backend via API calls

Primary Backend (Green Section):
- Main router endpoints (action, trigger, user, zap)
- Connection to its dedicated Prisma database
- Authentication middleware

Worker Service (Orange Section):
- Connections to email service
- Solana blockchain integration
- Parser functionality
- To its dedicated Prisma database

Processor Service (Purple Section):
- Role in workflow processing
- To its dedicated Prisma database

Hooks Service (Yellow Section):
- Integration points
- To its dedicated Prisma database

##### Database Schema Highlights

Database entities:
- User tables
- Zap definitions
- Triggers and Actions
- Transaction records
- Verification status

##### Critical Flows to Highlight

- User authentication flow
- Zap creation and execution
- Blockchain transaction processing
- Email verification process
- Error handling and recovery paths

##### Additional Notes

Annotations for:
- Scalability points
- Security measures
- Transaction consistency mechanisms
- Error handling strategies

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef backend fill:#e8f5e9,stroke:#1b5e20
    classDef worker fill:#fff3e0,stroke:#e65100
    classDef processor fill:#f3e5f5,stroke:#4a148c
    classDef hooks fill:#fff8e1,stroke:#f57f17
    classDef database fill:#eceff1,stroke:#263238
    classDef external fill:#fafafa,stroke:#424242

    %% Client Layer
    Client[Web Browsers]:::external

    %% Frontend Layer
    subgraph Frontend
        NextApp["Next.js Application"]:::frontend
        Dashboard["Dashboard"]:::frontend
        Login["Login"]:::frontend
        Signup["Signup"]:::frontend
        ZapCreation["Zap Creation"]:::frontend
        Components["Components"]:::frontend
    end

    %% Primary Backend Layer
    subgraph PrimaryBackend
        APIServer["API Server"]:::backend
        ActionRouter["Action Router"]:::backend
        TriggerRouter["Trigger Router"]:::backend
        UserRouter["User Router"]:::backend
        ZapRouter["Zap Router"]:::backend
        AuthMiddleware["Auth Middleware"]:::backend
        PrimaryDB[(Primary Database)]:::database
    end

    %% Service Layer
    subgraph WorkerService
        Worker["Worker Service"]:::worker
        EmailIntegration["Email Integration"]:::worker
        SolanaIntegration["Solana Integration"]:::worker
        Parser["Parser"]:::worker
        WorkerDB[(Worker Database)]:::database
    end

    subgraph ProcessorService
        Processor["Processor Service"]:::processor
        ProcessorDB[(Processor Database)]:::database
    end

    subgraph HooksService
        Hooks["Hooks Service"]:::hooks
        HooksDB[(Hooks Database)]:::database
    end

    %% External Services
    SolanaBC["Solana Blockchain"]:::external
    EmailService["Email Service"]:::external

    %% Relationships with Animation
    Client --->|1| NextApp
    NextApp --->|2| Dashboard & Login & Signup & ZapCreation
    NextApp --->|3| Components
    NextApp --->|4| APIServer

    APIServer --->|5| ActionRouter & TriggerRouter & UserRouter & ZapRouter
    APIServer --->|6| AuthMiddleware
    APIServer --->|7| PrimaryDB

    Worker --->|8| EmailIntegration
    Worker --->|9| SolanaIntegration
    Worker --->|10| Parser
    Worker --->|11| WorkerDB
    Worker --->|12| SolanaBC
    Worker --->|13| EmailService

    Processor --->|14| ProcessorDB
    Hooks --->|15| HooksDB

    %% TODOs
    TODO1["TODO #1: Email Verification"]:::external
    TODO2["TODO #2: Password Reset"]:::external
    TODO3["TODO #3: Solana Reconciliation"]:::external
    TODO4["TODO #4: React Flow Integration"]:::external

    %% Click Events
    click NextApp "https://github.com/shubha-9051/Zapier/tree/master/frontend"
    click Dashboard "https://github.com/shubha-9051/Zapier/blob/master/frontend/app/dashboard/page.tsx"
    click Login "https://github.com/shubha-9051/Zapier/blob/master/frontend/app/login/page.tsx"
    click Signup "https://github.com/shubha-9051/Zapier/blob/master/frontend/app/signup/page.tsx"
    click ZapCreation "https://github.com/shubha-9051/Zapier/blob/master/frontend/app/zap/create/page.tsx"
    click Components "https://github.com/shubha-9051/Zapier/tree/master/frontend/components"
    click APIServer "https://github.com/shubha-9051/Zapier/tree/master/primary-backend"
    click ActionRouter "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/src/router/action.ts"
    click TriggerRouter "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/src/router/trigger.ts"
    click UserRouter "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/src/router/user.ts"
    click ZapRouter "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/src/router/zap.ts"
    click AuthMiddleware "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/src/middleware.ts"
    click PrimaryDB "https://github.com/shubha-9051/Zapier/blob/master/primary-backend/prisma/schema.prisma"
    click Worker "https://github.com/shubha-9051/Zapier/tree/master/worker"
    click EmailIntegration "https://github.com/shubha-9051/Zapier/blob/master/worker/src/email.ts"
    click SolanaIntegration "https://github.com/shubha-9051/Zapier/blob/master/worker/src/solana.ts"
    click Parser "https://github.com/shubha-9051/Zapier/blob/master/worker/src/parser.ts"
    click WorkerDB "https://github.com/shubha-9051/Zapier/blob/master/worker/prisma/schema.prisma"
    click Processor "https://github.com/shubha-9051/Zapier/blob/master/processor/src/index.ts"
    click ProcessorDB "https://github.com/shubha-9051/Zapier/blob/master/processor/prisma/schema.prisma"
    click Hooks "https://github.com/shubha-9051/Zapier/blob/master/hooks/src/index.ts"
    click HooksDB "https://github.com/shubha-9051/Zapier/blob/master/hooks/prisma/schema.prisma"
```
