Skip to content

Breitjoda/BlockchainExchange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 BlockchainExchange - Multi-Chain NFT & Coin Exchange

A decentralized multi-chain exchange supporting Flow, Ethereum, and Polygon blockchains with NFT marketplace, token swaps, liquidity pools, and real-time analytics.

✨ Features

Must-Have βœ…

  • πŸ–ΌοΈ NFT Marketplace - Buy, sell, and trade Flow NFTs with 1% fees
  • πŸ’± Coin/Token Swap - Instant token exchange with automatic market maker (AMM)
  • πŸ’§ Liquidity Pools - Provide liquidity and earn from transaction fees
  • πŸ“Š Analytics Dashboard - Real-time trading data, volume charts, and top traders

Governance πŸ—³οΈ

  • BXEX Governance Token - 10M Initial Supply for voting
  • Fee Distribution - 1% trading fees β†’ 0.5% to LPs + 0.5% to Governance Treasury
  • Multi-Chain Support - Flow, Ethereum, Polygon ready

πŸ—οΈ Architecture

BlockchainExchange/
β”œβ”€β”€ smart-contracts/              # Blockchain contracts
β”‚   β”œβ”€β”€ cadence/                  # Flow contracts
β”‚   β”‚   β”œβ”€β”€ GovernanceToken.cdc   # BXEX token
β”‚   β”‚   β”œβ”€β”€ NFTMarketplace.cdc    # NFT trading
β”‚   β”‚   β”œβ”€β”€ CoinExchange.cdc      # Token swaps
β”‚   β”‚   └── LiquidityPool.cdc     # LP management
β”‚   └── flow.json                 # Flow config
β”‚
β”œβ”€β”€ backend/                      # REST API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ services/             # Business logic
β”‚   β”‚   β”œβ”€β”€ controllers/          # API endpoints
β”‚   β”‚   β”œβ”€β”€ routes/               # Route definitions
β”‚   β”‚   └── index.ts              # Entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ frontend/                     # Next.js app
β”‚   β”œβ”€β”€ src/app/
β”‚   β”‚   β”œβ”€β”€ page.tsx              # Home
β”‚   β”‚   β”œβ”€β”€ marketplace/          # NFT marketplace
β”‚   β”‚   β”œβ”€β”€ swap/                 # Token swap
β”‚   β”‚   β”œβ”€β”€ pools/                # Liquidity pools
β”‚   β”‚   └── analytics/            # Dashboard
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ database/                     # PostgreSQL
β”‚   └── init.sql                  # Schema & migrations
β”‚
β”œβ”€β”€ docker-compose.yml            # Local dev environment
β”œβ”€β”€ package.json                  # Monorepo root
β”œβ”€β”€ README.md                     # This file
β”œβ”€β”€ QUICKSTART.md                 # 5-minute setup
β”œβ”€β”€ ARCHITECTURE.md               # System design
└── DEPLOYMENT.md                 # Production guide

πŸš€ Quick Start (5 Minutes)

Prerequisites

  • βœ… Node.js 18+
  • βœ… Docker & Docker Compose
  • βœ… Git

Installation

# 1. Clone repository
git clone https://github.com/Breitjoda/BlockchainExchange.git
cd BlockchainExchange

# 2. Install dependencies
npm install:all

# 3. Setup environment
cp .env.example .env

# 4. Start services
docker-compose up -d

# 5. Start development
npm run dev

Access the Platform

Component URL
Frontend http://localhost:3000
Backend API http://localhost:3001/api/v1/status
NFT Marketplace http://localhost:3000/marketplace
Token Swap http://localhost:3000/swap
Liquidity Pools http://localhost:3000/pools
Analytics http://localhost:3000/analytics

πŸ“Š Key Features

πŸ–ΌοΈ NFT Marketplace

  • Browse active NFT listings
  • Filter by status (active/sold/cancelled)
  • View NFT details and seller info
  • Purchase with instant settlement
  • List your own NFTs
  • 1% trading fee (no listing fee)

πŸ’± Token Swap

  • Real-time price quotes
  • Constant product AMM (x*y=k)
  • 1% transaction fee
  • Price impact calculation
  • Slippage protection
  • Multiple token pairs
  • 24h volume tracking

πŸ’§ Liquidity Pools

  • Deposit token pairs to earn fees
  • Liquidity provider (LP) tokens
  • Real-time APY display
  • Remove liquidity anytime
  • Automatic fee distribution
  • Pool statistics & performance

πŸ“Š Analytics Dashboard

  • 24-hour trading volume
  • 7-day volume history with charts
  • Top traders leaderboard
  • Token price history
  • NFT marketplace statistics
  • Fee collection tracking
  • Portfolio value calculation

πŸ’° Fee Structure

Type Rate Distribution
Trading Fee 1% 0.5% LP + 0.5% Governance
NFT Listing 0% Free
Swap Slippage Variable None

πŸ”’ Smart Contracts

GovernanceToken.cdc

  • Symbol: BXEX
  • Total Supply: 10,000,000
  • Decimals: 8
  • Minting: Admin only
  • Burning: Supported

NFTMarketplace.cdc

  • List Flow NFTs for sale
  • 1% transaction fee collection
  • Automatic settlement
  • Event logging for auditing

CoinExchange.cdc

  • Constant product formula
  • 1% fee mechanism
  • Price quote calculation
  • Slip protection

πŸ› οΈ Tech Stack

Smart Contracts

  • Cadence - Flow blockchain
  • Solidity - EVM chains (future)

Backend

  • Node.js + Express - Server
  • TypeScript - Type safety
  • PostgreSQL - Data persistence
  • Redis - Caching

Frontend

  • Next.js 14 - React framework
  • TypeScript - Type safety
  • Tailwind CSS - Styling
  • Recharts - Data visualization
  • wagmi/ethers - Web3 integration
  • @onflow/fcl - Flow blockchain

Infrastructure

  • Docker - Containerization
  • PostgreSQL - Database
  • Redis - Cache layer

πŸ“š Documentation

Document Purpose
QUICKSTART.md 5-minute setup guide
ARCHITECTURE.md System design & data flow
DEPLOYMENT.md Production deployment
backend/README.md API reference
frontend/README.md Frontend guide
smart-contracts/README.md Smart contract docs

πŸ” Security

  • βœ… Input validation & sanitization
  • βœ… SQL injection prevention
  • βœ… Rate limiting (100 req/min)
  • βœ… CORS protection
  • βœ… JWT authentication ready
  • βœ… Smart contract auditing recommended
  • βœ… Multi-sig wallet support

πŸ“ˆ Performance

  • Response time: <200ms
  • Database connection pooling: 20 connections
  • Redis cache (5 min TTL for prices)
  • Code splitting & lazy loading
  • Image optimization
  • CSS minification

🚒 Deployment

Local Development

docker-compose up -d
npm run dev

Production

# Build
npm run build

# Deploy backend
docker push <registry>/blockchain-exchange:backend

# Deploy frontend
vercel deploy

# Deploy contracts
flow project deploy --network mainnet

See DEPLOYMENT.md for detailed production setup.

πŸ”„ API Endpoints

NFT Marketplace

GET    /api/v1/nft/listings
GET    /api/v1/nft/listings/:id
POST   /api/v1/nft/listings
PUT    /api/v1/nft/listings/:id
DELETE /api/v1/nft/listings/:id
POST   /api/v1/nft/purchase
GET    /api/v1/nft/seller/:address

Token Swap

GET    /api/v1/swap/pairs
GET    /api/v1/swap/pairs/:tokenA/:tokenB
GET    /api/v1/swap/price
POST   /api/v1/swap/execute
GET    /api/v1/swap/history
GET    /api/v1/swap/stats

Analytics

GET    /api/v1/analytics/volume/24h
GET    /api/v1/analytics/volume/history
GET    /api/v1/analytics/top-traders
GET    /api/v1/analytics/price-history
GET    /api/v1/analytics/nft-stats
GET    /api/v1/analytics/portfolio/:address
GET    /api/v1/analytics/fees

πŸ§ͺ Testing

# All tests
npm test

# Specific test
npm test -- nft.controller

# Coverage
npm run test:coverage

# Watch mode
npm run test:watch

πŸ“Š Database Schema

  • users - User accounts & wallets
  • nft_listings - NFT marketplace listings
  • transactions - All blockchain transactions
  • trading_pairs - Liquidity pool pairs
  • swaps - Token swap history
  • liquidity_providers - LP positions
  • portfolio - User asset holdings
  • fee_collection - Fee tracking
  • price_history - Historical prices

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request

πŸ“„ License

MIT License - See LICENSE file

πŸ†˜ Support

πŸ‘€ Author

@Breitjoda

🎯 Roadmap

  • Phase 1: Smart contracts & backend
  • Phase 2: Frontend development
  • Phase 3: Testing & integration
  • Phase 4: Mainnet deployment
  • Phase 5: Cross-chain bridges
  • Phase 6: Advanced features (limit orders, etc.)

Built with ❀️ for the multi-chain future

Join the revolution in decentralized trading! πŸš€

About

Multi-Chain NFT & Coin Exchange with Flow, Ethereum, Polygon Support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors