Skip to content

Repository files navigation

TheDataBay

CIReleaseTagLicenseIssuesPull RequestsContributorsRepo Size

Decentralized dataset marketplace with encrypted dataset delivery, on-chain listing/payment, and semantic discovery.

📚 Table of Contents

🔭 Overview

TheDataBay includes:

  • client/: React + Vite frontend
  • mobile/: Expo React Native app (wallet, search, upload, purchases)
  • api/: FastAPI backend (LLM jobs, key release, contract reads)
  • evm/: Foundry smart contracts/scripts/tests
  • infra/development/: Kubernetes manifests and Dockerfiles used in local dev

🧩 Tech Stack

LayerStackPaths
Web appReact, TypeScript, Vite, Zustand, Ethers.jsclient/
Mobile appExpo, React Native, Expo Router, Zustand, Reown AppKit, Ethers.jsmobile/
Backend APIFastAPI, SQLModel, Pydantic, pytestapi/
Smart contractsSolidity, Foundry (forge/anvil/cast), OpenZeppelinevm/
Dev infraDocker, Kubernetes (Minikube), Tiltinfra/development/, tiltfile

🧱 Architecture

  • Listings are stored and read from Marketplace contract.
  • Dataset payloads are encrypted before IPFS upload.
  • Signature files remain unencrypted.
  • Buyers obtain decryption keys via backend key release endpoint, gated by on-chain hasAccess.
  • Similarity search runs via /api/v1/ai/similarity-search and ranks on marketplace signature vectors.

✅ Prerequisites

  • Node.js 20.x (recommended for Vite/esbuild stability)
  • Python 3.11+
  • Foundry (forge, cast, anvil)
  • Docker
  • Minikube + kubectl
  • Tilt

🚀 Quick Start

1) Start local chain and deploy contract

make anvil
# in another terminal
make deploy-anvil
make seed-anvil

make anvil listens on 0.0.0.0:8545 by default so Tilt/Kubernetes backend pods can reach the host node. For a purely host-local chain, run ANVIL_HOST=127.0.0.1 make anvil.

2) Run backend

cd api
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8080

3) Run frontend

cd client
npm install
npm run dev

Copy .env.example.env at the repo root and fill in the values before starting the dev server.

4) Run mobile app

cd mobile
npm install
npm run start

🛠️ Command Catalog

🖥️ Frontend (client/)

CommandWhat it does
npm run devStart Vite dev server
npm run buildType-check and production build
npm run lintRun ESLint
npm run previewServe built app locally

⚙️ Backend (api/)

CommandWhat it does
fastapi devRun API locally with reload
pytestRun all tests except integration (default)
pytest tests/unit -qRun unit tests only (no Docker required)
pytest -m integration -qRun integration tests (requires Docker)
pytest -k "test_name" -qRun a single test by name

📱 Mobile (mobile/)

CommandWhat it does
npm run startStart Expo dev server
npm run iosLaunch iOS target
npm run androidLaunch Android target
npm run webLaunch web target
npm run lintRun Expo/ESLint checks
npm run testRun mobile Jest tests

⛓️ EVM / Foundry (evm/)

CommandWhat it does
make evm-buildCompile contracts, export ABI to api/app/contracts/
make evm-testRun Solidity test suite
make anvilStart local Anvil node on 0.0.0.0:8545
make deploy-anvilDeploy Marketplace to local Anvil
make seed-anvilSeed deterministic demo listings on-chain
make mint-tokens-anvilMint MockUSDC + MockCADC on Anvil
make mint-tokens-base-sepoliaMint MockUSDC + MockCADC on Base Sepolia

🐳 Docker

CommandWhat it does
docker build -f infra/development/docker/client.Dockerfile -t thedatabay/client .Build frontend image
docker build -f infra/development/docker/server.Dockerfile -t thedatabay/server .Build backend image
docker images | grep thedatabayVerify built images

☸️ Minikube / Kubernetes / Tilt

CommandWhat it does
minikube startStart local Kubernetes cluster
minikube statusCheck cluster health
tilt upBuild and deploy local development stack
tilt downStop Tilt session
kubectl get pods -AInspect all pods
kubectl get svc -AInspect services
kubectl logs deployment/api -n defaultView server logs
kubectl logs deployment/client -n defaultView client logs
kubectl logs statefulset/postgres -n defaultView postgres logs
kubectl port-forward svc/api-svc 8080:8080Expose backend locally
kubectl port-forward svc/client-svc 5173:5173Expose frontend locally

