# nagasiv-cyber/gpu architecture

> Architecture diagram of the GitHub repository nagasiv-cyber/gpu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nagasiv-cyber/gpu
- Repository: https://github.com/nagasiv-cyber/gpu

## Overview

GPUSetu is a peer-to-peer GPU rental marketplace whose core workflow prices and matches a buyer’s job, locks payment, runs it on a host GPU, meters and audits actual GPU work, then settles or slashes escrow. The README documents cloud fallback, host controls, sandboxing, and buyer deliverables; sampled source confirms key backend, host, and chain responsibilities. Some routes and subsystem internals were not sampled, so only documented relationships are shown for them.

Main entry points: [`backend.py`](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py) (Marketplace Backend), [`host_daemon.py`](https://github.com/nagasiv-cyber/gpu/blob/main/host_daemon.py) (Host Daemon), [`chain.py`](https://github.com/nagasiv-cyber/gpu/blob/main/chain.py) (Chain Adapter), [`static/app.html`](https://github.com/nagasiv-cyber/gpu/blob/main/static/app.html) (Buyer Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Marketplace"]
  node_dashboard["Buyer Dashboard<br/>[app.html]"]
  node_backend["Marketplace Backend<br/>[backend.py]"]
  node_pricing["Surge Pricing<br/>[backend.py]"]
  node_matching["Host Matching<br/>[backend.py]"]
  node_cloud["Cloud Fallback<br/>[backend.py]"]
  node_audit["Telemetry Audit<br/>[backend.py]"]
end

subgraph group_hostside["GPU Host"]
  node_hostportal["Host Portal<br/>[portal.html]"]
  node_daemon["Host Daemon<br/>[host_daemon.py]"]
  node_sandbox["Docker Sandbox<br/>[host_daemon.py]"]
  node_gpu[("Host GPU")]
  node_demojob["MNIST Training Job<br/>[demo_job.py]"]
  node_fakejob["Fraud Demo Job<br/>[fake_job.py]"]
end

subgraph group_settlement["Escrow Settlement"]
  node_chainadapter["Chain Adapter<br/>[chain.py]"]
  node_contract["Escrow Contract<br/>[GPUSetuEscrow.sol]"]
end

subgraph group_delivery["Job Deliverables"]
  node_artifacts["Verified Artifacts<br/>[backend.py]"]
  node_modelverify["Model Verification<br/>[verify_model.py]"]
end

node_buyer(("Buyer"))

node_buyer -->|"submits jobs"| node_dashboard
node_dashboard -->|"uses API"| node_backend
node_backend -->|"quotes rate"| node_pricing
node_backend -->|"matches host"| node_matching
node_matching -->|"dispatches job"| node_daemon
node_matching -->|"falls back"| node_cloud
node_backend -->|"locks payment"| node_chainadapter
node_chainadapter -->|"sends transactions"| node_contract
node_daemon -->|"runs job in"| node_sandbox
node_sandbox -->|"uses GPU"| node_gpu
node_daemon -->|"reads NVML telemetry"| node_gpu
node_demojob -->|"trains on"| node_gpu
node_fakejob -->|"leaves idle"| node_gpu
node_backend -->|"reads job telemetry"| node_daemon
node_backend -->|"checks claim"| node_audit
node_audit -->|"settles or slashes"| node_chainadapter
node_daemon -->|"produces outputs"| node_artifacts
node_backend -->|"delivers verified files"| node_artifacts
node_buyer -->|"checks model"| node_modelverify
node_artifacts -->|"loads delivered model"| node_modelverify
node_hostportal -->|"reads host earnings"| node_backend

click node_dashboard "https://github.com/nagasiv-cyber/gpu/blob/main/static/app.html"
click node_backend "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_pricing "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_matching "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_cloud "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_audit "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_hostportal "https://github.com/nagasiv-cyber/gpu/blob/main/static/portal.html"
click node_daemon "https://github.com/nagasiv-cyber/gpu/blob/main/host_daemon.py"
click node_sandbox "https://github.com/nagasiv-cyber/gpu/blob/main/host_daemon.py"
click node_demojob "https://github.com/nagasiv-cyber/gpu/blob/main/jobs/demo_job.py"
click node_fakejob "https://github.com/nagasiv-cyber/gpu/blob/main/jobs/fake_job.py"
click node_chainadapter "https://github.com/nagasiv-cyber/gpu/blob/main/chain.py"
click node_contract "https://github.com/nagasiv-cyber/gpu/blob/main/contracts/GPUSetuEscrow.sol"
click node_artifacts "https://github.com/nagasiv-cyber/gpu/blob/main/backend.py"
click node_modelverify "https://github.com/nagasiv-cyber/gpu/blob/main/verify_model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_backend,node_pricing,node_matching,node_cloud,node_audit toneBlue
class node_hostportal,node_daemon,node_sandbox,node_gpu,node_demojob,node_fakejob toneAmber
class node_chainadapter,node_contract toneMint
class node_artifacts,node_modelverify toneRose
class node_buyer toneIndigo
```

## Components

### Marketplace

- [Buyer Dashboard](https://github.com/nagasiv-cyber/gpu/blob/main/static/app.html): `static/app.html`
- [Marketplace Backend](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`
- [Surge Pricing](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`
- [Host Matching](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`
- [Cloud Fallback](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`
- [Telemetry Audit](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`

### GPU Host

- [Host Portal](https://github.com/nagasiv-cyber/gpu/blob/main/static/portal.html): `static/portal.html`
- [Host Daemon](https://github.com/nagasiv-cyber/gpu/blob/main/host_daemon.py): `host_daemon.py`
- [Docker Sandbox](https://github.com/nagasiv-cyber/gpu/blob/main/host_daemon.py): `host_daemon.py`
- **Host GPU**
- [MNIST Training Job](https://github.com/nagasiv-cyber/gpu/blob/main/jobs/demo_job.py): `jobs/demo_job.py`
- [Fraud Demo Job](https://github.com/nagasiv-cyber/gpu/blob/main/jobs/fake_job.py): `jobs/fake_job.py`

### Escrow Settlement

- [Chain Adapter](https://github.com/nagasiv-cyber/gpu/blob/main/chain.py): `chain.py`
- [Escrow Contract](https://github.com/nagasiv-cyber/gpu/blob/main/contracts/GPUSetuEscrow.sol): `contracts/GPUSetuEscrow.sol`

### Job Deliverables

- [Verified Artifacts](https://github.com/nagasiv-cyber/gpu/blob/main/backend.py): `backend.py`
- [Model Verification](https://github.com/nagasiv-cyber/gpu/blob/main/verify_model.py): `verify_model.py`

### Other components

- **Buyer**

## Connections

- Buyer → Buyer Dashboard: submits jobs (evidence: `README.md`)
- Buyer Dashboard → Marketplace Backend: uses API (evidence: `backend.py`)
- Marketplace Backend → Surge Pricing: quotes rate (evidence: `README.md`)
- Marketplace Backend → Host Matching: matches host (evidence: `README.md`)
- Host Matching → Host Daemon: dispatches job (evidence: `README.md`)
- Host Matching → Cloud Fallback: falls back (evidence: `README.md`)
- Marketplace Backend → Chain Adapter: locks payment (evidence: `backend.py`)
- Chain Adapter → Escrow Contract: sends transactions (evidence: `README.md`)
- Host Daemon → Docker Sandbox: runs job in (evidence: `README.md`)
- Docker Sandbox → Host GPU: uses GPU (evidence: `README.md`)
- Host Daemon → Host GPU: reads NVML telemetry (evidence: `host_daemon.py`)
- MNIST Training Job → Host GPU: trains on (evidence: `jobs/demo_job.py`)
- Fraud Demo Job → Host GPU: leaves idle (evidence: `jobs/fake_job.py`)
- Marketplace Backend → Host Daemon: reads job telemetry (evidence: `backend.py`)
- Marketplace Backend → Telemetry Audit: checks claim (evidence: `README.md`)
- Telemetry Audit → Chain Adapter: settles or slashes (evidence: `backend.py`)
- Host Daemon → Verified Artifacts: produces outputs (evidence: `README.md`)
- Marketplace Backend → Verified Artifacts: delivers verified files (evidence: `backend.py`)
- Buyer → Model Verification: checks model (evidence: `verify_model.py`)
- Verified Artifacts → Model Verification: loads delivered model (evidence: `verify_model.py`)
- Host Portal → Marketplace Backend: reads host earnings (evidence: `backend.py`)
