# viveksurti-dev/nft-marketplace architecture

> Architecture diagram of the GitHub repository viveksurti-dev/nft-marketplace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/viveksurti-dev/nft-marketplace
- Repository: https://github.com/viveksurti-dev/nft-marketplace

## Overview

##### Project type and purpose
- This is a full-stack web application: an NFT Marketplace built in PHP with a MySQL backend.
- It provides user account management, NFT minting and trading, wallet transactions, admin controls, and email notifications.

##### File structure
- Top-level directories indicate major components:
- Account/ – user profile, login, password reset
- Admin/ – admin panel, content and user management
- Collection/ – NFT collection creation and editing
- Trans/ – wallet and transaction flows (buy, sell, transfer, add/withdraw funds)
- Assets/ – static assets (images, videos, CSS, JS)
- ajaxValidation/ – server-side validation endpoints
- Functions/ – reusable PHP functions (CRUD, role updates)
- mailpage/ – email templates and sending logic via PHPMailer
- PhonePe/ – payment gateway integration scripts
- Database File/ – SQL schema and seed scripts
Other files like config.php, composer.json, and core pages (index.php, login.php, register.php) sit at the root.

##### README insights
- Confirms PHP + MySQL stack, Composer packages, PHPMailer, Bootstrap for frontend.
- Highlights feature modules: authentication, minting, marketplace, wallet, admin dashboard.
- Mentions email flows (password reset) and external SMTP.

##### Main components
a. Frontend (browser)
- Static assets: HTML/CSS/JS (Bootstrap), AJAX calls to validation endpoints.
- UI modules: landing page, account pages, collection pages, transaction pages, admin dashboard.
b. Backend (web server / PHP)
- Router/core pages: index.php, account controllers, collection controllers, transaction controllers, admin controllers.
- Reusable functions (Functions/), validation endpoints (ajaxValidation/), payment handlers (PhonePe/).
- Email service module (mailpage/) using PHPMailer.
c. Database (MySQL)
- Core tables: users, wallets, nft_collections, nfts, transactions, admin_logs, password_resets.
- SQL scripts under Database File/.
d. External services
- SMTP server (for email notifications).
- Payment gateway (PhonePe API).
- Composer-installed libraries.

##### Relationships and data flows
- User interacts with the browser → front-end pages → sends HTTP requests to PHP controllers.
- Controllers read/write from MySQL via config.php connection.
- AJAX validation → PHP scripts under ajaxValidation/.
- NFT minting → Inserts new records in nft_collections & nfts tables.
- Marketplace purchase → Transaction flow in Trans/ → updates wallet balance and transaction history.
- Admin actions → Admin/ pages → manipulate user, FAQs, ads, articles in the database.
- Email flows → Triggered within controllers → mailpage/ sends via SMTP.
- Payment gateway → PhonePe scripts call external API, then callback to paymentStatus.php.

