Skip to content
/ Devra Public

Devra is a decentralized marketplace that lets data owners securely encrypt, verify (AI), mint, and sell high-quality datasets as NFTs, buyers purchase access on-chain powered by Polkadot's Asset Hub.

Notifications You must be signed in to change notification settings

Nebulaz7/Devra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Devra - Decentralized Data Marketplace

Devra Banner Next.js Solidity NestJS

A trustless, AI-verified marketplace for trading datasets as NFTs on Polkadot's Westend Asset Hub

πŸ“‹ Table of Contents

🌟 Overview

Devra revolutionizes data trading by combining blockchain technology, AI verification, and decentralized storage to create a transparent marketplace where:

  • Datasets are NFTs: Immutable ownership proof on Polkadot
  • AI Quality Assurance: Automated verification before minting
  • Encrypted Storage: IPFS-based decentralized storage with encryption
  • Trustless Trading: Smart contract-powered peer-to-peer transactions
  • Fair Pricing: Dynamic marketplace with transparent price discovery

Key Features

✨ NFT-Based Ownership - Every dataset is an ERC-721 token
πŸ€– AI Verification - Quality scoring and authenticity checks
πŸ”’ End-to-End Encryption - RSA encryption before IPFS upload
πŸ’Ž Integrated Marketplace - List, buy, and cancel listings on-chain
πŸ“Š Multi-Format Support - CSV, JSON, ZIP, Parquet, Excel
🎨 Modern UI/UX - Cyberpunk-inspired, responsive design

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend (Next.js)                    β”‚
β”‚  β€’ React 19 + Server Components                             β”‚
β”‚  β€’ Wagmi v2 + Viem (Web3)                                   β”‚
β”‚  β€’ Framer Motion (Animations)                               β”‚
β”‚  β€’ Tailwind CSS v4                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β”‚ RPC Calls (Viem)
                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Smart Contract (Solidity 0.8.28)               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  DatasetNFT.sol                                      β”‚   β”‚
β”‚  β”‚  β€’ ERC-721 Implementation                            β”‚   β”‚
β”‚  β”‚  β€’ mint(cid, score)                                  β”‚   β”‚
β”‚  β”‚  β€’ list(tokenId, price)                              β”‚   β”‚
β”‚  β”‚  β€’ buy(tokenId)                                      β”‚   β”‚
β”‚  β”‚  β€’ cancelListing(tokenId)                            β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                  Deployed on Westend Asset Hub              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β”‚ Events & Queries
                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Backend (NestJS + Python)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚  NestJS API Server  β”‚       β”‚  AI Verifier (FastAPI)β”‚     β”‚
β”‚  β”‚  β€’ Upload Handler   │◄─────►│  β€’ Quality Analysis  β”‚      β”‚
β”‚  β”‚  β€’ Encryption Svc   β”‚       β”‚  β€’ Fraud Detection   β”‚      β”‚
β”‚  β”‚  β€’ IPFS Integration β”‚       β”‚  β€’ Scoring Engine    β”‚      β”‚
β”‚  β”‚  β€’ BullMQ Jobs      β”‚       β”‚  β€’ ML Models         β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚             β”‚                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚   PostgreSQL        β”‚       β”‚   Redis (BullMQ)    β”‚      β”‚
β”‚  β”‚   (Prisma ORM)      β”‚       β”‚   (Job Queue)       β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β”‚ Upload Encrypted Data
                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     IPFS (Decentralized Storage)             β”‚
β”‚  β€’ Content-Addressed Storage (CIDs)                         β”‚
β”‚  β€’ Encrypted Dataset Files                                  β”‚
β”‚  β€’ Metadata & Verification Reports                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. Upload Flow

    User β†’ Frontend β†’ Backend β†’ AI Verifier β†’ Encryption β†’ IPFS β†’ Get CID
                                                                     ↓
    User ← Frontend ← Smart Contract ← Mint NFT ← Return CID β†β”€β”€β”€β”€β”€β”˜
    
  2. Purchase Flow

    Buyer β†’ Frontend β†’ Smart Contract.buy() β†’ Transfer Funds β†’ Transfer NFT
                           ↓
    Buyer ← IPFS ← Decrypt ← Access Grant ← Event Listener
    
  3. Listing Flow

    Owner β†’ Frontend β†’ Smart Contract.list() β†’ Set Price β†’ Emit ListingCreated
    

πŸ› οΈ Tech Stack

Frontend

Technology Version Purpose
Next.js 15.5.5 React framework with App Router
React 19.1.0 UI library with Server Components
TypeScript 5.x Type-safe development
Tailwind CSS 4.0 Utility-first styling
Wagmi 2.19.2 React hooks for Ethereum
Viem 2.38.6 TypeScript Ethereum library
Framer Motion 12.23.24 Animation library
TanStack Query 5.90.7 Data fetching & caching
Lucide React 0.545.0 Icon library

Backend (NestJS)

