Metadata-Version: 2.4
Name: chessdirector
Version: 2.1.0
Summary: Chess tournament management — a free open API client, and a full offline engine that needs no server at all
Author-email: Paircraft <support@paircraft.io>
License: # PolyForm Noncommercial License 1.0.0
        
        ## Acceptance
        
        As a condition to your use of this software, you will abide by the terms and conditions of this license.
        
        ## Copyright License
        
        The licensor grants you a limited, royalty-free, non-exclusive, non-transferable license to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute this software and derivative works thereof for noncommercial purposes only, subject to the restrictions in this license. "Purposes" are noncommercial when they are not intended for or directed toward commercial advantage or monetary compensation.
        
        ## Noncommercial Purposes
        
        For the purposes of this license, noncommercial use includes:
        
        - Academic research
        - Educational use
        - Personal, private, or hobby projects
        - Charitable or nonprofit organizations
        - Personal or internal business use
        
        Noncommercial use does NOT include:
        
        - Any commercial use or for-profit use
        - Providing services to third parties
        - Incorporating into a commercial product
        - Competitive product development
        
        ## Restrictions
        
        You may not:
        
        1. Use or distribute this software or derivative works for any commercial purpose without obtaining a commercial license from the licensor
        2. Remove or alter the text of this license or any copyright notices
        3. Distribute this software without including a copy of this license
        4. Hold the licensor liable for damages or claims arising from your use
        
        ## Termination
        
        This license and the rights granted hereunder will terminate automatically upon any breach of the terms of this license. Upon termination, you must immediately cease all use and distribution of this software and derivative works.
        
        ## Disclaimer of Warranties
        
        THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
        ## Commercial Licensing
        
        For commercial use of this software, you must obtain a commercial license from the licensor. Contact support@paircraft.io for licensing inquiries.
        
Project-URL: Homepage, https://paircraft.io
Project-URL: Documentation, https://paircraft.io/api/docs
Project-URL: Repository, https://github.com/chughjug/ratings
Project-URL: Bug Tracker, https://github.com/chughjug/ratings/issues
Keywords: chess,tournament,api,sdk,swiss,pairing,uscf,fide,paircraft,offline,local
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Games/Entertainment :: Board Games
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Provides-Extra: fast
Requires-Dist: numpy>=1.21; extra == "fast"
Provides-Extra: dev
Requires-Dist: numpy>=1.21; extra == "dev"
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=21.0; extra == "dev"
Requires-Dist: flake8>=3.9; extra == "dev"
Dynamic: license-file

# Chess Tournament Director

A comprehensive chess tournament management system with React frontend and Node.js backend, featuring Swiss-system pairings, player management, and tournament analytics.

## 🏆 Features

- **Tournament Management**: Create and manage chess tournaments with multiple sections
- **Swiss System Pairings**: Automated pairing algorithm with USCF compliance
- **Player Management**: Add, edit, and search players with rating lookup
- **Real-time Standings**: Live tournament standings with tiebreakers
- **Export Capabilities**: PDF reports, CSV exports, and DBF file generation
- **Responsive Design**: Modern React UI with Tailwind CSS
- **Authentication**: Secure user authentication and authorization

## 🚀 Quick Start

### Prerequisites

- Node.js (v16 or higher)
- npm or yarn
- Git

### Installation

1. **Clone the repository**
   ```bash
   git clone <repository-url>
   cd ratings
   ```

2. **Install dependencies**
   ```bash
   npm run install-all
   ```

3. **Set up environment variables**
   ```bash
   cp .env.example .env
   # Edit .env with your configuration
   ```

4. **Start the development server**
   ```bash
   npm run dev
   ```

5. **Access the application**
   - Frontend: http://localhost:3000
   - Backend API: http://localhost:5000

## 📦 Project Structure

```
ratings/
├── client/                 # React frontend application
│   ├── src/
│   │   ├── components/     # Reusable UI components
│   │   ├── pages/         # Application pages
│   │   ├── services/      # API services
│   │   └── contexts/      # React contexts
├── server/                # Node.js backend
│   ├── routes/           # API routes
│   ├── services/         # Business logic
│   ├── middleware/       # Express middleware
│   └── database.js       # Database configuration
├── uploads/              # File uploads
└── docs/                 # Documentation
```

## 🛠️ Available Scripts

- `npm run dev` - Start development server (both frontend and backend)
- `npm run client` - Start React development server
- `npm run server` - Start Node.js backend server
- `npm run build` - Build React app for production
- `npm start` - Start production server
- `npm run setup` - Create admin user

## 🌐 Deployment

### Heroku Deployment

This application is configured for easy Heroku deployment:

1. **Quick Deploy**
   ```bash
   ./deploy.sh
   ```

2. **Manual Deploy**
   - See `HEROKU_DEPLOYMENT.md` for detailed instructions
   - Or follow `QUICK_DEPLOY.md` for quick reference



### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `NODE_ENV` | Environment mode | `development` |
| `PORT` | Server port | `5000` |
| `JWT_SECRET` | JWT token secret | Required |
| `CORS_ORIGIN` | CORS allowed origins | `http://localhost:3000` |

## 🎯 Core Features

### Tournament Management
- Create tournaments with custom settings
- Manage multiple tournament sections
- Set time controls and prize structures
- Export tournament data in multiple formats

### Pairing System
- Swiss-system pairings with USCF compliance
- Automatic bye assignment
- Pairing history tracking
- Conflict resolution

### Player Management
- Add players manually or import via CSV
- USCF rating lookup integration
- Player search and filtering
- Rating history tracking

### Analytics & Reporting
- Real-time tournament standings
- Comprehensive tiebreaker calculations
- PDF report generation
- Tournament statistics

## 🔧 Technology Stack

### Frontend
- **React 18** - Modern React with hooks
- **TypeScript** - Type-safe development
- **Tailwind CSS** - Utility-first CSS framework
- **Axios** - HTTP client for API calls

### Backend
- **Node.js** - JavaScript runtime
- **Express.js** - Web application framework
- **SQLite** - Lightweight database
- **JWT** - Authentication tokens

### Additional Tools
- **Helmet** - Security middleware
- **CORS** - Cross-origin resource sharing
- **Rate Limiting** - API protection
- **Multer** - File upload handling

## 📚 Documentation

- [Heroku Deployment Guide](HEROKU_DEPLOYMENT.md)
- [Quick Deploy Instructions](QUICK_DEPLOY.md)
- [Authentication Setup](AUTHENTICATION_README.md)
- [CSV Import Guide](CSV_IMPORT_README.md)
- [Player Search Documentation](PLAYER_SEARCH_README.md)

## Python SDK: Online Tournaments

The official Paircraft SDK (`paircraft>=1.1.0`) includes helper functions for online tournaments:

```bash
pip install --upgrade paircraft
```

```python
from paircraft import ChessTournamentClient

client = ChessTournamentClient(api_key="your-api-key", base_url="https://www.paircraft.tech")

tournament = client.create_online_tournament(
    name="Online Blitz Night",
    platform="lichess",  # or "chesscom"
    rounds=3,
    section="Open"
)

player_ids = client.import_players(tournament.id, [
    {"name": "Test White", "section": "Open", "lichess": "white_handle"},
    {"name": "Test Black", "section": "Open", "lichess": "black_handle"},
])

pairings = client.pair_round(tournament.id, round=1, section="Open")
games = client.create_online_games(tournament.id, round=1, platform="lichess", section="Open")
client.start_clocks(tournament.id, round=1, section="Open")
pairings = client.poll_results(tournament.id, round=1)

if pairings:
    game = client.game_status(tournament.id, pairings[0].id, include_pgn=True)
```

Online helper methods include `create_online_tournament`, `import_players`, `pair_round`, `oauth_link`, `create_online_games`, `start_clocks`, `poll_results`, `game_status`, `set_result`, `paste_pairings`, and `validate_usernames`.

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📄 License

This project is licensed under the PolyForm Noncommercial License - see the [LICENSE](LICENSE) file for details.

**Commercial use requires a commercial license.** For licensing inquiries, contact support@paircraft.io.

## 🙏 Acknowledgments

- USCF (United States Chess Federation) for pairing rules
- Chess.com for inspiration
- The open-source community for excellent tools and libraries

## 📞 Support

For support and questions:
- Create an issue in this repository
- Check the documentation files in the root directory
- Review the code comments for implementation details

---

**Built with ❤️ for the chess community**
