# Roesticoin Infrastructure Documentation

## 1. Introduction

### Project Name
Roesticoin (ROC)

### Project Purpose
Roesticoin is a stablecoin implemented on the Ethereum blockchain. Its value is pegged to the price of potatoes in Swiss francs (CHF), aiming to provide a unique and innovative use case for blockchain-based currency. The project aspires to combine traditional agricultural economics with modern decentralized finance principles, making it both practical and educational.

### Target Audience
This documentation is intended for Thomas Bocek, the blockchain module professor at OST - University of Applied Sciences, as well as team members or developers who worked on the project.

---

## 2. Architecture Overview

### Key Components
- **Grafana Dashboard**: Provides a visual representation and monitoring of key metrics related to the Roesticoin project. It enables the team to track real-time data and ensure system reliability. It also double serves as our frontend.
- **Roesticoin Service**: Manages core application functions such as minting, burning, liquidity, marketplace operations, and token interactions. This is the backbone of the project, ensuring the proper functionality.
- **Prometheus**: Integrated with Grafana for data collection and metric aggregation. Prometheus ensures reliable and scalable data monitoring.

### Key Technologies
- **Programming Languages**: C# (backend and application logic), Solidity (smart contract implementation on Ethereum). We chose C# because the developers on the team were already familiar with it. The reason we chose Ethereum (and thus Solidity) is because that's what we got introduced to in the Blockchain module.
- **Monitoring Tools**: Grafana (dashboard creation and visualization), Prometheus (data collection and alerting). We chose these two tools because David suggested these as he already has had good experiences with them in the past and nobody opposed his suggestion.
- **Database**: Postgresql (database), because that's what everyone was familiar with.
- **Containerization**: Docker (standardizes development and deployment processes).

### High Level Infrastructure Diagram
<img src="ROC_highlevel.png">

### Low Level Infrastructure Diagram
<img src="ROC_infrastructure.png">

---

## 3. Infrastructure Details

### Environment Setup
We use two environments to facilitate development and deployment:
1. **Normal Environment**: A typical environment used for application deployment and testing in real-world scenarios.
2. **Devcontainer**: A standardized development environment configured using:
   - A JSON configuration file that defines the settings and dependencies.
   - A Docker Compose file to automate container setup and ensure uniformity across team members. This setup simplifies onboarding and minimizes discrepancies in development environments.

### Hosting
The Coin itself is deployed on the Ethereum blockchain. However, the rebalancing service we have is centralized. 

### Monitoring Metrics
Metrics monitored through Grafana include:
- **Total Supply of Roesticoin**: Tracks the overall circulating supply of the token.
- **WETH/Roesticoin Price**: Monitors the token's exchange rate with Wrapped Ethereum (WETH).
- **Marketplace Potato Price (CHF and ETH)**: Reflects the price of potatoes in Swiss francs and its equivalent in Ethereum.
- **ETH Price in CHF**: Keeps track of the current Ethereum price in Swiss francs for accurate conversions.
- **Total Weight of Potatoes in Storage**: Provides an aggregated value of all stored potatoes, essential for accurate backing of the stablecoin.

These are just the most barebone metrics we wanted to implement, as these will give everyone a quick glance at the health of ROC.

---

## 4. Deployment Processes

### Development Environment Setup
1. **Prerequisites**: Ensure Docker and the VS Code Dev Containers plugin are installed on your machine.
2. **Setup Process**: Open the project directory in VS Code. Use the Dev Containers feature to launch the development environment automatically.
3. **Run the Application**: Execute `Program.cs` using your development tools. This initializes the entire Roesticoin service, including core functionalities like monitoring and token operations.
4. **Standardization**: The devcontainer setup ensures that all developers work in a consistent environment, minimizing compatibility issues.

---

## 5. Tokenomics

### Minting and Burning Process
- **Minting**: Tokens are minted when the current supply of ROC is too low to push the current course.
- **Burning**: Burning works as the opposite of minting: when the supply of ROC is too high so the current course can't be pushed down enough, we burn ROC.
- These mechanisms follow established strategies used by other stablecoins, ensuring stability and reliability.

---

## 6. Monitoring and External Dependencies

### Data Sources
- Roesticoin relies on the official potato price published by the Swiss government. This data is manually fetched from reliable government reports, as no API is available.

---

## 7. Security

### Secure Processes
- The project adheres to standard blockchain security practices, ensuring the integrity and robustness of minting and burning operations.
- Smart contracts are thoroughly reviewed and tested to avoid vulnerabilities or exploits to the best of our abilities.
- Since the code base is on Andri Joos' own Gitlab server, access to the codebase is very restricted.

---

## 8. Maintenance

### Documentation Maintenance
- This will be the first and list time the documentation will be updated, since the projects is nearing its lifecycle.
