Back to Projects

Primsell NFT E-Commerce

Web3 NFT Campaign Platform with 7-Service Monorepo

Overview

Architected 7-service monorepo with Express.js + NestJS backends, Awilix DI container, and event-driven workflow engine using EventEmitter2. 11 background daemons handle async processing — order expiration, OpenSea/Rarible secondary sales parsing, smart contract deployment, and POAP distribution. Stripe webhooks with Binance API currency conversion.

Key Features

  • 7-service monorepo with Awilix DI container — 19 controllers, 27+ services, 24 Sequelize models
  • Event-driven workflow engine: OrderWorkflow, ContractWorkflow, RewardDistributionWorkflow state machines
  • 11 background daemons with 60-second execution locks, structured error logging, and Sentry alerts
  • Stripe payment integration with webhooks, payment intents, and Binance API currency conversion
  • OpenSea/Rarible secondary sales parsing for real-time royalty calculations
  • Redis caching with ioredis + Cache Manager abstraction

Tech Stack

Backend

Express.jsNestJSSequelizeMikroORMPostgreSQLRedisTypeScript

Blockchain

ethers.jswagmiWeb3ModalAlchemy SDKIPFSPolygon/Ethereum

Infra

DockerAWS S3AWS X-RaySentryAwilix DI

Frontend

React 18Redux ToolkitTanStack QueryMaterial UIStyled Components

Challenges & Solutions

Event-Driven Workflow Engine

Problem

Complex business processes — order lifecycle, contract deployment, reward distribution — required reliable state machine orchestration across 7 services without data loss.

Solution

Built custom workflow engine using EventEmitter2 with PostgreSQL-backed state machines. Abstract base classes (AbstractService, AbstractDaemon, AbstractSubscriber) standardized the pattern. 11 daemons handle async processing with 60-second execution locks and Sentry alerting.

Multi-Marketplace Royalty Tracking

Problem

NFT secondary sales happen across OpenSea and Rarible with different APIs and data formats — need real-time royalty calculations and automatic reward distribution.

Solution

Background daemons poll marketplace APIs, normalize sale data, calculate creator royalties in basis points, and trigger automated reward distribution via smart contract calls. Structured error logging to DB with auto-cleanup of old records.

Monorepo State Management

Problem

4 React frontends needed consistent data handling while serving different user journeys — admin dashboard, checkout, QR redemption, and KYC verification.

Solution

Redux Toolkit for UI state (modals, filters) + React Query for server state (API caching, background sync). Shared component layer as git submodule ensured consistent MUI-based UI. Redux-Saga handled complex async flows like payment confirmation chains.

Key Achievements

7 Services
Monorepo architecture with Awilix DI container
11 Daemons
Background processors with execution locks and Sentry alerts
EventEmitter2
State machine workflows for orders, contracts, rewards
Stripe + Web3
Payment intents + blockchain royalty distribution