##### Architectural patterns and principles
- Modular directory structure – loosely resembles MVC:
- “Views”: .php pages output HTML mixed with PHP includes (Navbar.php, footer.php).
- “Controllers”: core pages under Account/, Collection/, Trans/, Admin/.
- “Models”: implicit in reusable functions (Functions/) and direct DB access in controllers.
- Separation of concerns: assets, validation, mailing, payment, database schemas each in their own directory.
- Stateful session management for authentication.
- Composer for dependency management.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client (Browser)" 
        direction TB
        UI["UI Pages (HTML/CSS/JS)"]:::client
        UI -->|AJAX| AJX
        UI -->|HTTP| Core
    end

    subgraph "Server (Web Server / PHP)"
        direction TB

        subgraph "Core Pages & Layout" 
            direction TB
            Core["index.php / dash.php / userDashboard.php"]:::core
            Navbar["Navbar.php"]:::core
            Footer["footer.php"]:::core
            Core --> Navbar
            Core --> Footer
        end

        subgraph "Account Module" 
            direction TB
            AM["Account/"]:::usermod
            Login["login.php"]:::usermod
            Register["register.php"]:::usermod
            Forgot["forgotpassword.php"]:::usermod
            Reset["resetpassword.php"]:::usermod
            AM --> Login
            AM --> Register
            AM --> Forgot
            AM --> Reset
        end

        subgraph "Collection Module"
            direction TB
            CM["Collection/"]:::usermod
            Deploy["Deploy.php"]:::usermod
            EditCol["editCollection.php"]:::usermod
            ColDet["collectionDetails.php"]:::usermod
            NFTDet["NFTDetails.php"]:::usermod
            Vol["totalVolume.php"]:::usermod
            CM --> Deploy
            CM --> EditCol
            CM --> ColDet
            CM --> NFTDet
            CM --> Vol
        end

        subgraph "Transaction Module"
            direction TB
            TM["Trans/"]:::usermod
            CreatePW["CreateWalletPassword.php"]:::usermod
            Activate["ActivateWallet.php"]:::usermod
            Wallet["Wallet.php"]:::usermod
            Dashboard["WalletDashboard.php"]:::usermod
            AddMoney["addMoney.php"]:::usermod
            Withdraw["withdrawFund.php"]:::usermod
            Transfer["MoneyTransfer.php"]:::usermod
            NFTPay["NFTPayment.php"]:::usermod
            BuyPay["BuyingPayment.php"]:::usermod
            CollPay["CollectionPayment.php"]:::usermod
            TransHist["transactions.php"]:::usermod
            TM --> CreatePW
            TM --> Activate
            TM --> Wallet
            TM --> Dashboard
            TM --> AddMoney
            TM --> Withdraw
            TM --> Transfer
            TM --> NFTPay
            TM --> BuyPay
            TM --> CollPay
            TM --> TransHist
        end

        subgraph "Admin Module"
            direction TB
            AMOD["Admin/"]:::admin
            ATrans["Transactions.php"]:::admin
            Ads["createAds.php"]:::admin
            FAQs["createFAQs.php"]:::admin
            Article["createArticle.php"]:::admin
            Panel["AdminPanel.php"]:::admin
            ManageU["AdminManageUser.php"]:::admin
            AMOD --> ATrans
            AMOD --> Ads
            AMOD --> FAQs
            AMOD --> Article
            AMOD --> Panel
            AMOD --> ManageU
        end

        subgraph "AJAX Validation"
            direction TB
            AJX["ajaxValidation/"]:::service
            CheckEmail["checkEmail.php"]:::service
            CheckPhone["checkPhone.php"]:::service
            CheckUser["checkUser.php"]:::service
            AJX --> CheckEmail
            AJX --> CheckPhone
            AJX --> CheckUser
        end

        subgraph "Reusable Functions"
            direction TB
            FUNC["Functions/"]:::service
        end

        subgraph "Email Service"
            direction TB
            MAIL["mailpage/"]:::service
        end

        subgraph "Payment Gateway"
            direction TB
            PP["PhonePe/"]:::service
        end

        subgraph "Static Assets"
            direction TB
            AS["Assets/"]:::assets
        end

        subgraph "Testing & Utilities"
            direction TB
            TEST["testingmode/"]:::service
        end
    end

    subgraph "Database (MySQL)"
        direction TB
        DB["MySQL"]:::db
        Schema["nftfinal.sql"]:::db
    end

    subgraph "External Services"
        direction TB
        SMTP["SMTP Server"]:::external
        PhonePeAPI["PhonePe API"]:::external
    end

    UI -->|"GET/POST"| Core
    UI -->|"POST AJAX"| AJX

    Core --> Account
    Core --> CM
    Core --> TM
    Core --> AMOD

    Login -->|SQL queries| DB
    Register -->|SQL queries| DB
    Deploy -->|SQL queries| DB
    NFTPay -->|SQL updates| DB
    BuyPay -->|SQL updates| DB
    ATrans -->|SQL queries| DB

    Register -->|trigger| MAIL
    Reset -->|trigger| MAIL
    AddMoney -->|trigger| MAIL

    TM --> PP
    PP -->|callback| Core

    MAIL --> SMTP

    Core --> FUNC

    Core --> AS
    Unused --> TEST

    Core --> DB
    FUNC --> DB
    AJX --> DB
    PP --> PhonePeAPI

    click AM "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Account/"
    click Login "https://github.com/viveksurti-dev/nft-marketplace/blob/main/login.php"
    click Register "https://github.com/viveksurti-dev/nft-marketplace/blob/main/register.php"
    click Forgot "https://github.com/viveksurti-dev/nft-marketplace/blob/main/forgotpassword.php"
    click Reset "https://github.com/viveksurti-dev/nft-marketplace/blob/main/resetpassword.php"
    click CM "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Collection/"
    click Deploy "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Collection/Deploy.php"
    click EditCol "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Collection/editCollection.php"
    click ColDet "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Collection/collectionDetails.php"
    click NFTDet "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Collection/NFTDetails.php"
    click TM "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Trans/"
    click CreatePW "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/CreateWalletPassword.php"
    click Activate "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/ActivateWallet.php"
    click Wallet "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/Wallet.php"
    click Dashboard "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/WalletDashboard.php"
    click AddMoney "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/addMoney.php"
    click Withdraw "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/withdrawFund.php"
    click Transfer "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/MoneyTransfer.php"
    click NFTPay "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/NFTPayment.php"
    click BuyPay "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/BuyingPayment.php"
    click CollPay "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/CollectionPayment.php"
    click TransHist "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Trans/transactions.php"
    click AMOD "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Admin/"
    click ATrans "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Admin/Transactions.php"
    click Ads "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Admin/createAds.php"
    click FAQs "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Admin/createFAQs.php"
    click Article "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Admin/createArticle.php"
    click Panel "https://github.com/viveksurti-dev/nft-marketplace/blob/main/AdminPanel.php"
    click ManageU "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Admin/AdminManageUser.php"
    click AS "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Assets/"
    click AJX "https://github.com/viveksurti-dev/nft-marketplace/tree/main/ajaxValidation/"
    click CheckEmail "https://github.com/viveksurti-dev/nft-marketplace/blob/main/ajaxValidation/checkEmail.php"
    click CheckPhone "https://github.com/viveksurti-dev/nft-marketplace/blob/main/ajaxValidation/checkPhone.php"
    click CheckUser "https://github.com/viveksurti-dev/nft-marketplace/blob/main/ajaxValidation/checkUser.php"
    click FUNC "https://github.com/viveksurti-dev/nft-marketplace/tree/main/Functions/"
    click MAIL "https://github.com/viveksurti-dev/nft-marketplace/tree/main/mailpage/"
    click PP "https://github.com/viveksurti-dev/nft-marketplace/tree/main/PhonePe/"
    click Schema "https://github.com/viveksurti-dev/nft-marketplace/blob/main/Database File/nftfinal.sql"
    click Core "https://github.com/viveksurti-dev/nft-marketplace/blob/main/index.php"
    classDef client fill:#ccffcc,stroke:#006600
    classDef usermod fill:#e6ffe6,stroke:#009900
    classDef admin fill:#cce5ff,stroke:#0047b3
    classDef service fill:#ffffcc,stroke:#b3b300
    classDef assets fill:#ffebcc,stroke:#cc6600
    classDef core fill:#e0e0e0,stroke:#666666
    classDef db fill:#ffe6e6,stroke:#cc0000
    classDef external fill:#f2f2f2,stroke:#999999
```
