> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coverfi.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture Diagrams

> Visual guide to CoverFi contract and app flows

This page shows the main CoverFi flows as diagrams.

## Contract map

```mermaid theme={null}
flowchart TD
  User[User Wallet]
  Engine[Protection Engine]
  Protected[Protected Balance Vault]
  Reserve[Reserve Vault]
  Oracle[Oracle Adapter]
  Username[Username Registry]
  Receipt[Receipt Registry]

  User --> Engine
  Engine --> Protected
  Engine --> Reserve
  Engine --> Oracle
  User --> Username
  User --> Receipt
  Receipt -->|Access, anchors, disputes| Receipt
```

## Protection creation

```mermaid theme={null}
sequenceDiagram
  participant U as User
  participant W as Wallet
  participant E as Protection Engine
  participant P as Protected Vault
  participant R as Reserve Vault

  U->>W: Approves protection transaction
  W->>E: create_position()
  E->>P: deposit_from()
  E->>R: collect_premium_from()
  E->>R: lock_payout_capacity()
```

## Expiry settlement and exit path

```mermaid theme={null}
sequenceDiagram
  participant U as User
  participant E as Protection Engine
  participant O as Oracle Adapter
  participant R as Reserve Vault

  U->>E: settle_position(position)
  E->>O: get_price_at_or_before(expiry)
  E->>E: reject invalid or missing expiry observation
  E->>R: settle_position(position, payout)
  R->>R: release unused capacity or reserve full payout
  U->>E: claim_payout(position)
  E->>R: claim_payout()
  U->>E: withdraw_principal(position)
```

## Username payment and receipt flow

```mermaid theme={null}
flowchart LR
  A[Sender enters username] --> B[Username Registry resolves address]
  B --> C[Wallet signs Stellar payment]
  C --> D[Stellar settles payment]
  D --> E[Receipt Registry anchors proof]
  E --> F[App stores wallet-local receipt history]
```

## Trust boundaries

```mermaid theme={null}
flowchart TD
  Wallet[User wallet signs funds movement]
  Contracts[Soroban contracts enforce protocol state]
  Backend[Backend provides AI, market, support, and health APIs]
  Oracle[Oracle publishes price and timestamp]
  Admin[Admin can pause/update policy]

  Wallet --> Contracts
  Oracle --> Contracts
  Admin --> Contracts
  Backend -. does not sign user transactions .-> Wallet
```

Important boundaries:

* Backend cannot sign user transactions.
* AI cannot move funds.
* Oracle observations must be valid for entry quotes and expiry settlement.
* Admin policy must be hardened before mainnet scale.
* Reserve accounting prevents provider withdrawals from using locked liabilities or reserved claims.
