Skip to content

osse101/BrandishBot_Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,385 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BrandishBot_Go

A high-performance game engine API for BrandishBot, built with Go. Provides inventory management, crafting, economy, and statistics tracking for live chatroom gaming experiences.

Features

Discord Bot πŸ€–

BrandishBot includes a native Discord bot with 21 slash commands providing complete feature access directly in Discord!

Quick Start (Discord)

  1. Configure (add to .env):
DISCORD_TOKEN=your_bot_token
DISCORD_APP_ID=your_app_id
API_URL=http://localhost:8080
  1. Start Discord Bot:
# Local development
make build
make discord-run

# Docker (with core API)
make docker-up
  1. Use Commands:
  • /info - Get started
  • /profile - View your profile
  • /search - Find items
  • /inventory - See your items
  • /help for more!

Discord Commands

Economy: /buy, /sell, /prices, /give
Inventory: /inventory, /search, /use
Crafting: /upgrade, /disassemble, /recipes
Expeditions: /explore, /expedition-journal Quests: /quests, /claimquest Farming: /harvest Jobs: /job-progress Linking: /link, /unlink Gambling: /gamble, /join-gamble
Stats: /stats, /leaderboard
Progression: /vote
Admin: /add-item, /remove-item

See /info commands in Discord for full details.

Admin Dashboard πŸ–₯️

BrandishBot includes a web-based admin dashboard for system monitoring and administration.

Access: http://localhost:8080/admin/ (or your configured port)

Features

  • Health Monitoring: Real-time server status, metrics, and performance stats
  • Admin Commands: GUI for progression management, job XP, cache control, and scenarios
  • Live Events: Real-time SSE event stream with filtering
  • User Management: Search users, view profiles, manage inventory and XP

Quick Start (Admin Dashboard)

  1. Build the dashboard:
make admin-build    # Build React frontend
make build          # Build Go binary with embedded dashboard
  1. Run the server:
./bin/app
# Dashboard available at http://localhost:8080/admin/
  1. Login: Use your API_KEY from .env

πŸ“– Full Documentation: See docs/features/ADMIN_DASHBOARD_USAGE.md for detailed usage, configuration, and extensibility guide.

Quick Start

Prerequisites

  • Go 1.24+
  • PostgreSQL 15+
  • Docker & Docker Compose (recommended)

Setup

  1. Clone and configure:
cp .env.example .env
# Edit .env with your database credentials
  1. Start database:
make docker-up
  1. Run migrations:
make migrate-up
  1. Start the server:
make run
# Server will start on http://localhost:8080
  1. View API documentation: Visit http://localhost:8080/swagger/index.html

Development

The project uses a centralized cmd/devtool utility for development tasks. Most make commands delegate to this tool. See Devtool Documentation for detailed usage.

Makefile Commands

Migrations:

  • make migrate-up - Run all pending migrations
  • make migrate-down - Rollback last migration
  • make migrate-status - Show migration status
  • make migrate-create NAME=<name> - Create new migration

Development:

  • make test - Run tests with coverage
  • make unit - Run unit tests (fast)
  • make test-coverage - Generate HTML coverage report
  • make build - Build all binaries
  • make swagger - Regenerate Swagger docs

Discord Bot:

  • make discord-run - Run Discord bot locally
  • make discord-logs - View Discord logs (Docker)
  • make docker-discord-build - Build Discord image
  • make docker-discord-up - Start Discord service
  • make docker-discord-restart - Restart Discord bot

Docker:

  • make docker-up - Start services
  • make docker-down - Stop services
  • make docker-logs - View logs

Project Structure

β”œβ”€β”€ cmd/              # Entry points
β”‚   β”œβ”€β”€ app/         # Main application
β”‚   β”œβ”€β”€ discord/     # Discord bot entry point
β”‚   β”œβ”€β”€ setup/       # Database setup
β”‚   β”œβ”€β”€ reset/       # Database reset utility
β”‚   └── debug/       # Debug tools
β”œβ”€β”€ internal/        # Application code
β”‚   β”œβ”€β”€ handler/     # HTTP handlers
β”‚   β”œβ”€β”€ domain/      # Domain models
β”‚   β”œβ”€β”€ repository/  # Database interfaces
β”‚   β”œβ”€β”€ database/    # SQLC and Postgres implementation
β”‚   β”œβ”€β”€ user/        # User service
β”‚   β”œβ”€β”€ economy/     # Economy service
β”‚   β”œβ”€β”€ crafting/    # Crafting service
β”‚   β”œβ”€β”€ harvest/     # Harvest (Farming) service
β”‚   β”œβ”€β”€ progression/ # Progression tree service
β”‚   β”œβ”€β”€ gamble/      # Gambling & Lootbox service
β”‚   β”œβ”€β”€ job/         # Job & XP service
β”‚   β”œβ”€β”€ stats/       # Statistics service
β”‚   β”œβ”€β”€ discord/     # Discord bot implementation
β”‚   └── cooldown/    # Cooldown service
β”œβ”€β”€ migrations/      # SQL migrations
β”‚   └── archive/     # Pre-v1 development migrations
β”œβ”€β”€ web/
β”‚   └── admin/       # Admin Dashboard (React)
└── docs/            # Documentation & Swagger

API Endpoints

Health

  • GET /healthz - Liveness check
  • GET /readyz - Readiness check (DB connectivity)

User

  • POST /user/register - Register user
  • GET /user/inventory - Get inventory
  • POST /user/item/add - Add item
  • POST /user/item/use - Use item

Crafting

  • POST /user/item/upgrade - Upgrade item
  • POST /user/item/disassemble - Disassemble item
  • GET /recipes - Get crafting recipes

Economy

  • POST /user/item/buy - Buy item
  • POST /user/item/sell - Sell item
  • GET /prices - Get market prices

Stats

  • POST /stats/event - Record event
  • GET /stats/user - Get user stats
  • GET /stats/leaderboard - Get leaderboard

See /swagger/ for complete API documentation with request/response examples.

Testing

For detailed guidance, see Test Guidance and Running Tests.

# Run all tests
make test

# Generate coverage report
make test-coverage
# Open coverage.html in browser

Event System

BrandishBot uses an asynchronous event-driven architecture for decoupled, reliable service communication:

πŸ“š Documentation:

Key Features:

  • πŸ”„ Automatic retry with exponential backoff (2s β†’ 4s β†’ 8s β†’ 16s β†’ 32s)
  • πŸ“ Dead-letter logging for permanently failed events
  • 🚫 Fire-and-forget: Domain operations never fail due to event errors
  • πŸ“Š Used for stats, notifications, audit logging, and cross-service communication

Contributing

See AGENTS.md for development guidelines and architecture details.

License

MIT License

About

Chat Bot Backend in Go

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors