Relaxy!

Under the hood

Technical Breakdown

Everything technical about Relaxy! How it's built, what it is built with, and where it runs.

At a quick glance

What Relaxy! is, technically

Relaxy! is a multipurpose Discord bot first written by me in 2019. It is a pure Node.js program written in modern JavaScript (ES Modules) with JSDoc + TypeScript declaration files for type-checking. There is no build step, the bot runs directly from source. It is sharded and clustered so it can easily scale horizontally across multiple machines.

171command modules
6command categories
v1.1.0current version
2019first written
~80npm dependencies
10database models

Live from the hardware

The Pi, right now

Reading live status straight off the Pi…

connecting

Architecture

A two-process, multi-cluster model

Relaxy! runs as a supervisor that spawns and watches worker processes.

Manager

src/Manager/Manager.js. The supervisor. It never connects to Discord itself, instead it spawns Clusters, watches their heartbeats, and reclusters or respawns dead workers. Hosts the cross-process rate limiter and the console command interface.

Cluster / Client

src/Client/Relaxy.js. Each cluster is a child process running one Relaxy client that owns one or more shards. The actual gateway connections to Discord, where commands and events are handled.

IPC & heartbeats

Manager and clusters talk over Node IPC. Spawn hand-off is the CLIENT_PROCESS_SPAWNED message; liveness uses a push heartbeat (every 3s, 5 missed beats = dead) so the manager only watches for silence instead of polling.

Self-repair & hot-patch

A SelfRepair module provides hot-reloading of modules/commands and an internet watchdog; the ModuleLoader + HotPatch system loads every module from a manifest and can swap them at runtime without a restart.

Boot sequence

Technology stack

What's inside?

Grouped by what each set of libraries does.

Runtime & language

Node.js JavaScript (ESM) TypeScript (.d.ts / jsconfig) JSDoc

Discord core & sharding

discord.js 14 @discordjs/voice @discordjs/opus discord-api-types discord-hybrid-sharding discord-cross-hosting discord-cross-ratelimit discord-voip

Database

MongoDB Mongoose 8

10 schema "blueprints": Server, Member, Profile, Warning, Reminder, TicketSystem, ForumChannel, HeartBoard, HeartBoardPost and Limits, all persisted through a dedicated database worker with a local cache as well.

Music & voice

discord-player 7 @discord-player/equalizer discord-player-youtubei (SABR) discord-player-soundcloud ytdl-core youtube-sr prism-media ffmpeg-static fluent-ffmpeg genius-lyrics LrcLib (synced lyrics)

Built around a heavily customised player with its own stream interceptor, a biquad/DSP equalizer, and a voice recorder.

Images & canvas

canvas canvacord sharp discord-image-generation gifencoder gif-frames emoji-mixer google-img-scrap

Text & search

natural (NLP) fuse.js (fuzzy search) stopword normalize-text weird-to-normal-chars @iamtraction/google-translate

Web, networking & utilities

express body-parser axios node-fetch lodash fs-extra archiver chalk asciiart-logo systeminformation

Commands

171 modules across 6 categories

Default prefix =, plus slash-command support.

File structure

How the source is organised

relaxy-private/
├── start                     # launcher: ./start [--client], sets Node flags
├── index.js                  # root entry -> boots the manager
├── detect_os.js              # host detection (void / raspberry-pi / windows / linux)
├── package.json              # ESM, ~80 dependencies, no build step
├── tsconfig.json / jsconfig.json
├── bot/                      # process entry points + handlers
│   ├── Manager.js            # supervisor process entry
│   ├── Client.js             # cluster/client process entry
│   ├── commands/             # 171 commands in 6 categories
│   │   ├── administrator/  fun/  image/
│   │   └── miscellaneous/  moderation/  music/
│   └── events/               # discord/ + music/ event handlers
├── src/                      # the engine
│   ├── ModuleLoader.js  HotPatch.js  MainFrame.js  DataTable.js
│   ├── Manager/
│   │   ├── Manager.js
│   │   ├── Core/             # SelfRepair, HeartBeatManager
│   │   └── Modules/          # ClusterSpawnProcessor, ConsoleInputProcessor
│   └── Client/
│       ├── Relaxy.js         # the bot client
│       └── Modules/
│           ├── Database/     # Mongoose models (Blueprints) + Database
│           ├── MusicPlayer/  # custom player, equalizer, extractors
│           ├── VoiceRecorder/  Handlers/  Workers/
│           └── ADSR/         # active diagnosis + rate limiter
├── types/                    # 14 .d.ts type declarations
├── assets/                   # config, images, fonts, sounds, text, scripts
├── storage/                  # runtime caches (users / guilds)
└── docs/                     # STARTUP.md and other internals

Deployment

Where it runs

Relaxy! detects its host at startup (detect_os.js) and adapts. Thanks to discord-cross-hosting the shards can be spread across these machines at once.

Void PC HOST_TYPE = void

The primary host is a Void Linux desktop. Detected by reading ID=void from /etc/os-release. Carries the bulk of the clusters and shards.

Raspberry Pi HOST_TYPE = raspberry-pi

An always-on ARM board, detected via arm/arm64 architecture. Acts as a low-power node that keeps a slice of the fleet alive around the clock.

Laptop HOST_TYPE = windows / linux

A secondary / development host. Used for debugging single shards (./start --client) and to add capacity when needed.