# steelman277/homelabmecanicsapi architecture

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

- Interactive diagram: https://gitdiagram.com/steelman277/homelabmecanicsapi
- Repository: https://github.com/steelman277/homelabmecanicsapi

## Overview

This repository implements a small Discord bot for Minecraft server interaction. Discord messages reach a handler that supports ping replies and whitelist requests; whitelist requests are validated, sent to Crafty Controller, and answered in Discord. The source also contains a log-polling path intended to announce player joins and leaves. Evidence is limited to the single source file: the polling code uses placeholder values and appears inside the message handler, so its runtime behavior may not match its apparent intent.

Main entry points: [`src/index.ts`](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts) (Message handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord bot"]
  node_client["Discord client<br/>[index.ts]"]
  node_message_handler["Message handler<br/>[index.ts]"]
end

subgraph group_whitelist["Minecraft whitelist"]
  node_crafty["Crafty Controller"]
  node_whitelist_request["Whitelist request<br/>[index.ts]"]
  node_token_lookup["Token lookup<br/>[index.ts]"]
end

subgraph group_logs["Server log announcements"]
  node_log_poller["Log poller<br/>[index.ts]"]
  node_log_channel["Discord log channel"]
end

node_user(("Discord user"))

node_user -->|"sends message"| node_client
node_client -->|"dispatches message"| node_message_handler
node_message_handler -->|"replies"| node_client
node_message_handler -->|"validates and invokes"| node_whitelist_request
node_whitelist_request -->|"extracts token"| node_token_lookup
node_whitelist_request -->|"authenticates and commands"| node_crafty
node_message_handler -->|"starts polling"| node_log_poller
node_log_poller -->|"fetches logs"| node_crafty
node_log_poller -->|"posts announcements"| node_log_channel

click node_client "https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts"
click node_message_handler "https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts"
click node_whitelist_request "https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts"
click node_token_lookup "https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts"
click node_log_poller "https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts"

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_client,node_message_handler,node_user toneBlue
class node_crafty,node_whitelist_request,node_token_lookup toneAmber
class node_log_poller,node_log_channel toneMint
```

## Components

### Discord bot

- [Discord client](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts): `src/index.ts`
- [Message handler](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts): `src/index.ts`

### Minecraft whitelist

- **Crafty Controller**
- [Whitelist request](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts): `src/index.ts`
- [Token lookup](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts): `src/index.ts`

### Server log announcements

- [Log poller](https://github.com/steelman277/homelabmecanicsapi/blob/main/src/index.ts): `src/index.ts`
- **Discord log channel**

### Other components

- **Discord user**

## Connections

- Discord user → Discord client: sends message (evidence: `src/index.ts`)
- Discord client → Message handler: dispatches message (evidence: `src/index.ts`)
- Message handler → Discord client: replies (evidence: `src/index.ts`)
- Message handler → Whitelist request: validates and invokes (evidence: `src/index.ts`)
- Whitelist request → Token lookup: extracts token (evidence: `src/index.ts`)
- Whitelist request → Crafty Controller: authenticates and commands (evidence: `src/index.ts`)
- Message handler → Log poller: starts polling (evidence: `src/index.ts`)
- Log poller → Crafty Controller: fetches logs (evidence: `src/index.ts`)
- Log poller → Discord log channel: posts announcements (evidence: `src/index.ts`)
