Protocol Architecture

Comprehensive overview of the Irion Pay system on Algorand.

Full Stack Overview

Irion Pay utilizes a decentralized, monorepo architecture that combines high-performance blockchain logic with modern web technologies to provide a consumer-grade BNPL experience.

Technical Stack

LayerTechnology
BlockchainAlgorand (AVM)
Smart ContractsPython / PuyaTS
FrontendNext.js 15, Tailwind CSS, Shadcn UI
Backend/APINext.js API Routes (Serverless)
DatabaseMongoDB Atlas
SDK/InteractionsAlgoKit Utils, Algosdk

System Diagram

graph TD
    User([User]) <--> CoreApp[Irion Core Dashboard]
    Shopper([Shopper]) <--> ShoppingApp[E-commerce Store]
    Merchant([Merchant]) <--> MerchantApp[Merchant Portal]
    
    ShoppingApp <--> APILayer[Next.js API Layer]
    MerchantApp <--> APILayer
    CoreApp <--> APILayer
    
    APILayer <--> MongoDB[(MongoDB Atlas)]
    APILayer <--> Algorand[Algorand Testnet/LocalNet]
    
    subgraph Smart Contracts
        Algorand <--> CreditScore[CreditScore Contract]
        Algorand <--> LendingPool[LendingPool Contract]
        Algorand <--> BNPL[BNPLCredit Contract]
        Algorand <--> Escrow[MerchantEscrow Contract]
    end

Core Architecture Components

1. Smart Contracts (The Engine)

The Algorand Virtual Machine (AVM) hosts the core logic. Transactions are processed in seconds with minimal fees, enabling the real-time checkout experience essential for BNPL.

2. Next.js API Layer (The Orchestrator)

The API layer acts as a bridge between the blockchain and the user-facing apps. It manages:

  • Transaction Preparation: Building complex atomic groups for checkouts and repayments.
  • Data Indexing: Syncing on-chain state to MongoDB for fast, searchable access.
  • Merchant Verification: Authenticating cross-site checkout requests via CORS-enabled routes.

3. MongoDB Layer (The Memory)

While the blockchain is the source of truth for assets and debt, MongoDB stores auxiliary data like:

  • Merchant profiles and product catalogs.
  • High-frequency transaction history for the dashboard.
  • Active user sessions and interaction logs.

Data Flows

The BNPL Checkout Flow

  1. Shopper: Selects "Pay with Irion" on the Shopping App.
  2. API: Checks the shopper's CreditScore and available limit on-chain.
  3. Escrow: If approved, funds are moved from the LendingPool to MerchantEscrow.
  4. Settlement: The Merchant receives USDC immediately, and a Loan entry is created for the Shopper.

The Repayment Flow

  1. User: Initiates repayment via Irion Core.
  2. Contract: BNPLCredit calculates the principal + interest due.
  3. Distribution: Funds are transferred back to the LendingPool and the loan is closed.
  4. Credit Boost: CreditScore is updated automatically upon successful closure.