# neelshah1505/transactin architecture

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

- Interactive diagram: https://gitdiagram.com/neelshah1505/transactin
- Repository: https://github.com/neelshah1505/transactin

## Overview

##### Project type and purpose
- TransactIN is a full-stack, decentralized payment protocol built with Next.js (React) on the frontend, Next.js API routes as the backend, and Solidity smart contracts on EVM chains. It provides EIP-712 dual-signature token transfers, cross-chain support (Chainlink CCIP & Circle CCTP), on-chain verification, gasless relayers, and real-time attestation indexing (The Graph).

##### File structure
- Top level:
- app/ (Next 13 “app router” pages, API routes, global layout, providers)
- components/ (UI primitives & domain components)
- contract/ (ABI JSON artifacts)
- lib/ (Apollo GraphQL client)
- utils/ (formatters, validation schemas, Wagmi setup)
- Key config: next.config.mjs, tsconfig.json, tailwind.config.ts
- API routes in app/api handle fetch/store transactions and payment callbacks.
- Providers.tsx wires up Wagmi (blockchain) and Apollo (The Graph).

##### Readme insights
- Architecture relies on:
- Frontend Next.js (React)
- Backend API routes
- Ethers.js & Wagmi for wallet interactions & EIP-712 signing
- Solidity contracts for on-chain dual-signature verification
- Chainlink CCIP & Circle CCTP for cross-chain messages
- The Graph for attestation indexing & Apollo GraphQL queries

a. Frontend (Next.js app)
– Pages: /, /dashboard, /send-request
– React components & UI libs (Tailwind, custom modals, spinners)
– Wagmi hooks for wallet connect & EIP-712 signing
– Apollo Client for GraphQL queries to The Graph
b. API layer (Next.js app/api)
– fetch-transaction, store-transaction, latest-transactionid, payment-completed
– Orchestrates calls between frontend, The Graph, and on-chain relayer services
c. Smart Contracts (EVM)
– Dual-signature contracts verifying EIP-712 data
– Cross-chain gateways (Chainlink CCIP, Circle CCTP)
d. External Services
– Chainlink CCIP network
– Circle CCTP bridge
– The Graph indexing node
– Relayer (third-party or custom off-chain executor)
e. Data Stores
– On-chain state in smart contracts

##### Relationships and data flow
1. User (sender) → Next.js UI → Wagmi/Ethers.js → EIP-712 message → Wallet signature
2. UI → API `/store-transaction` → off-chain storage or triggers relayer
3. Recipient fetches pending transaction → signs via EIP-712
4. API `/payment-completed` or relayer service → submits both signatures to on-chain contract
5. Smart contract validates dual signatures → emits events
6. Chainlink CCIP / Circle CCTP handle cross-chain message passing if needed
7. The Graph indexes contract events → makes data available via GraphQL
8. Frontend queries GraphQL via Apollo → updates dashboard

##### Architectural patterns & design principles
- Separation of concerns: clear frontend vs. API code vs. blockchain code
- Modular React components + Tailwind CSS for style
- Provider pattern for injecting Wagmi & Apollo contexts
- Next.js “app router” conventions for server/client boundaries
- Event-driven on-chain → off-chain indexing (The Graph)