Technology Version Purpose
NestJS 11.0.1 Node.js framework
Prisma 6.17.1 ORM for PostgreSQL
BullMQ 5.61.0 Job queue with Redis
PostgreSQL 8.x Relational database
Redis IORedis 5.8.1 In-memory cache & queue
Axios 1.12.2 HTTP client

AI Verification (Python)

Technology Version Purpose
FastAPI Latest High-performance API framework
PyTorch Latest Deep learning framework
Transformers Latest NLP models (BERT, DistilBERT)
Sentence-Transformers Latest Semantic similarity
Pandas Latest Data analysis
Scikit-learn Latest ML utilities
Pillow Latest Image processing

Blockchain

Technology Version Purpose
Solidity 0.8.28 Smart contract language
Polkadot Asset Hub EVM-compatible blockchain
IPFS HTTP Client Decentralized storage
Ethers.js 6.15.0 Ethereum library (scripts)

πŸ“ Project Structure

Devra/
β”œβ”€β”€ devra-frontend/           # Next.js 15 Frontend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Hero.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   └── About.tsx
β”‚   β”‚   β”œβ”€β”€ animations/       # Framer Motion animations
β”‚   β”‚   β”œβ”€β”€ connect/          # Wallet connection page
β”‚   β”‚   β”œβ”€β”€ marketplace/      # Dataset marketplace
β”‚   β”‚   β”œβ”€β”€ datasets/         # User datasets management
β”‚   β”‚   β”œβ”€β”€ dashboard/        # User dashboard
β”‚   β”‚   └── providers.tsx     # Wagmi & React Query setup
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ wagmi.ts          # Web3 configuration
β”‚   β”‚   └── contracts/        # Contract interaction hooks
β”‚   β”‚       β”œβ”€β”€ useDataset.ts # NFT contract hooks
β”‚   β”‚       └── DatasetNFT.ts # Contract ABI & config
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ useWallet.ts      # Wallet connection hook
β”‚   β”‚   └── useContract.ts    # Generic contract hook
β”‚   └── package.json
β”‚
β”œβ”€β”€ devra-backend/            # NestJS Backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”‚   β”œβ”€β”€ upload/       # File upload handling
β”‚   β”‚   β”‚   β”œβ”€β”€ encryption/   # RSA encryption service
β”‚   β”‚   β”‚   β”œβ”€β”€ verification/ # AI verification integration
β”‚   β”‚   β”‚   β”œβ”€β”€ crust/        # IPFS/Crust integration
β”‚   β”‚   β”‚   └── prisma/       # Database service
β”‚   β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”‚   └── config/       # Redis & Vault config
β”‚   β”‚   └── main.ts
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   └── schema.prisma     # Database schema
β”‚   └── package.json
β”‚
β”œβ”€β”€ devra-ai_verifier/        # Python AI Service
β”‚   β”œβ”€β”€ main.py               # FastAPI application
β”‚   β”œβ”€β”€ requirements.txt      # Python dependencies
β”‚   └── Procfile              # Deployment config
β”‚
β”œβ”€β”€ devra-contracts/          # Solidity Smart Contracts
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   └── DatasetNFT.sol    # Main NFT contract
β”‚   β”œβ”€β”€ scripts/              # Deployment scripts
β”‚   β”‚   β”œβ”€β”€ deploy_with_ethers.ts
β”‚   β”‚   └── deploy_with_web3.ts
β”‚   └── tests/                # Contract tests
β”‚
└── README.md                 # This file

πŸš€ Getting Started

Prerequisites

  • Node.js 20.x or higher
  • npm or yarn
  • Python 3.10+
  • PostgreSQL 14+
  • Redis 7+
  • MetaMask or Talisman wallet

Installation

1. Clone the Repository

git clone https://github.com/Nebulaz7/Devra.git
cd Devra

2. Frontend Setup

cd devra-frontend
npm install
cp .env.example .env.local
# Configure your environment variables
npm run dev
# Open http://localhost:3000

Environment Variables (.env.local)

NEXT_PUBLIC_CONTRACT_ADDRESS=0x25e485fc5492ce1c65cfd438de6d64eb62335cd7
NEXT_PUBLIC_CHAIN_ID=420420421
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000

3. Backend Setup

cd devra-backend
npm install
cp .env.example .env
# Configure database and Redis
npx prisma migrate dev
npm run start:dev
# Backend runs on http://localhost:3000

Environment Variables (.env)

DATABASE_URL="postgresql://user:password@localhost:5432/devra"
REDIS_HOST=localhost
REDIS_PORT=6379
AI_VERIFIER_URL=http://localhost:5000/
IPFS_GATEWAY=https://ipfs.io

4. AI Verifier Setup

cd devra-ai_verifier
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload --port 5000
# AI service runs on http://localhost:5000/

5. Database Migration

cd devra-backend
npx prisma migrate dev --name init
npx prisma generate

πŸ“œ Smart Contracts

DatasetNFT.sol

Deployed Address: 0x25e485fc5492ce1c65cfd438de6d64eb62335cd7
Network: Westend Asset Hub (Chain ID: 420420421)
Explorer: Blockscout

