How anhhuy007/nftify works
Project type and purpose
• NFTify is a React-based Single Page Application (SPA) built with Vite and Tailwind CSS.
• It serves as a decentralized application (DApp) frontend for interacting with an NFT Marketplace smart contract on Ethereum, integrating with MetaMask and external services (IPFS, Etherscan, and a separate backend server).
File structure
• Top-level: configuration files (.eslintrc, tailwind.config.js, vite.config.js), public assets, contract ABI (contract/NFTMarketplace.json), and frontend entrypoints (index.html, src/).
• src/ subdivides into:
· components/ — reusable UI elements and page-specific widgets
· pages/ — route-driven React pages (home, marketplace, NFT details, auth flows, settings)
· layouts/ — layout wrappers (AuthLayout, MarketplaceLayout, RootLayout)
· context/ — React Context providers (Auth, Cart, Wallet)
· handlers/ and services/ — abstraction for HTTP or blockchain calls (Endpoints.js, AuthHandler.js, NFTService.js, IpfsService.js)
· routes/ — client-side routing logic (PrivateRoute, index.jsx)
• No backend code here; the repo references a separate server.
Extract insights from the README
• Purpose: connect MetaMask, validate network, perform blockchain transactions (buy/sell/transfer NFTs), view transaction history.
• Tech stack: React, Vite, Tailwind, Solidity (contract ABI), Node.js/MongoDB backend (external), IPFS, Etherscan API.
Main components
a. Client (Browser)
• React SPA (pages, components, layouts).
• Context Providers (manage auth state, cart state, wallet state).
• Services & Handlers (NFTService, IpfsService, AuthHandler, Endpoints).
b. MetaMask Extension
• Provides Web3 provider, wallet address, network information, transaction signing.
c. Ethereum Network
• Smart contract (NFTMarketplace) deployed on a specific chain.
d. External Backend Server
• REST API for off-chain data (users, collections metadata), MongoDB database.
e. IPFS Network
• Stores and retrieves NFT media assets.
f. Etherscan API
• Fetches detailed transaction and block information.
Relationships and data flows
• User clicks in the UI → React component calls a Context or Service.
• For blockchain operations:
· Service picks up the contract ABI → metaMask.request() → Ethereum RPC endpoint → contract interaction (buy/sell/transfer).
· MetaMask pops up for signature → transaction submitted to Ethereum.
• For metadata or user data:
· Handler or Service issues HTTP request → External backend server → MongoDB → returns JSON metadata (e.g., collection info).
• For NFT media:
· Service calls IPFS gateway → retrieves image/video.
• For transaction details/history:
· Service calls Etherscan API → returns transaction logs → UI displays.
Architectural patterns and design principles
• Component-based UI (React) separated into Presentational and Container components.
• Context API for cross-cutting concerns (Auth, Wallet, Cart).
• Service/Handler layer abstracts external calls (blockchain RPC, REST API, IPFS).
• Layout + Route segregation for public vs authenticated flows (PrivateRoute).
• Single responsibility per module: UI, state management, data fetching.
• UI Layer (components/pages/layouts)
• State Layer (AuthProvider, WalletProvider, CartProvider)
• Service Layer (NFTService, IpfsService, Endpoints, AuthHandler)