Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {}
}
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
140 changes: 85 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,120 @@
# DotablazeTech
# Dotablaze Platform Monorepo

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
[![CI](https://github.com/dotablaze-tech/platform/actions/workflows/ci.yml/badge.svg)](https://github.com/dotablaze-tech/platform/actions/workflows/ci.yml)
![Go](https://img.shields.io/badge/Go-1.24-blue)
![Nx](https://img.shields.io/badge/Nx-monorepo-blue)
![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)

✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨.
The Dotablaze Tech Platform Monorepo is a multi-language, multi-project repository that houses all application code,
reusable libraries, configuration, and tooling used across the Dotablaze ecosystem. This repository is organized to
support scalable development with a clean separation of concerns and structured sharing of features, utilities, and
infrastructure.

[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!
## 📁 Structure Overview

## Finish your CI setup
- **apps/** – Full-stack applications grouped by language or runtime (e.g., Go bots and services).
- **libs/** – Reusable code libraries organized by app, language, or shared domain:
- `feature/` – Domain-specific handlers, components, or state.
- `data-access/` – Integration with APIs or external services.
- `util/` – Common utility functions, models, and helpers.
- `ui/` – Visual or bot-rendered components (when applicable).
- **tools/** – Dev tooling for formatting, local dev, automation, and updates.

[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/kcEQrm1SNj)
## 🗂️ Directory Structure

```
.
├── apps/ # Complete applications
│ └── go/ # Grouped by framework / language
│ ├── meowbot/ # Specific application
│ └── barkbot/
├── libs/ # Reusable libraries
│ ├── go/ # Grouped by framework
│ │ ├── meowbot/ # App-specific libraries
│ │ │ ├── feature/
│ │ │ └── util/
│ │ ├── shared/ # Framework-wide shared
│ │ │ ├── ui/
│ │ │ ├── util/
│ │ │ └── data-access/
│ └── shared/ # Cross-framework shared
│ └── utils/
└── tools/ # Monorepo tooling
```

## Generate a library
### 🔑 Key Architectural Principles

```sh
npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1
```
- **Language-Scoped**: Projects and libraries are grouped by runtime (e.g., `go/`, `angular/`, etc.).
- **App Isolation**: Features unique to a specific app are namespaced under that app.
- **Shared Logic**:
- App-specific: Scoped to one app only (`libs/go/meowbot/*`).
- Framework-wide: Usable across projects using the same runtime.
- Cross-platform: Reusable by any project (e.g., `libs/shared`).
- **Library Types**:
- `feature/` – Domain-level logic or bot commands.
- `data-access/` – Service interfaces and clients.
- `util/` – Reusable helpers, emoji maps, etc.
- `ui/` – Discord message formatting or future rich UIs.

## Run tasks
## 🚀 Nx Task Execution

To build the library use:
Nx provides efficient task orchestration for builds, tests, and automation.

```sh
npx nx build pkg1
```bash
npx nx <target> <project> [options]
```

To run any task with Nx use:
**Examples:**

```sh
npx nx <target> <project-name>
```bash
npx nx build go-meowbot
npx nx test go-meowbot-feature-handler
npx nx run-many -t build -p meowbot
```

These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
See the full guide: [https://nx.dev/features/run-tasks](https://nx.dev/features/run-tasks)

[More about running tasks in the docs &raquo;](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## 🌐 Visualize Dependencies

## Versioning and releasing
Generate the project graph with:

To version and release the library use

```
npx nx release
```bash
npx nx graph
```

Pass `--dry-run` to see what would happen without actually releasing the library.
This helps you visualize app/library dependencies and identify opportunities for optimization or sharing.

[Learn more about Nx release &raquo;](hhttps://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## 📦 Deployment & Infrastructure

## Keep TypeScript project references up to date
Deployment and Kubernetes infrastructure for Dotablaze services are managed in separate repositories:

Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in `tsconfig.json` files to ensure they remain accurate based on your project dependencies (`import` or `require` statements). This sync is automatically done when running tasks such as `build` or `typecheck`, which require updated references to function correctly.
- **Deployment Configs**: [https://github.com/dotablaze-tech/deployments](https://github.com/dotablaze-tech/deployments)
- **Infra/Kubernetes (WIP)**: [https://github.com/jdwillmsen/jdw-kube](https://github.com/jdwillmsen/jdw-kube)

To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:

```sh
npx nx sync
```

You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:

```sh
npx nx sync:check
```
Container images are hosted at:

[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
- **Docker Hub**: [https://hub.docker.com/u/dotablaze](https://hub.docker.com/u/dotablaze)

## 📚 Library Strategy

[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
This monorepo encourages reuse and clean separation of concerns by organizing libraries in layers:

## Install Nx Console
- `feature/` – Commands, event handlers, and scoped state.
- `data-access/` – Service and bot integrations (coming soon).
- `util/` – Emoji helpers, string formatters, etc.
- `ui/` – For any visual rendering components.

Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
## 🧪 CI/CD & Automation

[Install Nx Console &raquo;](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
CI pipelines live in `.github/workflows/`, and use Nx to build affected projects only, improving feedback time.

## Useful links
## 📌 About

Learn more:
This repo is the central platform for building, deploying, and scaling Dotablaze Tech applications — including bots,
services, and eventually frontend dashboards. Managed with Nx and Go Workspaces for flexibility and performance.

- [Learn more about this workspace setup](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects)
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
### 👤 Maintainer

And join the Nx community:
- [Discord](https://go.nx.dev/community)
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- **Jake Willmsen**
Empty file added apps/go/meowbot/CHANGELOG.md
Empty file.
8 changes: 8 additions & 0 deletions apps/go/meowbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use a specific version of distroless based on SHA256 digest for reproducibility and security
# Using distroless for the final image to minimize attack surface and size
FROM gcr.io/distroless/base-debian12:nonroot AS runner

WORKDIR /app
COPY ./dist/apps/go/meowbot .

ENTRYPOINT ["/app/main"]
26 changes: 26 additions & 0 deletions apps/go/meowbot/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Remember to check for updates to base images to incorporate security patches
# Use a specific version of golang based on SHA256 digest for reproducibility and security
FROM golang:1.23 AS builder-go

# Use a specific version of node base on SHA256 digest for reproducibility and security
FROM node:lts-alpine AS builder
WORKDIR /app

ARG GOLANG_VERSION=1.23
COPY --from=builder-go /usr/local/go /usr/local/go
ENV PATH=$PATH:/usr/local/go/bin

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npx nx build meowbot

# Use a specific version of distroless based on SHA256 digest for reproducibility and security
# Using distroless for the final image to minimize attack surface and size
FROM gcr.io/distroless/base-debian12:nonroot AS runner

WORKDIR /app
COPY --from=builder /app/dist/apps/go/meowbot .

ENTRYPOINT ["/app/main"]
138 changes: 138 additions & 0 deletions apps/go/meowbot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# 🐾 Meow Bot

![Docker](https://img.shields.io/docker/pulls/jdwillmsen/meow-bot?label=downloads)
![Docker Image Version](https://img.shields.io/docker/v/jdwillmsen/jdw-servicediscovery)
![Docker Image Size](https://img.shields.io/docker/image-size/jdwillmsen/jdw-servicediscovery)
![Docker Downloads](https://img.shields.io/docker/pulls/jdwillmsen/jdw-servicediscovery?label=downloads)
![Nx](https://img.shields.io/badge/Nx-managed-blue)
![License](https://img.shields.io/github/license/jdwillmsen/jdw)

**Meow Bot** is a lightweight and fun Discord bot built with Go and powered by `discordgo`. It tracks consecutive “meow”
messages in a single channel, maintaining streaks, preventing duplicate users, and celebrating high scores. Ideal for
community engagement, cat lovers, and general chaos.

This project is managed with [Nx](https://nx.dev) and includes Docker support for local and CI/CD workflows.

---

## 📁 Project Structure

```
apps/go/meow-bot/
├── Dockerfile # Production image
├── Dockerfile.local # Local development Dockerfile
├── README.md # This file
├── go.mod / go.sum # Module definitions
├── main.go # Main bot entrypoint
├── main_test.go # Unit tests
└── assets/ # Bot avatars/icons
```

---

## 🚀 Getting Started

### Prerequisites

- Go 1.23+
- [Nx CLI](https://nx.dev)
- Docker (optional for containerized runs)
- Discord bot token

### Local Run (Token via ENV)

```bash
DISCORD_TOKEN=your-token-here nx run meow-bot:serve
```

### Local Dev with Volume (Docker)

```bash
nx run meow-bot:serve-cache
```

Creates a volume (`meow-bot-data`) for persistent local development (e.g., future DB use).

---

## ✨ Features

- Regex-based “meow” detection (e.g., `meooow`, `MEEEEOW`)
- Streak counter per guild
- Prevents same user from meowing twice in a row
- Tracks and announces high scores
- Slash command `/highscore` to show current record
- Guild-specific in-memory state tracking
- `slog`-based structured logging

---

## 🐳 Docker

### Build Production Image

```bash
npx nx run meow-bot:build-image
```

### Build Local Dev Image

```bash
npx nx run meow-bot:local-build-image
```

---

## 📦 Deployment

This bot is designed to run as a stateless container with ephemeral memory or backed by a persistent volume. Future
plans may include Redis or embedded DB support.

---

## 🔧 Commands

- `/highscore` – Shows the current top meow streak and who set it.

---

## 🐱 Example Interaction

```text
User1: meow
Bot: 😺 meow x1!
User2: meeeow
Bot: 😼 meow x2!
User1: meow
Bot: 😻 meow x3!
User1: meow
Bot: 😾 You can't meow twice in a row!
```

---

## 🧪 Testing

```bash
go test ./apps/go/meow-bot
```

---

## 📌 Notes

- You must set the bot token via `DISCORD_TOKEN` env var or update `main.go` to read from config.
- The bot is intended for one channel per guild.
- You can customize behavior (e.g., emojis, reset behavior) in the handler and state packages.

---

## 📷 Assets

A few example icons are included in `apps/go/meow-bot/assets/` for use when registering your bot on Discord.

---

## 📝 License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
Binary file added apps/go/meowbot/assets/bot_icon_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/go/meowbot/assets/bot_icon_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions apps/go/meowbot/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module apps/go/meowbot

go 1.23

require github.com/bwmarrin/discordgo v0.28.1

require (
github.com/gorilla/websocket v1.4.2 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
)
12 changes: 12 additions & 0 deletions apps/go/meowbot/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4=
github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Loading