Microservices Architecture
1.1 Overview
1.2 Structure of Microservices
The CapsureLabs microservices architecture is divided into several key services, each organized by function:
Manages user data, authentication, and access control.
Handles NFT creation, metadata management, and integration with blockchain for minting and trading.
Provides analytical tools, trading bots, arbitrage scanning, and yield optimization for investors.
Supports NFT creation, virtual galleries, and IP protection tools for artists.
Offers toolkits, debugging tools, and gas fee optimizers for Web3 developers.
Manages decentralized governance, voting, and community incentive structures.
Sends user alerts, event notifications, and system messages for various events across the platform.
Each of these services is deployed independently and communicates with other services using secure, well-defined interfaces. The microservices structure is designed to support horizontal scaling, meaning each service can scale independently based on demand.
1.3 Service Communication
Communication between services is handled through two primary mechanisms:
REST is used for standard HTTP communication, providing simple and scalable communication between internal services.
For performance-sensitive interactions, such as real-time data exchanges (e.g., trading bot updates or asset tracking), gRPC is employed due to its efficient protocol and binary format, which reduces latency.
REST API Communication
A common scenario involves the User Service interacting with the NFT Service to fetch a user’s NFT assets. Here’s an example configuration for a REST API-based communication:
User Service Code for Fetching NFTs
gRPC Communication
For high-performance communication, CapsureLabs uses gRPC. In this example, the Trading Service sends real-time market data to the Analytics Service using gRPC.
Trading Service Code for Sending Market Data via gRPC
Define gRPC Protocol (market.proto)
market.proto)Trading Service Client Implementation
In this example, Trading Service sends market data to the Analytics Service via gRPC, providing a low-latency communication path for real-time updates.
1.4 Service Discovery and Load Balancing
To ensure that services can dynamically locate and communicate with each other, CapsureLabs employs a service discovery mechanism. This mechanism uses a registry where services register themselves upon startup, and other services can query this registry to locate the necessary endpoints. This registry enables load balancing and supports scaling up instances of high-demand services.
For service discovery and health checks.
NGINX or AWS Elastic Load Balancer (ELB) routes requests to appropriate service instances.
1.5 Data Management and Persistence
Each microservice is responsible for managing its own data and database. This design follows the database-per-service pattern, which isolates each service’s data to reduce dependencies. For shared data, each service either directly queries or requests access from the data-owning service.
1.6 Error Handling and Resilience
To ensure that the system remains stable, CapsureLabs implements
Circuit breaker patterns prevent cascading failures by monitoring service health and disabling calls to failing services.
Network calls include retries with exponential backoff and timeouts to prevent long wait times.
Logs from each service are centrally collected to facilitate monitoring and troubleshooting.
Last updated