- Client-side components
- Server/API components
- On-chain components
- Off-chain services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Client-side)"
        direction TB
        HomePage["Home Page"]:::frontend
        DashboardPage["Dashboard Page"]:::frontend
        SendRequestPage["Send Request Page"]:::frontend
        Layout["Global Layout"]:::frontend
        GlobalsCSS["Global Stylesheet"]:::frontend
        Providers["App Providers (Wagmi & Apollo)"]:::frontend
        Header["Header Component"]:::frontend
        Accordian["AccordionExpanded"]:::frontend
        RequestModal["RequestModal"]:::frontend
        LoadingSpinner["LoadingSpinner"]:::frontend
        TransactionAccordian["TransactionAccordian"]:::frontend
        AddressCopy["AddressWithCopy"]:::frontend
        ApproveToken["ApproveToken"]:::frontend
        CustomSelect["CustomSelect"]:::frontend
        Timestamp["Timestamp"]:::frontend
        ApolloP["ApolloP"]:::frontend
    end

    %% API Layer
    subgraph "API Layer (Next.js API Routes)"
        direction TB
        FetchTx["fetch-transaction"]:::api
        StoreTx["store-transaction"]:::api
        LatestTxID["latest-transactionid"]:::api
        PaymentCompleted["payment-completed"]:::api
    end

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        direction TB
        SmartContracts(("Smart Contracts")):::blockchain
        DualSigABI["Dual-Signature Contract ABI"]:::blockchain
        ERC20ABI["ERC-20 Token ABI"]:::blockchain
    end

    %% Indexing & GraphQL
    subgraph "Indexing & GraphQL"
        direction TB
        TheGraph(("The Graph Subgraph")):::datastore
        ApolloClient["Apollo Client"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Wallet["Wallet (Wagmi/Ethers)"]:::external
        ChainlinkCCIP["Chainlink CCIP"]:::external
        CircleCCTP["Circle CCTP"]:::external
        Relayer["Relayer Service"]:::external
    end

    %% Connections
    HomePage -->|"HTTP/HTTPS"| FetchTx
    DashboardPage -->|"GraphQL"| ApolloClient
    SendRequestPage -->|"HTTP/HTTPS"| StoreTx
    StoreTx -->|"JSON-RPC"| Relayer
    PaymentCompleted -->|"JSON-RPC"| SmartContracts
    Relayer -->|"JSON-RPC"| SmartContracts
    SmartContracts -->|"Event Logs"| TheGraph
    ApolloClient -->|"GraphQL"| TheGraph
    SendRequestPage -->|"EIP-712 Sig"| Wallet
    DashboardPage -->|"EIP-712 Sig"| Wallet
    Wallet -->|"Signed Tx"| StoreTx
    Wallet -->|"Signed Tx"| PaymentCompleted
    ChainlinkCCIP -->|"CCIP Msg"| SmartContracts
    CircleCCTP -->|"CCTP Msg"| SmartContracts
    TheGraph -->|"Indexed Data"| ApolloClient

    %% Click Events
    click HomePage "https://github.com/neelshah1505/transactin/blob/main/app/page.tsx"
    click DashboardPage "https://github.com/neelshah1505/transactin/blob/main/app/dashboard/page.tsx"
    click SendRequestPage "https://github.com/neelshah1505/transactin/blob/main/app/send-request/page.tsx"
    click Layout "https://github.com/neelshah1505/transactin/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/neelshah1505/transactin/blob/main/app/globals.css"
    click Providers "https://github.com/neelshah1505/transactin/blob/main/app/providers.tsx"
    click Header "https://github.com/neelshah1505/transactin/blob/main/components/header/Header.tsx"
    click Accordian "https://github.com/neelshah1505/transactin/blob/main/components/common/AccordianExpanded.tsx"
    click RequestModal "https://github.com/neelshah1505/transactin/blob/main/components/common/RequestModal.tsx"
    click LoadingSpinner "https://github.com/neelshah1505/transactin/blob/main/components/common/LoadingSpinner.tsx"
    click TransactionAccordian "https://github.com/neelshah1505/transactin/blob/main/components/common/TransactionAccordian.tsx"
    click AddressCopy "https://github.com/neelshah1505/transactin/blob/main/components/common/AddressWithCopy.tsx"
    click ApproveToken "https://github.com/neelshah1505/transactin/blob/main/components/common/ApproveToken.tsx"
    click CustomSelect "https://github.com/neelshah1505/transactin/blob/main/components/common/CustomSelect.tsx"
    click Timestamp "https://github.com/neelshah1505/transactin/blob/main/components/common/Timestamp.tsx"
    click ApolloP "https://github.com/neelshah1505/transactin/blob/main/components/common/ApolloP.tsx"
    click FetchTx "https://github.com/neelshah1505/transactin/blob/main/app/api/fetch-transaction/route.ts"
    click StoreTx "https://github.com/neelshah1505/transactin/blob/main/app/api/store-transaction/route.ts"
    click LatestTxID "https://github.com/neelshah1505/transactin/blob/main/app/api/latest-transactionid/route.ts"
    click PaymentCompleted "https://github.com/neelshah1505/transactin/blob/main/app/api/payment-completed/route.ts"
    click DualSigABI "https://github.com/neelshah1505/transactin/blob/main/contract/dualsign.json"
    click ERC20ABI "https://github.com/neelshah1505/transactin/blob/main/contract/ERC20ABI.json"
    click ApolloClient "https://github.com/neelshah1505/transactin/blob/main/lib/apolloClient.ts"
    click Wallet "https://github.com/neelshah1505/transactin/blob/main/utils/wagmi.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef api fill:#D1FAD7,stroke:#28A745,color:#155724;
    classDef blockchain fill:#FFE4B5,stroke:#E09E00,color:#8A4F00;
    classDef external fill:#EDE7F6,stroke:#6A1B9A,color:#4A148C;
    classDef datastore fill:#FFDDE2,stroke:#D32F2F,color:#B71C1C;
```
