Lootex Core is a high-performance NFT marketplace infrastructure managed with a Monorepo architecture. This project includes a modern frontend based on Next.js and a robust backend API based on NestJS, integrated with blockchain event monitoring and NFT data indexing capabilities.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Quick Start
- Configuration
- Database Management
- Common Commands
The system primarily provides the following core features:
-
NFT Marketplace Protocol
- Integrated with Seaport protocol for secure and efficient NFT trading.
- Supports Aggregator architecture.
-
Multi-Chain / Single-Chain Support
- Configurable target blockchain via environment variables (e.g., Soneium).
- Supports custom RPC nodes and block explorer integration.
-
Real-time Data Indexing (Indexer & Poller)
- Event Poller: Listens to on-chain events to sync NFT transfers and transaction records in real-time.
- Metadata Sync: Integrated with Alchemy and Moralis APIs to automatically update NFT metadata.
-
Account & Authentication System
- Supports Web3 wallet login and JWT authentication.
- Complete User Profile and asset management APIs.
- Turborepo: High-performance build system and task scheduling.
- pnpm: Fast and disk-efficient package manager.
- Framework: Next.js (React)
- Language: TypeScript
- Styling: Tailwind CSS
- Linting: Biome / ESLint
- Framework: NestJS
- Language: TypeScript
- Database: PostgreSQL
- Caching: Redis
- Message Queue: AWS SQS (for asset sync and event processing)
- Blockchain Interaction: Viem / Wagmi
- Database Migration: Goose
- Containerization: Docker & Docker Compose
lootex-core/
├── apps/
│ ├── client/ # Next.js Frontend Application
│ └── server/ # NestJS Backend Application (API, Poller, Worker)
├── db/
│ └── migrations/ # SQL Migration Files
├── packages/ # Shared Packages (UI Kit, Utilities, Configs)
├── docker-compose.yml # Local Development Environment (Postgres, Redis, etc.)
├── package.json # Root Dependencies and Scripts
└── turbo.json # Turborepo Configuration
Before starting, ensuring you have the following tools installed:
- Node.js: >= 18.0.0
- pnpm: 9.0.0 (Recommended to enable via Corepack:
corepack enable) - Docker & Docker Compose: For running local database and cache services.
- Goose: Database migration tool (binary installation required).
pnpm installCreate .env based on the backend example configuration:
cp apps/server/configs/.env.example apps/server/configs/.envCHAIN_RPC_URL_MAIN: Blockchain RPC node URL.ALCHEMY_API_KEY/MORAILS_API_KEY: Third-party data service keys.POSTGRES_*: Database connection info (no change needed if using default Docker config).
After .env is configured, start everything via Docker Compose (Postgres, Redis, migrations, backend, frontend):
docker compose up- Frontend: http://localhost:3000
- Backend API: http://localhost:2999 (depends on config)
Main configuration is located in apps/server/configs/.env. Key configurations:
| Category | Key Variables | Description |
|---|---|---|
| Ports | PORT, QUEUE_PORT |
Ports for API and Worker services |
| Database | POSTGRES_HOST, POSTGRES_DATABASE |
PostgreSQL connection settings |
| Blockchain | CHAIN_ID, CHAIN_RPC_URL_MAIN |
Target Chain ID and RPC Node |
| Contracts | CHAIN_SEAPORT_ADDRESS |
Seaport protocol contract address |
| 3rd Party | ALCHEMY_API_KEY |
Alchemy API Key (for on-chain data) |
| AWS SQS | AWS_SQS_* |
Queue URLs if SQS is enabled |
When you need to migrate the platform to a new blockchain (e.g., from Soneium to another chain), please follow these best practice steps:
Update the following critical information in apps/server/configs/.env:
CHAIN_ID: The ID of the new chain.CHAIN_NAME/CHAIN_SHORT_NAME: Identifiers.CHAIN_RPC_URL_MAIN: RPC node(s) for the new chain (supports comma-separated values).CHAIN_SEAPORT_ADDRESS: Seaport protocol contract address on the new chain.CHAIN_AGGREGATOR_ADDRESS: Lootex Aggregator contract address on the new chain.
Ensure the address parsing logic in apps/server/src/common/utils/chain.config.ts matches the requirements of the new chain.
Update default data in apps/server/src/model/seeders:
- Blockchain: Update the new chain's name, ID, and explorer URL.
- Currency: Update the supported native tokens (e.g., ETH, WETH, USDC) and their corresponding addresses for the new chain.
If the contract versions on the new chain have changed, replace the corresponding ABI files in:
packages/sdk/src/[module]/abi.ts(e.g.,seaport,drop,swapmodules).
This project uses goose for version-controlled database migrations.
- Create New Migration:
goose -dir db/migrations create [migration_name] sql
- Run Migrations (Up): Refer to the command in "Quick Start".
- Rollback Migration (Down):
goose -dir db/migrations postgres "postgres://lootex:lootexpassword@localhost:5432/dex-mainnet?sslmode=disable" down
| Command | Description |
|---|---|
pnpm dev |
Start full-stack dev environment (Client + Server) |
pnpm build |
Build all projects |
pnpm lint |
Run code linting |
pnpm format |
Format code with Prettier |
pnpm check-types |
Run TypeScript type checking |
knip |
Check for unused files and dependencies |
Created by Lootex Team