refactor: migrate to Bun-workspaces monorepo + ship Discord Embedded Activity, coins economy & web admin - #3
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-architecture→main. ~960 files touched.Architecture
apps/(bot,api,activity,dashboard) and sharedlibs/(core,database,types,sdk,config,constants,utils,logger,cache,events,shared). Path aliases repointed; single rootbun.lock.libs/constantsBRANCH_CONFIG is now the single source for per-branch role /punishment IDs and branding (removes hardcoded IDs across commands).
Features
via nginx; OAuth token exchange handled by the new
apps/api./coinscommand,leaderboard category,
Coin/CoinSettingsmodels + repositories.customization (color/banner/bio/badges) and user settings, backed by 12 new API routes.
/helpcommands and a shared help/usage builder derivedfrom each command's own schema.
Deployment
docker-compose, or the VPS.env.deploy.ymlbuilds and rolls out three images in sequence:robtic-api→robtic-activity→robtic-system(bot).Verification
bun install --frozen-lockfile— no changes (no new deps).tsc --noEmitpasses for the root workspace and the activity app(the activity Docker build gates on typecheck).
.env.example; no new secrets/keys.apps/api/src/index.ts.