Page cover

Architecture

in development

Frontend Layer (Web & Mobile)

Web application (runs in the browser) acts as a secure digital wallet and handles all client side secrets, credentials and cryptography. It's currently based on the T3 (Typescript/Tailwind CSS/tRPC)arrow-up-right tech stack and is delivered through Google owned CDN (Firebase Hostingarrow-up-right).

It uses DIDarrow-up-right provided by the Ceramic Key DID libraryarrow-up-right to pass the vSelf Dapp authorization, Wallet Selectorarrow-up-right for NEARarrow-up-right authorization and integration with NEAR contacts, MetaMaskarrow-up-right with WalletConnectarrow-up-right SDK for authorization in the EVM-compatible chains, including Caminoarrow-up-right Blockchain. Also we use near-api-jsarrow-up-right and caminojsarrow-up-right to interact with supported chains.

We integrate Magic.link arrow-up-rightto provide Web3 onboarding without a seed phrase and authentication through an authorization token. And also, we integrate Keypomarrow-up-right to support claiming new NEAR accounts on the fly.

Mobile application is developed in Unityarrow-up-right and obtained through Google Play herearrow-up-right and App Store herearrow-up-right. It uses Unity NEAR SDKarrow-up-right (currently in development) to pass the authentication. Mobile application sends authenticated requests to API services and communicates with web applications using web socketsarrow-up-right.

Web application is developed using Next.jsarrow-up-right framework and hosted using Firebasearrow-up-right. NEAR-compatible production version is available herearrow-up-right and development version - herearrow-up-right. Camino-compatible staging version is available herearrow-up-right and supports Columbus testnetarrow-up-right.

All frontend applications use vSelf API for data fetching, session management and for interacting with other vSelf subsystems.

Cloud Layer (API)

As we use Next.jsarrow-up-right framework it allows us to implement server side logic in Typescriptarrow-up-right and use it for typesafe endpoints implementation. The cloud based backend can be decoupled in two logical layers. The first part consists of the services directly interacting with user applications, and the other one runs in the cloud and doesn't affect UX directly.

The main vSelf API service serves as a bridge between frontend applications and backend services. It communicates with vSelf databases, smart contracts and any 3rd party APIs which are required. Also it implements authentication and authorization mechanisms (with next-autharrow-up-right) for access control and identity management.

We plan to use Firebase and Google Cloudarrow-up-right to host and deploy our dockerizedarrow-up-right services for a long time, but to avoid any vendor lock, we will be migrating to Kubernetesarrow-up-right.

Storage Layer (Database, Storage)

We use hybrid data storage solution for different types of the user personal data.

Social DBarrow-up-right is used as an on-chain data storage for public profiles. Public profile data can contain public identity or sub identity information, and user is able to choose witch information she wants to share. Social DB usage requires the NEAR ID, and we provide a smooth on-boarding process for all the users without NEAR wallet.

For access data storage we chose to go with GunDBarrow-up-right distributed graph database in the user side. We store there the identity tree and keypairs for different supported chains. It has several distinct features that we find useful and particularly relevant to the web3 world. It provides us with an offline-first storage solution for client side and fast data synchronization protocol with conflict resolution.

The Storage service is responsible for long term storage of immutable data (like big files - source images and text documents), backups. We believe IPFSarrow-up-right will be the standard in the near future and we integrate external distributed storage Filecoinarrow-up-right and use NFT.Storagearrow-up-right gateway.

Backend (Contracts, Indexer, Monitoring)

Deeper backend layer is concerned with business logic inside smart contracts, analytics tools and cloud infrastructure management.

The main part and business logic involving any value transfer is executed and verified on-chain. For this we develop a set of NEAR smart contracts written in Rustarrow-up-right (using Rust SDKarrow-up-right). For Camino contacts we use Solidityarrow-up-right. Until governance mechanisms are developed and tested, we are fully responsible for deployment and migrations. But once vSelf DAO is ready it's possible to pass admin rights to some consortium of users who will make decisions on behalf of the community.

The second one is Indexer service which serves two purposes. First it is responsible for the NEAR blockchain RPC endpoint, so it runs its own instance of NEAR (currently falls back to services like Infuraarrow-up-right) and makes sure our cloud never loses connectivity to the blockchain network. The second is to watch every blockchain state update and maps all relevant data to our internal representation. For this reason we integrate The Graph Protocolarrow-up-right sub-graphs to index NFTs, SBTs and verifiable credentials for each supported chain (NEAR, Camino).

Lastly for monitoring there is a separate service which aggregates analytics and logs from different sources and subsystems. Its goal is twofold - on one hand we need to provide our dev-ops with real-time data on systems health and operational status, on the other hand management needs access to the usage metrics for customer development and feature planning. We use Google Analyticsarrow-up-right for web & mobile applications, Pagodaarrow-up-right & Tenderly arrow-up-rightto implement the contracts monitoring functionality.

System architecture model

Here is systems architecture C4 modelarrow-up-right, render is available herearrow-up-right. The reference documentation and source model in DSL is published to our documentationarrow-up-right repository.

Last updated