Instruction file imported from Badminton-Apps/badman (
.github/instructions/structure.instructions.md). Copyright stays with the author.
GitHub Copilot Instructions for Badman Project
AGENTS.md in the repository root is the single source of truth for AI-assisted development in this repo. This file is a short orientation; when the two disagree, AGENTS.md wins.
Project Overview
Badman is a comprehensive badminton management system built with NestJS and TypeScript in a Turborepo monorepo. The application handles player management, tournament organization, ranking systems, and club administration.
This repository is backend-only — the frontend lives in a separate repository. Do not add frontend code here.
Architecture & Technologies
- Monorepo: Turborepo over pnpm workspaces
- Backend: NestJS with a code-first Apollo GraphQL API (Fastify adapter)
- Database: PostgreSQL with Sequelize ORM (
sequelize-typescript) - Queues: Bull on Redis
- Cache: Redis
- Testing: Jest, per-package config with a shared
jest.preset.js - Build Tools:
nest buildfor apps,tscfor packages
Key Directory Structure
Applications (apps/)
apps/api/- GraphQL API server and business logic (serves at localhost:5010)apps/worker/sync/- Federation data sync workerapps/worker/ranking/- Ranking recalculation workerapps/worker/belgium/flanders/{places,points}/- Regional workersapps/scripts/- One-off operational scripts
Packages (packages/)
Compiled internal libraries. tsc emits to <pkg>/dist and consumers resolve through the package exports map.
- Core:
backend-authorization/,backend-database/,backend-graphql/,backend-cache/,backend-queue/ - Business:
backend-competition/{assembly,change-encounter,encounter-games,enrollment,transfer-loans}/,backend-ranking/,backend-notifications/,backend-mailing/ - Integrations:
backend-twizzit/,backend-visual/,backend-belgium/flanders/{games,places,points}/ - Utils:
utils/,backend-utils/,backend-search/,backend-translate/,backend-validation/,backend-websockets/
Other Important Directories
database/- Migrations, config, seedersmails/- HTML email templatesscripts/- Build and deployment scriptsspecs/- Feature specificationstypes/- Global TypeScript definitions
Development Guidelines
File Creation Patterns
- Backend Services: Place in the relevant domain package under
packages/ - Resolvers:
packages/backend-graphql/src/resolvers/<domain>/— one*.resolver.ts,*.module.ts,*.resolver.spec.tsper domain - Models:
packages/backend-database/— Sequelize models double as GraphQL@ObjectTypedeclarations - Shared enums and helpers:
packages/utils/ - Tests: Co-locate with source files (
foo.resolver.ts→foo.resolver.spec.ts)
Naming Conventions
- Packages follow domain-driven design (e.g.,
competition,ranking,enrollment) - Backend services use PascalCase
- Database models follow Sequelize conventions
Import Patterns
- Import packages by their alias:
@badman/backend-database,@badman/utils - To add a dependency between packages, add
"@badman/<name>": "workspace:*"to the consumer'spackage.jsonand runpnpm install. There are no tsconfig path aliases — resolution goes through each package'sexportsmap - The alias is the package's
namefield and does not always match its directory (packages/backend-competition/assemblyis@badman/backend-assembly) — check thepackage.json - Prefer barrel exports from a package's index file
Common File Types
.service.ts- NestJS services.resolver.ts- GraphQL resolvers.model.ts- Database models (Sequelize).interface.ts- TypeScript interfaces.spec.ts- Jest unit tests.integration.spec.ts- Integration tests (opt-in, skipped by default)
Key Configuration Files
turbo.json- Task pipeline, caching and task dependenciespnpm-workspace.yaml- Which directories are workspace packages- Each app/package
package.json- Its own scripts andworkspace:*dependencies tsconfig.*.json- TypeScript configsjest.preset.js+ per-packagejest.config.ts- Test configurationschema.gql- GraphQL schema
Common Commands
pnpm turbo run build --filter=<name>- Build one app or packagepnpm turbo run test --filter=<name>- Test one packagepnpm start:server- Serve the API and sync worker in watch mode
When suggesting code changes, respect the package boundaries and express cross-package dependencies through workspace:* rather than reaching into another package's source.
Fetching data
Use the graphql tool to fetch data from the GraphQL API, Always try to use the existing data structures and types defined in the project.
Only create new resolvers if we are changing the models