MCPcopy Index your code
hub / github.com/Drarig29/brackets-manager.js

github.com/Drarig29/brackets-manager.js @v1.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.11.0 ↗ · + Follow
306 symbols 678 edges 28 files 143 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

brackets-manager.js

npm Downloads Package Quality

A simple library to manage tournament brackets (round-robin, single elimination, double elimination).

It contains all the logic needed to manage tournaments.

Features

  • BYE supported: only during creation (for seeding and balancing).
  • Forfeit supported: only during updates.
  • Match supported (locked, waiting, ready, running, completed, archived).
  • Multiple stages per tournament.
  • So you can first have a round-robin stage (which will give you a seeding), then an elimination stage.

Interface

  • This library doesn't come with a GUI to create and update tournaments.
  • You can use brackets-viewer.js to display the current state of a stage.
  • It is designed to be used with any type of storage (JSON, in-memory, SQL, Redis, and more).
  • Some storage implementations are already available (see the documentation).

Getting Started

For more information, see the documentation.

const { JsonDatabase } = require('brackets-json-db');
const { BracketsManager } = require('brackets-manager');

const storage = new JsonDatabase();
const manager = new BracketsManager(storage);

// Create an elimination stage for tournament `3`.
await manager.create.stage({
  tournamentId: 3,
  name: 'Elimination stage',
  type: 'double_elimination',
  seeding: ['Team 1', 'Team 2', 'Team 3', 'Team 4'],
  settings: { grandFinal: 'double' },
});

await manager.update.match({
  id: 0, // First match of winner bracket (round 1)
  opponent1: { score: 16, result: 'win' },
  opponent2: { score: 12 },
});

The manager emits events when storage mutation operations succeed:

manager.on('entity.changed', event => {
  // Any successful insert, update or delete operation.
});

Rendered with the viewer:

image

As you can see, the manager is composed of submodules, which themselves have methods: - create module: manager.create.stage() - get module: manager.get.seeding(), manager.get.finalStandings(), ... - update module: manager.update.match(), manager.update.confirmSeeding(), ... - reset module: manager.reset.seeding(), manager.reset.matchGame(), ... - delete module: manager.delete.stage() - find module: manager.find.match(), manager.find.nextMatches(), ... - storage module: this gives you access to the abstract storage interface. Use it as a last resort.

You can navigate the API documentation here: BracketsManager class documentation

All the helpers defined by the library are available here:

const { helpers } = require('brackets-manager');

Credits

This library has been created to be used by the Nantarena.

It has been inspired by:

Extension points exported contracts — how you extend this code

CallableCreate (Interface)
(no doc)
src/manager.ts
ChildGameResults (Interface)
(no doc)
src/types.ts
BracketsManager (Interface)
(no doc)
src/manager.ts
MatchGameCancellationOptions (Interface)
(no doc)
src/types.ts
ParitySplit (Interface)
(no doc)
src/types.ts
EntityChangedEvent (Interface)
(no doc)
src/types.ts
FinalStandingsItem (Interface)
(no doc)
src/types.ts

Core symbols most depended-on inside this repo

match
called by 173
src/find.ts
stage
called by 159
src/create.ts
matchGame
called by 88
src/find.ts
seeding
called by 42
src/get.ts
nextMatches
called by 20
src/find.ts
matchChildCount
called by 17
src/update.ts
selectFirst
called by 17
src/types.ts
previousMatches
called by 16
src/find.ts

Shape

Method 142
Function 133
Class 20
Interface 11

Languages

TypeScript100%

Modules by API surface

src/helpers.ts121 symbols
src/base/stage/creator.ts39 symbols
src/base/getter.ts38 symbols
src/get.ts22 symbols
src/update.ts17 symbols
src/base/updater.ts16 symbols
src/manager.ts12 symbols
src/types.ts11 symbols
src/find.ts10 symbols
src/reset.ts5 symbols
src/delete.ts5 symbols
src/create.ts4 symbols

For agents

$ claude mcp add brackets-manager.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact