How to design an NFT marketplace architecture
Dear reader we assume you have already known what a marketplace is. As well as you’ve already heard and understand what an NFT’s is which is a non-fungible (non-interchangeable) token on a blockchain platform that represents value of the item. The record of this NFT item is stored in the memory of blockchain network with help of smart contract.
Therefore, combining these two concepts, let’s determine what kind of NFT marketplaces can be developed nowadays, and then dive deeper into the architecture of marketplaces.
Of course, all levels assume that you have web development skills or your own development team.
1. Beginners level. API is linked to a specific platform:
Using open API and ready-made SDK libraries from major platforms like OpenSea, Rarible, etc., you can create your own visual interface with the NFT catalog for which integration the specific smart contracts as well as backend development are not required.
All you need is:
- Study the documentation of the API, e.g. from OpenSea
- Design your user interface: the design layouts of the screens of creation, display and interaction with the NFT objects
- Develop a frontend application which will use these layouts to access the OpenSea API when creating, displaying and interacting with NFT objects.
Using the OpenSea API methods you won’t need to develop either smart contracts or your own backend.
2. Medium level. White-label solution for ready made NFT marketplace:
This is the best price-quality solution to launch NFT Marketplace on your own smart-contracts and your own backend (API).
For example, you want to add a small feature that popular NFT marketplaces like OpenSea do not have, such as a referral system or some other integration with a third service provider.
Why could it be relevant for you?
1. You do not want to spend a lot of time developing your platform from scratch
2. You have a limited budget
3. You want to adjust the existing platform with a small customization of the design interface.
Take a look at the solution provided by our company, a ready-made NFT-marketplace with fully functioning platform architecture and established cloud infrastructure.
There are three purchasing options
- Minimal UI redesign + deployment into your infrastructure.
- Modifications of business logic, UI redesign and deployment into your infrastructure.
- Modifications, deployment into your infrastructure and our team to monthly maintain the platform.
Besides standard package we offer additional features implementation for NFT collections smart contracts development. The marketplace already has smart contracts with all the basic functionality to create and interact with collections and NFTs.
3. Advanced level. Designing and developing your platform from scratch:
This is the choice for those who want to implement something radically new that hasn’t existed in the IT world before. Who see their platform as special from others, and who have a sufficient budget for development.
Therefore you should approach the creation of such unique solution systematically, designing the structure of the NFT Marketplace at all possible levels:
- UI structure
- The architecture of smart contracts.
- Microservices architecture
- Environment Infrastructure
Now we’re going to share some basic approach that helps us work through this structure.
3.1 User interface
When you are working on it, it will be amazingly helpful for you to describe the following:
- Schematic diagram of the screens
- It shows how to get from one screen to another and to see the bird-view of the whole application
- It’s easy to do with help of the board in Miro.com
- Prototypes of screens with basic elements
- They help the Designer understand what should happen inside each screen
- It is convenient to make them either on the board at Miro or directly in the project at Figma.com
- Design layouts of the screens
- They are created by the Designer, using the previous schema and also some prototypes
- Components are immediately exported to a separate UI-Kit project to be reused on other screens
- It can be immediately done in Figma — today it is the most convenient service for application design layouts.
- Table with a list of application URLs (routes)
- This table is definitely important and helps even before the development of the frontend application:
- to review the entire logic of the user’s movement through the screens;
- to determine the route and the access level for each screen;
- to identify missing screens on prototypes or design layouts
- It is convenient to do it using Google SpreadSheets
- It’s important to work through it in parallel with the previous three tasks (schematic, prototypes, layouts)
3.2 Smart contracts architecture
The most accurate moment to start designing your smart contracts is when you have a top-level schematic of all the screens ready. As well as you have alredy take into consideration all possible scenarios of user interaction with the contracts or platform itself.
When you are designing smart contracts for the NFT Marketplace, ask yourself the following questions:
- What type of collection do I need — Single, Multi, or both?
- Should I let users issue their own collections or should I make one large system collection for them?
- Should I offer users opportunities to list for sell/auction and buy NFTs?
If you answered YES to all the questions, there are three basic sets of smart contracts for the full operation of the NFT Marketplace:
- Contracts of collections (e.g., ERC-721 and ERC-1155 in Ethereum-based networks)
- Contract of custom user collections factory
- Contracts of trading operations on the marketplace
In the case of a typical NFT Marketplace, ordinary NFT collections and Ethereum compatible blockchains, you can take ready-made smart contracts on the ERC-721 and ERC-1155 standards as well as ready-made factory and trade contracts from existing NFT Marketplaces.
But there is one important recommendation, whether you use ready-made contracts or write your own:
You need an experienced smart contracts developer to help design your microservices’ interaction scheme with these contracts, as well as an experienced auditor to check the logic of all methods for validity and security.
3.3 Microservices architecture
Some of you might also raise a question — why exactly do we need to use microservices? This is a common practice in 2022 not to provide a heavy monolithic applications, but to have multiple mini-applications connected to each other. Even if you have an MVP, and it’s just a single frontend application at the start, it’s still useful to plan for it in a future architecture as one of the microservices that can be integrated with some other system component.
In order to understand what components should be in your system architecture, we need to answer the following questions:
We won’t dive into the different options for each service right now, because it still depends on the cloud provider you use, as well as the specific business situation and requirements for your application.
Let’s focus on an abstract representation of how many services should be used in your system. And if you answered YES to all the questions, then you have roughly such a list of microservices:
- frontend-user (scalable, stateless)
- frontend-admin (scalable, stateless)
- backend-api (scalable, stateless)
- backend-cron (statefull)
- backend-indexer (statefull)
- sql/nosql database
- in-memory database
- ipfs node/gateway
Of course, some microservices can be replaced by cloud services from AWS, GCP, Azure, Digital Ocean, etc. rather than deployed inside your servers. And in each specific situation, this can give both pluses and minuses.
An abstract scheme of the NFT marketplace components architecture could look like this:
3.4 Infrastructure and environments
For a minimally working product you will need two environments:
- DEV — for development, interaction with Testnet and initial testing
- PROD — for production users and interaction with Mainnet
Additionally, you can create other intermediate environments, such as STAGE — to demonstrate to investors or to test with first trusted users.
There are some following questions while planning your NFT Marketplace infrastructure development:
- Do I have enough budget for infrastructure costs? At least 500 USD per month (depends on configuration and workload)
- Are reliability and fault tolerance my main criteria?
- Do I need to provide automatic scaling of system resources as user traffic and system load increase?
- Do I need to provide monitoring of system metrics (e.g., CPU/RAM/NET/Storage) on a dedicated dashboard and notifications of critical performance changes?
We can recommend completely different infrastructure configurations, depending on your needs.
If you answered YES to all these questions, then your best option might be an auto scalable cluster on Kubernetes using cloud services from AWS.
This cluster should have multiple servers from different data centres, between which the cluster orchestrator distributes copies of your applications containers. Supporting services such as Prometheus and Graphana for monitoring and alerting are also will be required.
An approximate scheme for allocating NFT marketplace infrastructure components in an AWS cloud provider looks like this:
But if you are looking for more economical solution and you don’t need fault tolerance or scalability function for the MVP testing period, then you can easily deploy all the microservices in docker containers on a regular Docker Swarm in a static virtual server on Hetzner or Digital Ocean.
The architecture of the NFT Marketplace can be either simple or complex, and it depends on:
- Complexity of your idea
- Fault tolerance and scalability requirements
- Development budget
- Experience of your development team
If you have a cool idea with NFT Marketplace, but not enough of experience in development, we recommend two options:
- Try releasing a small MVP on beginning level architecture with a binding to the API of the existing Marketplace or an NFT aggregator
- You can also ask for help from a team of professionals with a good experience in development of NFT Marketplaces