Core Functions

// Mint a new dataset NFT
function mint(bytes32 cid, uint8 score) external returns (uint256)

// List dataset for sale
function list(uint256 tokenId, uint96 price) external

// Purchase a listed dataset
function buy(uint256 tokenId) external payable

// Cancel listing
function cancelListing(uint256 tokenId) external

// Get dataset info
function datasetInfo(uint256 tokenId) external view returns (Data memory)

Events

event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
event ListingCreated(uint256 indexed tokenId, uint96 price)
event ListingCancelled(uint256 indexed tokenId)
event Sold(uint256 indexed tokenId, address indexed buyer, uint96 price)

Deployment

cd devra-contracts
npm install
# Deploy using Remix IDE or:
npx hardhat run scripts/deploy_with_ethers.ts --network westend

πŸ”§ Backend Services

Upload Service

Handles multipart file uploads with validation.

@Post('upload')
@UseInterceptors(FileInterceptor('file'))
async uploadDataset(
  @UploadedFile() file: Express.Multer.File,
  @Body() dto: CreateDatasetDto
) {
  // 1. Validate file
  // 2. Send to AI verifier
  // 3. Encrypt file
  // 4. Upload to IPFS
  // 5. Return CID
}

Encryption Service

RSA-based encryption for dataset security.

async encryptFile(buffer: Buffer, publicKey: string): Promise<Buffer> {
  // AES-256-GCM encryption with RSA-wrapped keys
}

Queue Service (BullMQ)

Background job processing for uploads.

@Process('upload-dataset')
async processUpload(job: Job) {
  // 1. Verify with AI
  // 2. Encrypt data
  // 3. Upload to IPFS
  // 4. Update database
}

🎨 Frontend Application

Wallet Integration

// lib/wagmi.ts
import { createConfig, http } from "wagmi";
import { westendAssetHub } from "./chains";
import { metaMask } from "@wagmi/connectors";

export const config = createConfig({
  chains: [westendAssetHub],
  connectors: [metaMask()],
  transports: {
    [westendAssetHub.id]: http(),
  },
});

Contract Interaction Hooks

// lib/contracts/useDataset.ts
export function useMintDataset() {
  const { writeContractAsync } = useWriteContract();

  const mint = async (cid: string) => {
    const hash = await writeContractAsync({
      address: CONTRACT_ADDRESS,
      abi: DatasetNFTABI,
      functionName: "mint",
      args: [cid, 85], // CID and quality score
    });
    return hash;
  };

  return { mint };
}

Components

  • Hero.tsx - Landing page hero section with 3D animations
  • Navbar.tsx - Navigation with wallet connection
  • Marketplace.tsx - Dataset browsing and purchasing
  • Datasets.tsx - User's owned datasets management
  • MintDatasetModal.tsx - Multi-step minting workflow

πŸ€– AI Verification

Verification Pipeline

@app.post("/verify")
async def verify_dataset(file: UploadFile):
    # 1. Extract and parse data
    data = extract_data(file)

    # 2. Quality metrics
    completeness = calculate_completeness(data)
    consistency = check_consistency(data)

    # 3. Fraud detection
    duplicates = detect_duplicates(data)
    anomalies = find_anomalies(data)

    # 4. AI scoring
    score = ml_quality_score(data)

    return {
        "score": score,
        "quality_metrics": {...},
        "fraud_indicators": {...}
    }

Supported Models

  • BERT - Text quality analysis
  • DistilBERT - Fast text classification
  • ResNet18 - Image dataset verification
  • Sentence-BERT - Semantic similarity

🌐 Deployment

Frontend (Vercel)

cd devra-frontend
vercel deploy --prod

Build Configuration:

{
  "buildCommand": "npm run build",
  "outputDirectory": ".next",
  "framework": "nextjs"
}

Backend (Railway/Heroku)

cd devra-backend
# Set environment variables
railway up

AI Verifier (Render)

# render.yaml
services:
  - type: web
    name: devra-ai-verifier
    env: python
    buildCommand: pip install -r requirements.txt
    startCommand: uvicorn main:app --host 0.0.0.0 --port $PORT

Database (PostgreSQL)

Use managed services:

  • Supabase (Recommended)
  • Railway
  • Render

πŸ§ͺ Testing

Frontend Tests

cd devra-frontend
npm run test

Backend Tests

cd devra-backend
npm run test
npm run test:e2e

Contract Tests

cd devra-contracts
npm run test

🀝 Contributing

We welcome contributions! Please follow these steps:

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

Code Style

  • Frontend: ESLint + Prettier
  • Backend: NestJS style guide
  • Contracts: Solidity style guide

πŸ”— Links

Built with ❀️ by the Devra Team
Making data trading fair, transparent, and decentralized

About

Devra is a decentralized marketplace that lets data owners securely encrypt, verify (AI), mint, and sell high-quality datasets as NFTs, buyers purchase access on-chain powered by Polkadot's Asset Hub.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •