# Solice
> A metaverse build on Solano that allows for interactive staking, asset trading and more more.
## Infrastructure
> A simple overview on the interaction between all the different components in the system.

### Requirements
- Vertical scalability
- Standalone / Modular
- Flexible
- Persistent
- Reliable
### Stack
* **DB:** Postgres SQL (Serverless)
* **API + Backend:** Express.JS + Typeorm (Serverless)
* **Caching:** Redis (Serverless)
* **Polling:** Google/CloudFlare worker
* **Indexer:** Google/CloudFlare worker
* **Staking:** Vue (TypeScript)
#### express.js
- fast development
- lightweight
- modular/standalone
- reliable
- simple
- powerful
- lots of community support

express.js is lightweight and modular, while being very reliable. it allows for quick development of backends, APIs and workers. The framework is very small and very flexible. Using express.js will allow us to seperate components easier and having them run indepdently on standalone servers allowing for easy scalibility with cloud workers + docker.
## Models
> Here we outline the required models and corresponding endpoints
* Wallets (/walllet)
* Users (/user)
* Profiles (/profile)
### /auth
> authenticate a session with a Firebase + Twitter token
### /user
> manage users and store profile/user/account information
- account data
- profile data
### /assets
> manage assets owned by a wallet
- type of assets
- number of assets
- value of assets
- trade history
### /wallet
> manage wallets owned by users that are related to a chain
- wallet balances
- incoming transactions
### /leaderboard
> get stats of the community / ecocystem
- experience
- points
- levels
- rewards
### /reward
> manage rewards created by the system
- related campaign
- experience
- points
- levels
## Authentication Flow
1) Social media
2) Firebase
3) Backend User

#### Options
1. Traditional login (email + password)
2. Social media login (twitter, facebook, google, etc)
3. Wallet login (address/keys only)
4. Social media/Traditional + Wallet (email/username + address)
## Workers
> Here we outline the required workers
### Blockchain Indexer
> Will scrape the Solana blockchain watching user wallets who registered to track balance and other stats.
#### Requirements
- Run every minute
- Access to a fleet of Solano nodes
- Scrape the entire chain and throw it behind a loadbalancer proxy api
### Polling
> Watch for state changes in the client/blockchain and update the centralized DB
#### Requirements
- Run every few minutes
- Access to blockchain (wallet)
- keep track of incoming transactions
- keep track of changing wallet balances
- keep track of client activity
## Deployment
> There are a few ways we can deploy this. For enterprise level deployment we should go with a cloud provider such as Google, Amazon, Alibaba and CloudFlare.
### Backend
We will need to make use of the following serverless services
* Databases
* Memory Stores
* App deployment + CI
* Load balancers
* Workers
* Nodes
Estimated costs per environment: 200 USD. We will need three environments (at least two):
1. Development (for local dev)
2. Staging (for internal testing)
3. Production (end user live app)
### Frontend
For frontend we can rely on CloudFlare deployment for the website and staking pool. This is completely free while offering the fatest and most reliable hosting. It also comes with free CI support. Paid plans allow bigger teams to operate and more builds, however, this does not influence performance.