# layr-labs/d-inference architecture

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

- Interactive diagram: https://gitdiagram.com/layr-labs/d-inference
- Repository: https://github.com/layr-labs/d-inference

## Overview

Darkbloom is a decentralized private-inference network: consumers submit OpenAI-compatible requests, the coordinator authenticates, routes and bills them, and provider Macs run inference in-process before streaming results back. The repository also includes a user console and an administrative UI for provider, account, network and payment operations. The README documents security and attestation paths; the sampled source excerpts are partial, so unverified internal wiring is intentionally omitted.

Main entry points: [`coordinator/api`](https://github.com/layr-labs/d-inference/tree/master/coordinator/api) (Coordinator API), [`provider-swift/Sources/ProviderCore/ProviderLoop+InferenceHandler.swift`](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/ProviderLoop%2BInferenceHandler.swift) (Request handler), [`coordinator/api/dispatch.go`](https://github.com/layr-labs/d-inference/blob/master/coordinator/api/dispatch.go) (Inference dispatch), [`provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swift`](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swift) (Model scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Consumer console"]
  node_console["User console"]
  node_chat["Chat interface<br/>[page.tsx]"]
  node_provider_ui["Provider dashboard"]
  node_analytics_ui["Network explorer"]
  node_earnings_ui["Earnings and billing UI"]
end

subgraph group_control["Coordinator services"]
  node_api["Coordinator API"]
  node_dispatch["Inference dispatch<br/>[dispatch.go]"]
  node_attestation["Provider attestation<br/>[app_attest.go]"]
  node_billing["Billing and payouts"]
  node_rewards["Base rewards<br/>[engine.go]"]
  node_network_stats["Network statistics<br/>[network_series.go]"]
end

subgraph group_provider["Provider runtime"]
  node_provider_loop["Request handler"]
  node_scheduler["Model scheduler"]
  node_bridge["Engine bridge"]
  node_vision["Vision prefill"]
  node_capacity["Capacity quoting"]
  node_mlx["MLX inference"]
end

subgraph group_operations["Network operations"]
  node_admin["Admin UI"]
end

node_consumer(("Consumer / SDK"))
node_gpu["Apple Silicon GPU"]
node_stripe["Stripe"]

node_consumer -->|"submits request"| node_api
node_console -->|"calls APIs"| node_api
node_chat -->|"sends chat"| node_api
node_api -->|"routes inference"| node_dispatch
node_dispatch -->|"dispatches encrypted request"| node_provider_loop
node_provider_loop -->|"admits request"| node_scheduler
node_scheduler -->|"submits tokens"| node_bridge
node_bridge -->|"runs model"| node_mlx
node_mlx -->|"executes inference"| node_gpu
node_provider_loop -->|"streams encrypted frames"| node_dispatch
node_dispatch -->|"streams response"| node_consumer
node_api -->|"verifies providers"| node_attestation
node_provider_ui -->|"manages provider"| node_api
node_admin -->|"queries operations"| node_api
node_api -->|"handles billing"| node_billing
node_billing -.->|"processes payouts"| node_stripe
node_api -->|"settles rewards"| node_rewards
node_analytics_ui -->|"requests statistics"| node_network_stats
node_earnings_ui -->|"requests account data"| node_api
node_api -->|"serves network data"| node_network_stats
node_scheduler -->|"prepares media"| node_vision
node_provider_loop -->|"quotes capacity"| node_capacity

click node_console "https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app"
click node_chat "https://github.com/layr-labs/d-inference/blob/master/console-ui/src/app/chat/page.tsx"
click node_provider_ui "https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/providers"
click node_admin "https://github.com/layr-labs/d-inference/tree/master/admin-ui/src/app"
click node_api "https://github.com/layr-labs/d-inference/tree/master/coordinator/api"
click node_dispatch "https://github.com/layr-labs/d-inference/blob/master/coordinator/api/dispatch.go"
click node_attestation "https://github.com/layr-labs/d-inference/blob/master/coordinator/api/app_attest.go"
click node_billing "https://github.com/layr-labs/d-inference/blob/master/coordinator/api/billing_handlers.go"
click node_rewards "https://github.com/layr-labs/d-inference/blob/master/coordinator/payments/baserewards/engine.go"
click node_provider_loop "https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/ProviderLoop%2BInferenceHandler.swift"
click node_scheduler "https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swift"
click node_bridge "https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge%2BSubmission.swift"
click node_vision "https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Vision/EngineV2VisionPrefill.swift"
click node_capacity "https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Coordinator/CapacityQuoteEngine.swift"
click node_mlx "https://github.com/layr-labs/d-inference/tree/master/provider-swift/Sources/ProviderCore/Inference/Engine"
click node_network_stats "https://github.com/layr-labs/d-inference/blob/master/coordinator/api/network_series.go"
click node_analytics_ui "https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/stats"
click node_earnings_ui "https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/billing"

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_console,node_chat,node_provider_ui,node_analytics_ui,node_earnings_ui toneBlue
class node_api,node_dispatch,node_attestation,node_billing,node_rewards,node_network_stats toneAmber
class node_provider_loop,node_scheduler,node_bridge,node_vision,node_capacity,node_mlx toneMint
class node_admin toneRose
class node_consumer,node_gpu,node_stripe toneIndigo
```

## Components

### Consumer console

- [User console](https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app): `console-ui/src/app`
- [Chat interface](https://github.com/layr-labs/d-inference/blob/master/console-ui/src/app/chat/page.tsx): `console-ui/src/app/chat/page.tsx`
- [Provider dashboard](https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/providers): `console-ui/src/app/providers`
- [Network explorer](https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/stats): `console-ui/src/app/stats`
- [Earnings and billing UI](https://github.com/layr-labs/d-inference/tree/master/console-ui/src/app/billing): `console-ui/src/app/billing`

### Coordinator services

- [Coordinator API](https://github.com/layr-labs/d-inference/tree/master/coordinator/api): `coordinator/api`
- [Inference dispatch](https://github.com/layr-labs/d-inference/blob/master/coordinator/api/dispatch.go): `coordinator/api/dispatch.go`
- [Provider attestation](https://github.com/layr-labs/d-inference/blob/master/coordinator/api/app_attest.go): `coordinator/api/app_attest.go`
- [Billing and payouts](https://github.com/layr-labs/d-inference/blob/master/coordinator/api/billing_handlers.go): `coordinator/api/billing_handlers.go`
- [Base rewards](https://github.com/layr-labs/d-inference/blob/master/coordinator/payments/baserewards/engine.go): `coordinator/payments/baserewards/engine.go`
- [Network statistics](https://github.com/layr-labs/d-inference/blob/master/coordinator/api/network_series.go): `coordinator/api/network_series.go`

### Provider runtime

- [Request handler](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/ProviderLoop%2BInferenceHandler.swift): `provider-swift/Sources/ProviderCore/ProviderLoop+InferenceHandler.swift`
- [Model scheduler](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swift): `provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swift`
- [Engine bridge](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge%2BSubmission.swift): `provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Submission.swift`
- [Vision prefill](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Inference/Vision/EngineV2VisionPrefill.swift): `provider-swift/Sources/ProviderCore/Inference/Vision/EngineV2VisionPrefill.swift`
- [Capacity quoting](https://github.com/layr-labs/d-inference/blob/master/provider-swift/Sources/ProviderCore/Coordinator/CapacityQuoteEngine.swift): `provider-swift/Sources/ProviderCore/Coordinator/CapacityQuoteEngine.swift`
- [MLX inference](https://github.com/layr-labs/d-inference/tree/master/provider-swift/Sources/ProviderCore/Inference/Engine): `provider-swift/Sources/ProviderCore/Inference/Engine`

### Network operations

- [Admin UI](https://github.com/layr-labs/d-inference/tree/master/admin-ui/src/app): `admin-ui/src/app`

### Other components

- **Consumer / SDK**
- **Apple Silicon GPU**
- **Stripe**

## Connections

- Consumer / SDK → Coordinator API: submits request
- User console → Coordinator API: calls APIs
- Chat interface → Coordinator API: sends chat
- Coordinator API → Inference dispatch: routes inference
- Inference dispatch → Request handler: dispatches encrypted request
- Request handler → Model scheduler: admits request
- Model scheduler → Engine bridge: submits tokens
- Engine bridge → MLX inference: runs model
- MLX inference → Apple Silicon GPU: executes inference
- Request handler → Inference dispatch: streams encrypted frames
- Inference dispatch → Consumer / SDK: streams response
- Coordinator API → Provider attestation: verifies providers
- Provider dashboard → Coordinator API: manages provider
- Admin UI → Coordinator API: queries operations
- Coordinator API → Billing and payouts: handles billing
- Billing and payouts → Stripe: processes payouts
- Coordinator API → Base rewards: settles rewards
- Network explorer → Network statistics: requests statistics
- Earnings and billing UI → Coordinator API: requests account data
- Coordinator API → Network statistics: serves network data
- Model scheduler → Vision prefill: prepares media
- Request handler → Capacity quoting: quotes capacity
