Skip to content

refactor: migrate to Bun-workspaces monorepo + ship Discord Embedded Activity, coins economy & web admin - #3

Merged
robo38 merged 8 commits into
mainfrom
refactor/monorepo-architecture
Jul 24, 2026
Merged

refactor: migrate to Bun-workspaces monorepo + ship Discord Embedded Activity, coins economy & web admin#3
robo38 merged 8 commits into
mainfrom
refactor/monorepo-architecture

Conversation

@robo38

@robo38 robo38 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Overview

Restructures the codebase from a single src/ tree into a Bun-workspaces monorepo
(apps/* + libs/*) and, on top of that foundation, adds a Discord Embedded Activity
(React/Vite client + token-exchange API), a coins economy, an in-app help system, and
web-based admin/profile management.

Branch: refactor/monorepo-architecturemain. ~960 files touched.

Architecture

  • Monorepo split into apps/ (bot, api, activity, dashboard) and shared
    libs/ (core, database, types, sdk, config, constants, utils, logger,
    cache, events, shared). Path aliases repointed; single root bun.lock.
  • libs/constants BRANCH_CONFIG is now the single source for per-branch role /
    punishment IDs and branding (removes hardcoded IDs across commands).

Features

  • Discord Embedded Activity — React + Vite client with the Embedded App SDK, served
    via nginx; OAuth token exchange handled by the new apps/api.
  • Coins economy — per-guild coins earned from messages/combo/streak, /coins command,
    leaderboard category, Coin / CoinSettings models + repositories.
  • Web admin & profiles — server/bot/staff admin sections, project submission, profile
    customization (color/banner/bio/badges) and user settings, backed by 12 new API routes.
  • Help system — per-branch /help commands and a shared help/usage builder derived
    from each command's own schema.

Deployment

  • CI/CD unchanged — no edits required to the self-hosted runner, GHCR, Docker images,
    docker-compose, or the VPS .env.
  • deploy.yml builds and rolls out three images in sequence:
    robtic-apirobtic-activityrobtic-system (bot).

Verification

  • bun install --frozen-lockfile — no changes (no new deps).
  • tsc --noEmit passes for the root workspace and the activity app
    (the activity Docker build gates on typecheck).
  • ✅ All env vars used are already in .env.example; no new secrets/keys.
  • ✅ All 12 new API routes registered in apps/api/src/index.ts.

robo38 and others added 8 commits July 21, 2026 19:25
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Move src/bot + entrypoint to apps/bot/src (git mv, history preserved)
- Split src/core -> libs/core, src/database -> libs/database, src/types -> libs/types
- Move monitor/ -> scripts/monitor and repoint its relative imports
- Root tsconfig aliases now target the new locations; imports unchanged
- ClientManager bot-modules root is injected by the app entrypoint instead of a relative hop
- Scaffold apps/activity (React/Vite/Discord SDK structure), apps/dashboard, apps/api
- Scaffold libs/sdk, config, constants, utils, logger, cache, events, shared
- Update Dockerfile for workspace layout; scripts run from repo root (cwd-relative assets preserved)
- Add docs set: architecture, folder-structure, coding-style, contributing, deployment,
  development, roadmap, sdk/* (auth, activity, communication, websocket), api/, database/, bot/

No behavior changes: typecheck clean, build green, smoke boot verified.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ken exchange api)

- libs/sdk: createDiscordSdk singleton + authenticateUser flow (ready -> authorize ->
  backend token exchange -> authenticate) over @discord/embedded-app-sdk
- apps/activity: React + Vite starter using the sdk via useDiscordAuth hook;
  /.proxy dev proxy mirrors Discord's production proxy; env from repo root
- apps/api: Bun.serve with POST /api/token (OAuth2 code exchange, secret stays
  server-side) and /api/health
- .env.example: VITE_DISCORD_CLIENT_ID, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET, API_PORT
- root scripts: dev:activity, dev:api; apps/api + libs/sdk now in root typecheck
- docs/sdk/getting-started.md updated to the implemented flow

Validated: root typecheck clean, activity tsc+vite build green, api endpoints smoke-tested.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- apps/api/Dockerfile: Bun runtime image for the token-exchange API
- apps/activity/Dockerfile: vite build (VITE_DISCORD_CLIENT_ID build arg) -> nginx static
  image; nginx proxies /api/* to robtic-api over the compose network
- docker-compose.yml: robtic-api (127.0.0.1:3001) and robtic-activity (127.0.0.1:8080)
  services next to robtic-system, same server env file
- deploy.yml: three chained jobs on the shared robtic-actions workflow; api/activity
  scope compose pull/up to their own service, bot job finishes with the full compose run
- .dockerignore: exclude nested **/node_modules and **/dist (bun installs per-workspace
  node_modules; copying host installs broke the image build)
- docs/deployment.md rewritten for the multi-image topology and required config

Validated locally: all three images build; activity+api containers smoke-tested on a
shared network (static serve, nginx /api proxy, token route reaching Discord).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Comment thread apps/bot/src/dev/components/project-share-submit.ts Dismissed
@robo38
robo38 merged commit f464828 into main Jul 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants