# System Architecture

**Mobile Application (Flutter Frontend)**

* **Cross-platform framework**: Single codebase for **iOS & Android** using **Flutter 3.x**.
* **State management**: **Riverpod + StateNotifier** for predictable state transitions.
* **Key security features**:
  * **Encrypted local storage** (using `flutter_secure_storage` with AES-256).
  * **Biometric authentication** (Face ID/Touch ID via biometric\_storage).
  * **Secure enclave usage** (where supported) for private key operations.
* **Transaction flow**:
  * **QR code scanning** for address input.
  * **Gas fee estimation** before signing.
  * **Real-time transaction tracking** via WebSocket.

#### **Wallet Core (Aptos SDK Integration)**

* **Key derivation**:
  * **BIP-39** mnemonic generation (12/24 words).
  * **BIP-44** deterministic wallet paths (`m/44'/637'/0'/0` for Aptos).
  * **Ed25519** key pairs for Aptos compatibility.
* **Transaction lifecycle**:
  * **Raw transaction construction** (Aptos ABI encoding).
  * **Client-side signing** (never exposes private keys).
  * **Submission via Supra Chain RPC**.

#### **Backend Services (Python + MongoDB)**

* **API layer**:
  * **FastAPI** for high-performance REST endpoints.
  * **JWT authentication** with short-lived tokens.
* **Database**:
  * **MongoDB** (sharded cluster for scalability).
  * **Stores**:
    * User preferences.
    * User wallet address and name.
    * Transaction metadata (not private keys).
    * Audit logs for compliance.
* **Security measures**:
  * **HSM-backed signing** for critical operations.
  * **IP filtering** and DDoS protection via Cloudflare.

**Blockchain Layer (Supra Chain + Move)**

* **Supra Chain advantages**:
  * **High TPS** (10,000+ transactions per second).
  * **Low latency** (sub-second finality).
  * **EVM compatibility** (future-proofing).
* **Move smart contracts**:
  * **Resource-oriented model** prevents double-spending.
  * **Module-based architecture** for reusable components.
  * **Formal verification** for security guarantees.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ribbit-wallet.gitbook.io/ribbit-wallet-whitepaper/technical-overview/system-architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
