# borodooovitsyn/coreshare architecture

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

- Interactive diagram: https://gitdiagram.com/borodooovitsyn/coreshare
- Repository: https://github.com/borodooovitsyn/coreshare

## Overview

CoreShare is a GPU-compute marketplace. Renters submit jobs through the web client; the API stores and shards work, provider workers claim and sandbox chunks, report GPU usage and return results, and a settlement service converts recorded usage into SOL payouts. The web and Electron clients expose renter, wallet, provider, and earnings experiences. The README supplies several cross-system relationships; sampled excerpts show API handlers, worker execution, metric persistence, and settlement internals. Other UI and subsystem details are represented at documented capability level.

Main entry points: [`services/api/app/main.py`](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/main.py) (API routing), [`services/worker/__main__.py`](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/__main__.py) (Worker process), [`payments/run_settlement.py`](https://github.com/borodooovitsyn/coreshare/blob/main/payments/run_settlement.py) (Settlement runner), [`payments/settlement.py`](https://github.com/borodooovitsyn/coreshare/blob/main/payments/settlement.py) (Settlement engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client apps"]
  node_web_rent["Rent and jobs<br/>[page.tsx]"]
  node_web_wallet["Wallet and earnings<br/>[page.tsx]"]
  node_web_account["Account access<br/>[page.tsx]"]
  node_web_job_view["Live job view<br/>[JobView.tsx]"]
  node_desktop_app["Provider desktop<br/>[renderer.js]"]
  node_desktop_api["Desktop API client<br/>[api.js]"]
end

subgraph group_api["Marketplace API"]
  node_api_routes["API routing<br/>[main.py]"]
  node_job_queue["Job queue and chunks<br/>[jobs.py]"]
  node_artifacts["Input and results<br/>[artifacts.py]"]
  node_credit_ledger[("Wallet credits<br/>[credits.py]")]
end

subgraph group_worker["Provider execution"]
  node_worker_entry["Worker process<br/>[__main__.py]"]
  node_worker_client["Backend client<br/>[client.py]"]
  node_worker_loop["Claim and run loop<br/>[loop.py]"]
  node_gpu_sampling["GPU sampling<br/>[gpu.py]"]
  node_sandbox["Container sandbox<br/>[sandbox.py]"]
  node_job_images["Job image handlers"]
end

subgraph group_metering["Metering and settlement"]
  node_metrics_repo[("Metrics and earnings<br/>[database.py]")]
  node_settlement_runner["Settlement runner<br/>[run_settlement.py]"]
  node_usage_source["Usage source<br/>[usage_source.py]"]
  node_settlement_engine["Settlement engine<br/>[settlement.py]"]
  node_settlement_state[("Idempotency state<br/>[state.py]")]
  node_solana_client["Solana transfers<br/>[solana_clients.py]"]
end

subgraph group_identity["Identity and accounts"]
  node_pairing["Device pairing<br/>[pairing.py]"]
  node_wallet_auth["Wallet authentication<br/>[auth.py]"]
  node_account_links[("Account and worker links<br/>[links.py]")]
end

node_renter(("Renter"))
node_provider(("GPU provider"))
node_timescale[("Tiger Data")]
node_solana["Solana devnet"]

node_renter -->|"submits work"| node_web_rent
node_web_rent -->|"requests jobs"| node_api_routes
node_web_wallet -->|"reads wallet data"| node_api_routes
node_web_job_view -->|"views job status"| node_api_routes
node_provider -->|"controls sharing"| node_desktop_app
node_desktop_app -->|"uses client"| node_desktop_api
node_desktop_api -->|"calls backend"| node_api_routes
node_web_account -->|"registers account"| node_api_routes
node_api_routes -->|"verifies wallet"| node_wallet_auth
node_api_routes -->|"pairs devices"| node_pairing
node_api_routes -->|"links accounts"| node_account_links
node_api_routes -->|"updates credits"| node_credit_ledger
node_api_routes -->|"creates and claims"| node_job_queue
node_api_routes -->|"stores files"| node_artifacts
node_api_routes -->|"records and reads"| node_metrics_repo
node_worker_entry -->|"calls backend"| node_worker_client
node_worker_entry -->|"runs jobs"| node_worker_loop
node_worker_entry -->|"samples GPU"| node_gpu_sampling
node_worker_entry -->|"executes chunks"| node_sandbox
node_worker_loop -->|"claims and reports"| node_worker_client
node_worker_loop -.->|"meters usage"| node_gpu_sampling
node_worker_client -->|"sends HTTP calls"| node_api_routes
node_worker_client -->|"transfers artifacts"| node_artifacts
node_sandbox -.->|"runs workload images"| node_job_images
node_metrics_repo -->|"writes and queries"| node_timescale
node_settlement_runner -->|"runs cycles"| node_settlement_engine
node_settlement_runner -->|"configures source"| node_usage_source
node_settlement_runner -->|"configures state"| node_settlement_state
node_settlement_runner -->|"configures payments"| node_solana_client
node_settlement_engine -->|"fetches usage"| node_usage_source
node_settlement_engine -->|"checks and marks"| node_settlement_state
node_settlement_engine -->|"sends payout"| node_solana_client
node_usage_source -->|"reads earnings"| node_api_routes
node_solana_client -->|"transfers SOL"| node_solana
node_api_routes -->|"resolves workers"| node_account_links

click node_web_rent "https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/rent/page.tsx"
click node_web_wallet "https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/wallet/page.tsx"
click node_web_account "https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/register/page.tsx"
click node_web_job_view "https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/jobs/%5Bid%5D/JobView.tsx"
click node_desktop_app "https://github.com/borodooovitsyn/coreshare/blob/main/apps/desktop/renderer.js"
click node_desktop_api "https://github.com/borodooovitsyn/coreshare/blob/main/apps/desktop/src/api.js"
click node_api_routes "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/main.py"
click node_job_queue "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/jobs.py"
click node_artifacts "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/artifacts.py"
click node_pairing "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/pairing.py"
click node_wallet_auth "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/auth.py"
click node_account_links "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/links.py"
click node_credit_ledger "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/credits.py"
click node_worker_entry "https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/__main__.py"
click node_worker_client "https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/client.py"
click node_worker_loop "https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/loop.py"
click node_gpu_sampling "https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/gpu.py"
click node_sandbox "https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/sandbox.py"
click node_job_images "https://github.com/borodooovitsyn/coreshare/tree/main/services/worker/images"
click node_metrics_repo "https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/database.py"
click node_settlement_runner "https://github.com/borodooovitsyn/coreshare/blob/main/payments/run_settlement.py"
click node_usage_source "https://github.com/borodooovitsyn/coreshare/blob/main/payments/usage_source.py"
click node_settlement_engine "https://github.com/borodooovitsyn/coreshare/blob/main/payments/settlement.py"
click node_settlement_state "https://github.com/borodooovitsyn/coreshare/blob/main/payments/state.py"
click node_solana_client "https://github.com/borodooovitsyn/coreshare/blob/main/payments/solana_clients.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_web_rent,node_web_wallet,node_web_account,node_web_job_view,node_desktop_app,node_desktop_api toneBlue
class node_api_routes,node_job_queue,node_artifacts,node_credit_ledger,node_timescale toneAmber
class node_worker_entry,node_worker_client,node_worker_loop,node_gpu_sampling,node_sandbox,node_job_images toneMint
class node_metrics_repo,node_settlement_runner,node_usage_source,node_settlement_engine,node_settlement_state,node_solana_client toneRose
class node_pairing,node_wallet_auth,node_account_links,node_renter,node_provider,node_solana toneIndigo
```

## Components

### Client apps

- [Rent and jobs](https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/rent/page.tsx): `apps/web/app/rent/page.tsx`
- [Wallet and earnings](https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/wallet/page.tsx): `apps/web/app/wallet/page.tsx`
- [Account access](https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/register/page.tsx): `apps/web/app/register/page.tsx`
- [Live job view](https://github.com/borodooovitsyn/coreshare/blob/main/apps/web/app/jobs/%5Bid%5D/JobView.tsx): `apps/web/app/jobs/[id]/JobView.tsx`
- [Provider desktop](https://github.com/borodooovitsyn/coreshare/blob/main/apps/desktop/renderer.js): `apps/desktop/renderer.js`
- [Desktop API client](https://github.com/borodooovitsyn/coreshare/blob/main/apps/desktop/src/api.js): `apps/desktop/src/api.js`

### Marketplace API

- [API routing](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [Job queue and chunks](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/jobs.py): `services/api/app/jobs.py`
- [Input and results](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/artifacts.py): `services/api/app/artifacts.py`
- [Wallet credits](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/credits.py): `services/api/app/credits.py`

### Provider execution

- [Worker process](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/__main__.py): `services/worker/__main__.py`
- [Backend client](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/client.py): `services/worker/client.py`
- [Claim and run loop](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/loop.py): `services/worker/loop.py`
- [GPU sampling](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/gpu.py): `services/worker/gpu.py`
- [Container sandbox](https://github.com/borodooovitsyn/coreshare/blob/main/services/worker/sandbox.py): `services/worker/sandbox.py`
- [Job image handlers](https://github.com/borodooovitsyn/coreshare/tree/main/services/worker/images): `services/worker/images`

### Metering and settlement

- [Metrics and earnings](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/database.py): `services/api/app/database.py`
- [Settlement runner](https://github.com/borodooovitsyn/coreshare/blob/main/payments/run_settlement.py): `payments/run_settlement.py`
- [Usage source](https://github.com/borodooovitsyn/coreshare/blob/main/payments/usage_source.py): `payments/usage_source.py`
- [Settlement engine](https://github.com/borodooovitsyn/coreshare/blob/main/payments/settlement.py): `payments/settlement.py`
- [Idempotency state](https://github.com/borodooovitsyn/coreshare/blob/main/payments/state.py): `payments/state.py`
- [Solana transfers](https://github.com/borodooovitsyn/coreshare/blob/main/payments/solana_clients.py): `payments/solana_clients.py`

### Identity and accounts

- [Device pairing](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/pairing.py): `services/api/app/pairing.py`
- [Wallet authentication](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/auth.py): `services/api/app/auth.py`
- [Account and worker links](https://github.com/borodooovitsyn/coreshare/blob/main/services/api/app/links.py): `services/api/app/links.py`

### Other components

- **Renter**
- **GPU provider**
- **Tiger Data**
- **Solana devnet**

## Connections

- Renter → Rent and jobs: submits work
- Rent and jobs → API routing: requests jobs
- Wallet and earnings → API routing: reads wallet data
- Live job view → API routing: views job status
- GPU provider → Provider desktop: controls sharing
- Provider desktop → Desktop API client: uses client
- Desktop API client → API routing: calls backend
- Account access → API routing: registers account (evidence: `services/api/app/main.py`)
- API routing → Wallet authentication: verifies wallet (evidence: `services/api/app/main.py`)
- API routing → Device pairing: pairs devices (evidence: `services/api/app/main.py`)
- API routing → Account and worker links: links accounts (evidence: `services/api/app/main.py`)
- API routing → Wallet credits: updates credits (evidence: `services/api/app/main.py`)
- API routing → Job queue and chunks: creates and claims (evidence: `services/api/app/main.py`)
- API routing → Input and results: stores files (evidence: `services/api/app/main.py`)
- API routing → Metrics and earnings: records and reads (evidence: `services/api/app/main.py`)
- Worker process → Backend client: calls backend (evidence: `services/worker/__main__.py`)
- Worker process → Claim and run loop: runs jobs (evidence: `services/worker/__main__.py`)
- Worker process → GPU sampling: samples GPU (evidence: `services/worker/__main__.py`)
- Worker process → Container sandbox: executes chunks (evidence: `services/worker/__main__.py`)
- Claim and run loop → Backend client: claims and reports (evidence: `services/worker/loop.py`)
- Claim and run loop → GPU sampling: meters usage
- Backend client → API routing: sends HTTP calls (evidence: `services/worker/client.py`)
- Backend client → Input and results: transfers artifacts (evidence: `services/worker/client.py`)
- Container sandbox → Job image handlers: runs workload images
- Metrics and earnings → Tiger Data: writes and queries (evidence: `services/api/app/database.py`)
- Settlement runner → Settlement engine: runs cycles (evidence: `payments/run_settlement.py`)
- Settlement runner → Usage source: configures source (evidence: `payments/run_settlement.py`)
- Settlement runner → Idempotency state: configures state (evidence: `payments/run_settlement.py`)
- Settlement runner → Solana transfers: configures payments (evidence: `payments/run_settlement.py`)
- Settlement engine → Usage source: fetches usage (evidence: `payments/settlement.py`)
- Settlement engine → Idempotency state: checks and marks (evidence: `payments/settlement.py`)
- Settlement engine → Solana transfers: sends payout (evidence: `payments/settlement.py`)
- Usage source → API routing: reads earnings (evidence: `payments/usage_source.py`)
- Solana transfers → Solana devnet: transfers SOL (evidence: `payments/solana_clients.py`)
- API routing → Account and worker links: resolves workers (evidence: `services/api/app/main.py`)
