4.3 KiB
4.3 KiB
AGENTS.md
Runtime And Workspace
- Use Node 22+ and pnpm 11;
packageManagerpinspnpm@11.5.2. - This is a pnpm workspace:
apps/apiis NestJS/Prisma,apps/playeris Vue H5 on:5173,apps/adminis the unified platform-admin + agent Vue app on:5174, andpackages/sharedholds shared types/constants pluspublicassets. - The frontends alias
@thebet365/sharedtopackages/shared/src/index.tsbecause the built shared package is CommonJS; update shared source exports, not onlydist. packages/sharedbuild runsscripts/generate-phone-countries.mjsbeforetsc.
Local Setup
- Start local infrastructure with
docker compose up -d; this exposes PostgreSQL on5432and Redis on6379. - Copy env for the API as
cp .env.example apps/api/.env; Nest reads.envfrom the API working directory when run via the workspace filter. - First database setup from repo root:
pnpm db:generate, thenpnpm db:migrate, thenpnpm db:seed. pnpm dev:apirunsscripts/ensure-port-free.mjs 3000and will kill any listener on port3000before starting Nest watch.- If starting apps separately, start API before
pnpm dev:playerorpnpm dev:admin; both Vite servers proxy/apitohttp://localhost:3000.
Commands
pnpm devbuilds shared once, then runs all workspacedevscripts in parallel.pnpm dev:adminandpnpm dev:manageare the same admin app.- Full verification is
pnpm buildandpnpm test; there is no root lint or formatter script in current manifests. - API tests:
pnpm --filter @thebet365/api test. - Focused API Jest test:
pnpm --filter @thebet365/api exec jest settlement-calculator.spec.ts --runInBand; avoidpnpm ... test -- ...for focused args because pnpm passes the literal--through to Jest here. - Frontend typecheck/build:
pnpm --filter @thebet365/player buildandpnpm --filter @thebet365/admin build. - Admin bundle report:
pnpm --filter @thebet365/admin build:analyze.
API Notes
- API URLs use the global
/apiprefix; Swagger is at/api/docsin non-production or whenENABLE_SWAGGERis truthy. AppModuleinstalls a globalJwtAuthGuard; public endpoints must use@Public()fromapps/api/src/shared/common/decorators.ts.- Keep business rules in
apps/api/src/domains/*;apps/api/src/applications/{player,admin,agent}should stay as portal/controller orchestration. - Wallet changes should go through ledger/wallet services; UAT docs explicitly forbid direct balance edits for settlement fixes.
- After editing
apps/api/prisma/schema.prisma, runpnpm db:generate; usepnpm db:migratefor dev migrations andpnpm db:migrate:deployfor deployment.
Frontend Notes
- Edit
.tsand.vuesources inapps/player/srcandapps/admin/src; many.jssiblings exist undersrc, but bothindex.htmlfiles load/src/main.tsand Vite resolution prefers TS before JS. - Admin is one app for both
ADMINandAGENTaccounts; route/menu gating is inapps/admin/src/router/index.tsandapps/admin/src/stores/auth.ts. - Player is mobile-first; performance expectations and required mobile paths are in
docs/player-mobile-performance.md.
Tests And Smoke Checks
- Jest specs live under
apps/api/src/**/*.spec.tswithrootDir: src; the documented unit/regression suite is rule-oriented and does not require a live DB. - DB-backed smoke tests are exposed in the admin UI under
smoke-tests;SmokeTestServiceallows them outside production, or in production only withALLOW_SMOKE_TESTS=true. - UAT regression flow is documented in
docs/UAT_CHECKLIST.md; it includes admin UI smoke tests plus manual wallet/agent-credit checks.
Deployment Gotchas
- Production compose uses
.env.docker:docker compose -f docker-compose.prod.yml --env-file .env.docker up -d --buildorpnpm docker:upafter creating.env.docker. - In production, keep
SEED_DATABASE=falseafter first seed; production seed creates onlyadminplus WC2026 sample data, while dev seed includes agent/player demo accounts. scripts/prod-init-db.shis destructive by design: it requiresCONFIRM=YES, backs up unless--skip-backup, truncates business data, then seeds production data.- Deployment packaging is
pnpm pack:deploy;pack.mjsremoves legacy shared public directories exceptflagsandplayersbefore creatingrelease/thebet365-deploy-*.zip.