🔌 API Endpoints

Health

MethodEndpointPurpose
GET/health/Basic service health
GET/health/readyReadiness/dependency status

LLM / Jobs

MethodEndpointPurpose
POST/api/v1/llm/embed/batchUpload CSV, enqueue embedding/encryption job
GET/api/v1/llm/jobs/{job_id}Poll job status
POST/api/v1/llm/embed/queryQuery embedding generation

Similarity Search

MethodEndpointPurpose
POST/api/v1/ai/similarity-searchSemantic ranking of marketplace datasets

Datasets / Key Release

MethodEndpointPurpose
POST/api/v1/datasets/{listing_id}/keyRelease AES key/nonce if wallet has on-chain access

Contract Read/Utility

MethodEndpointPurpose
GET/api/v1/contract/items/allGet all listings
GET/api/v1/contract/items/{listing_id}Get single listing
POST/api/v1/contract/access/{listing_id}/checkCheck wallet access
GET/api/v1/contract/fee-bpsCurrent marketplace fee
GET/api/v1/contract/ownerContract owner

Contract Write/Admin (server-signed where enabled)

MethodEndpointPurpose
PATCH/api/v1/contract/items/{listing_id}/dataset-urlUpdate dataset URL
PATCH/api/v1/contract/items/{listing_id}/signatureUpdate signature URL/hash
PATCH/api/v1/contract/items/{listing_id}/priceUpdate listing price
PATCH/api/v1/contract/fee-configUpdate fee recipient/bps
POST/api/v1/contract/items/{listing_id}/grant-accessGrant access for walletId

🌱 Seed On-Chain Test Data

Use this flow to populate Home/Detail pages with real on-chain listings.

make anvil
# new terminal
make deploy-anvil
make seed-anvil

make seed-anvil uses evm/script/SeedMarketplace.s.sol and creates deterministic UUID-compatible bytes32 item IDs so frontend route + backend UUID conversion remain consistent.

make deploy-anvil also syncs the deployed marketplace address into infra/k8s/development/secrets.yaml and the root .env.

For Tilt/Kubernetes, set infra/k8s/development/secrets.yamlRPC_URL to a host-reachable URL such as http://host.docker.internal:8545. Use http://127.0.0.1:8545 only when the backend process itself runs directly on the host.

🧰 Troubleshooting

MetaMask connected but create/buy fails

  • Verify MetaMask network is your anvil chain (31337 by default).
  • Verify selected account matches expected seller flow for createItem.
  • Verify VITE_CONTRACT_ADDRESS points to deployed contract on the same chain.
  • Verify VITE_USDC_TOKEN_ADDRESS points to the accepted USDC token for that deployment.

Error: no contract code found at configured address

  • Address is wrong for the active chain or deployment changed.
  • Re-run make deploy-anvil so local config files are refreshed with the new address.

getAllItems() reverts in the backend but make getall works

  • Check that the backend is calling the same deployed address saved in evm/deployments/anvil_marketplace.addr.
  • If you redeployed Anvil, re-run make deploy-anvil to sync infra/k8s/development/secrets.yaml and the root .env.
  • Restart the server resource after the config update so the new CONTRACT_ADDRESS is loaded.

Error: RPC node unreachable

  • Verify Anvil is running with make anvil. The default target binds to 0.0.0.0:8545 so containers can reach it.
  • If the backend runs in Tilt/Kubernetes, set infra/k8s/development/secrets.yamlRPC_URL to http://host.docker.internal:8545, then restart the server resource so the secret is reloaded.
  • If the backend runs directly on your host with uvicorn, RPC_URL=http://127.0.0.1:8545 is correct.

Marketplace__ItemDoesNotExist(bytes32)

  • Listing is being queried before on-chain creation.
  • Confirm create transaction is mined, then refresh item view.
  • Use make getall to verify listing presence.

Similarity search returns no results

  • Signature files may be missing/unavailable or below threshold.
  • Validate signature_url/signature_hash for listed items.
  • Try broader query terms.

About

Decentralized dataset marketplace with encrypted dataset delivery, on-chain listing/payment, and semantic discovery.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages