# Architecture Overview

The Merso BNPL system consists of two main components: a **dashboard for game companies** and a **decentralized BNPL protocol** built on smart contracts.

## 🏗️ System Architecture

The Merso BNPL system is built on a multi-layered architecture that seamlessly integrates traditional web technologies with blockchain infrastructure. At the top layer, game companies interact with a comprehensive dashboard that provides real-time analytics and business intelligence. This dashboard serves as the primary interface for monitoring BNPL performance, user behavior, and revenue metrics.

The middle layer houses the core BNPL protocol, which consists of three interconnected smart contracts that handle the entire payment lifecycle. Each contract serves a specific purpose: the MersoBNPL contract manages the core BNPL logic and payment processing, the MersoTokenPool contract handles liquidity management for payment tokens, and the WrappedNFT contract creates transfer-restricted versions of original NFTs.

The bottom layer represents the blockchain infrastructure where the actual assets and transactions reside. This includes the original game NFTs, payment tokens used for transactions, and user wallets that interact with the protocol.

```
┌─────────────────────────────────────────────────────────────────┐
│                    GAME COMPANIES                               │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐  │
│  │   Dashboard     │    │   API Access    │    │   Analytics │  │
│  │   (Web App)     │    │   (JWT Auth)    │    │   & Reports │  │
│  └─────────────────┘    └─────────────────┘    └─────────────┘  │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                    MERSO BNPL PROTOCOL                          │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐  │
│  │   MersoBNPL     │    │   TokenPool     │    │  WrappedNFT │  │
│  │   (Per Game)    │    │   (Per Chain)   │    │(Per Collection)│
│  └─────────────────┘    └─────────────────┘    └─────────────┘  │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                    BLOCKCHAIN LAYER                             │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐  │
│  │   Game NFTs     │    │   Payment       │    │   User      │  │
│  │   (Original)    │    │   Tokens        │    │   Wallets   │  │
│  └─────────────────┘    └─────────────────┘    └─────────────┘  │
└─────────────────────────────────────────────────────────────────┘
```

## 🔗 Smart Contract Architecture

### **Contract Structure**

The BNPL protocol is built on three core smart contracts that work together to provide a secure and efficient payment system. Each contract is designed with specific responsibilities and security measures to ensure the integrity of the payment process.

The MersoBNPL contract serves as the central orchestrator of the BNPL system. It manages the core payment logic, tracks loan information, and coordinates interactions between users and the protocol. This contract is deployed per game, allowing for customization and optimization based on each game's specific requirements.

The MersoTokenPool contract handles liquidity management for payment tokens across different blockchains. It maintains pools of approved tokens and manages the flow of funds between users, the protocol, and game companies. This contract ensures that sufficient liquidity is available for all transactions.

The WrappedNFT contract creates transfer-restricted versions of original NFTs. These wrapped tokens maintain the same metadata and functionality as the original NFTs but include transfer restrictions during the payment period. This ensures that users cannot sell their NFTs before completing their payments while still allowing them to use the NFTs in games.

You can know more about the smart contracts here

```
┌─────────────────────────────────────────────────────────────────┐
│                    SMART CONTRACTS                              │
├─────────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐  │
│  │   MersoBNPL     │    │   TokenPool     │    │  WrappedNFT │  │
│  │   (Per Game)    │◄──►│   (Per Chain)   │◄──►│(Per Collection)│
│  └─────────────────┘    └─────────────────┘    └─────────────┘  │
└─────────────────────────────────────────────────────────────────┘
```
