# System Architecture

DecentraFit is built as a **three-layer privacy architecture** that connects real-world human activity to a verifiable digital network. Each layer from the **devices**, the **application interface**, to the **ZK-enabled Layer-2 network** serves a distinct function in maintaining data integrity, privacy, and proof of genuine health activity.

### Devices

At the foundation of DecentraFit’s ecosystem are the **DecentraFit Watch** and **Health Ring**, both designed to operate as **hardware oracles** for authentic, real-world biometric data.\
Each device integrates multiple sensors — including heart rate (HR), heart-rate variability (HRV), blood oxygen (SpO₂), motion, and temperature — combined with embedded machine-learning models that verify genuine human activity and reject synthetic or replayed signals.

After validation, the device produces a **Zero-Knowledge Proof (ZKP)** through a lightweight SNARK circuit. This cryptographic proof verifies that the activity occurred without exposing any underlying biometric information. In this way, every DecentraFit device becomes a **trust anchor** in the network: a secure endpoint that converts human motion into verifiable, privacy-preserving digital evidence.

```
 ┌────────────────────────────┐
 │  DecentraFit Devices       │
 │  • Sensor Fusion (HR, HRV, SpO₂)
 │  • On-device AI validation
 │  • ZK proof generator (SNARK circuit)
 └────────────┬───────────────┘
```

### Application

The **DecentraFit App** acts as the central bridge between user devices and the decentralized Layer-2 network. It is responsible for securely managing encrypted proof submissions and maintaining user privacy at every stage of verification.

The app performs three primary functions:

1. **Proof Aggregation** – Collects and batches verified proofs of activity generated by the DecentraFit Watch and Health Ring before submitting them to the Layer-2 verifier.
2. **Local Zero-Knowledge Verification** – Validates each proof locally to ensure authenticity and prevent tampering or duplication prior to blockchain submission.
3. **Encrypted Data Vault** – Stores all user activity data locally using AES-256-GCM encryption. Biometric information never leaves the device or app environment unless the user explicitly authorizes it.

This layer acts as a **cryptographic firewall** and a **privacy gateway**, ensuring that every health proof remains user-controlled from creation to validation.\
In the DecentraFit model, **privacy begins and ends with the individual**, not with a remote server or centralized database.

```
              │ Encrypted PoA-ZK proofs
              ▼
 ┌────────────────────────────┐
 │      DecentraFit App       │
 │  • Proof aggregation       │
 │  • Local ZK verification   │
 │  • Encrypted data vault    │
 └────────────┬───────────────┘
```

### The Network

Our network operates as a **Layer-2 protocol** built on top of existing zero-knowledge infrastructure. The primary purpose is to verify proofs of activity, manage consensus validation, and handle automated token reward distribution — all while maintaining privacy, scalability, and efficiency.

#### Core Components

1. **ZK Verification Engine**\
   The network uses recursive SNARK verification to confirm the authenticity of thousands of Proof-of-Activity attestations in a single, compact transaction.\
   This process guarantees integrity without revealing any biometric or personal information.
2. **Layer-2 Validators**\
   Validators operate within the host blockchain’s consensus layer, confirming aggregated batches of DecentraFit proofs.\
   Their role is to ensure that only valid, ZK-certified proofs are committed to the underlying Layer-1 ledger for finality and security inheritance.
3. **DFIT Reward Contracts**\
   Smart contracts automatically issue DFIT tokens to users based on their verified activity levels.\
   Rewards are distributed transparently, with parameters defined by governance through the Health DAO.

#### Network Integrity

This architecture allows DecentraFit to maintain **privacy, scalability, and decentralization** simultaneously. By anchoring its consensus to an established ZK Layer-2 network, DecentraFit inherits enterprise-grade security while introducing a new mechanism for human-driven validation.

Every verified action contributes to both **personal wellness** and **network resilience**, creating a system where the act of staying healthy directly strengthens the decentralized ecosystem.

```
              │ On-chain submission
              ▼
 ┌────────────────────────────┐
 │   DecentraFit ZK Network   │
 │  • ZK verification engine  │
 │  • Layer-2 validators      │
 │  • DFIT reward contracts    │
 └────────────────────────────┘
```
