# Overall Flow Diagram

{% @mermaid/diagram content="
flowchart TD

%% User Flow
A\[User: MetaMask Wallet Holder] --> B\[Connects to MetaMiles dApp]
B --> C\[Verifies Card Ownership via MetaMask SDK]
C --> D\[Spends Using MetaMask Card]

%% Chainlink Oracle and Spend Tracking
D --> E\[Chainlink Function / Oracle Fetches Spend]
E --> F\[Updates On-Chain SpendTracker Contract]

%% ZK Proof Flow
F --> G\[User Opens MetaMiles dApp]
G --> H\[Generates ZK Proof of Spend > X]
H --> I\[Submits Proof to ZKVerifier Contract]

%% Reward Claim
I --> J\[ZKVerifier Verifies Proof]
J --> K\[Mints Soulbound Reward NFT / Token via RewardNFTMinter]

%% Reward Usage
K --> L\[Unlocks IRL Perks like Tickets, Discounts, Merch]

%% LI.FI and Cross-Chain
L --> M{Wants Reward on Other Chain?}
M -- Yes --> N\[LI.FI SDK Bridges Reward via Circle CCTP]
M -- No --> O\[Stores in  Circle Wallet]

%% Optional Custody
N --> P\[Reward NFT Delivered to User on Preferred Chain]
O --> Q\[Stored in Circle Wallet]

%% Partner Admin Flow
R\[Partner Admin ] --> S\[Uses MetaMiles Partner Dashboard]
S --> T\[Uploads Rewards, Sets Tiers, Defines Region Rules]
T --> K

style A fill:#f9f,stroke:#333,stroke-width:2px
style R fill:#ccf,stroke:#333,stroke-width:2px
style S fill:#ccf,stroke:#333,stroke-width:1px

" %}
