Repository Structure

This document provides a comprehensive overview of the MiningOS repositories. It explains the organizational patterns, inheritance hierarchy, and standard conventions used across all worker repositories.

For the system architecture and component relationships, see Architecture. For contribution workflow, see Contribution Workflow.


Overview

MiningOS follows a modular, inheritance-based architecture. Functionality is distributed across multiple Git repositories. Each repository serves a specific purpose in the hierarchy, from foundational worker utilities to concrete device implementations.

Design Philosophy

The repository structure embodies several key principles:

Principle
Description
Related Documentation

Inheritance over composition

Base classes provide core functionality that specialized workers extend

Convention over configuration

Standard directory layouts and naming patterns reduce cognitive overhead

Separation of concerns

Each repository focuses on a single abstraction level or device category

Reusability

Common patterns are extracted into template repositories for maximum code sharing

Repository Hierarchy

Regarding the workers for physical devices, the MiningOS ecosystem consists of repositories organized into five distinct levels. For the complete architecture diagram, see Architecture — Object Model.

Level 1: Foundation
└── bfx-wrk-base                    # Core worker primitives

Level 2: Platform Base
└── tether-wrk-base                 # Tether/MiningOS worker foundation

Level 3: Thing Management
└── miningos-tpl-wrk-thing          # Abstract "thing" device management

Level 4: Device Category Templates
├── miningos-tpl-wrk-miner          # Mining hardware template
├── miningos-tpl-wrk-container      # Container infrastructure template
├── miningos-tpl-wrk-sensor         # Environmental sensor template
├── miningos-tpl-wrk-powermeter     # Power monitoring template
└── miningos-tpl-wrk-electricity    # Electricity usage 

Level 5: Concrete Implementations
├── miningos-wrk-miner-whatsminer   # WhatsMiner devices (like m53s)
├── miningos-wrk-miner-antminer     # Antminer devices (like s19xp)
├── miningos-wrk-miner-avalon       # Avalon devices (like a1346)
├── miningos-wrk-container-antspace # Antspace miner containers (like hk3)
├── miningos-wrk-container-microbt  # MicroBT miner containers (like kehua)
├── miningos-wrk-sensor-temp-seneca # Seneca temperature sensors
├── miningos-wrk-powermeter-satec   # Satec power meters (like PM180)
└── miningos-wrk-powermeter-schneider # Schneider power meters (like PM5340)

For creating new workers at each level, see Adding New Worker Type. For supported device specifications, see Supported Devices.

Standard Directory Structure

All MiningOS worker repositories follow a consistent directory layout. Below is the canonical structure:

For testing guidelines, see Testing & Linting Guidelines. For documentation standards, see Code Documentation Standards.

Directory Purpose Reference

Directory/File
Purpose
Related Documentation

config/

All configuration files with .example templates

config/facs/

Facility-specific configuration (network, storage)

mock/

Test doubles for device simulation

tests/

Brittle test framework test suite

workers/

Core worker implementation

workers/lib/

Shared utilities and base classes

worker.js

CLI entry point for worker startup

setup-config.sh

Copies .example files to active configs

upstream-merge.sh

Merges changes from parent template

Naming Conventions

Repository names

Pattern
Example
Description
Documentation

bfx-wrk-base

Bitfinex foundation worker

tether-wrk-base

Tether platform base

miningos-tpl-wrk-<type>

miningos-tpl-wrk-miner

Template/abstract worker

miningos-wrk-<type>-<brand>

miningos-wrk-miner-whatsminer

Concrete implementation

miningos-wrk-ext-<service>

miningos-wrk-ext-mempool

External service integration

Class names

Component
Convention
Example
Documentation

Worker class

Wrk<Device>Rack

WrkMinerRack

Base device class

Base<Device>

BaseMiner

Device controller

<Brand><Device>

WhatsminerMiner

Model-specific worker class

Wrk<Device>Rack<Model>

WrkMinerRackM56s

Key files explained

File
Purpose
Related Documentation

worker.js

The entry point for all workers. This file is minimal and delegates to the bfx-svc-boot-js framework

package.json

Standard Node.js package manifest with MiningOS-specific conventions

setup-config.sh

Utility script that creates active configuration files from '.example' files

upstream-merge.sh

Merges changes from parent template

config/base.thing.json

Configures thing management behavior

config/facs/net.config.json

Configures RPC server and network access. Structure varies by repository

config/facs/store.config.json

Configures Hyperbee persistent storage. This facility typically requires no additional configuration

Worker implementation files

File
Purpose
Related Documentation

workers/[model].rack.[device].wrk.js

The main worker class implementing device-specific logic

workers/lib/base.js

Base class for device interactions

workers/lib/alerts.js

Alert definitions for the device type

workers/lib/constants.js

Worker constants and configuration values

workers/lib/stats.js

Statistics collection and aggregation logic

workers/lib/utils.js

Utility functions shared across the worker


Contributor Guide

General Documentation

Operator Manual

Last updated