|
| 1 | +# Contributing to ChessEngine |
| 2 | + |
| 3 | +Thank you for your interest in contributing to ChessEngine! This document provides guidelines for contributing to the project. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- **Java 17 or higher** - For backend development |
| 10 | +- **Node.js 18+** - For frontend development |
| 11 | +- **Git** - For version control |
| 12 | +- **Docker** (optional) - For containerized development |
| 13 | + |
| 14 | +### Development Setup |
| 15 | + |
| 16 | +1. **Fork and clone the repository** |
| 17 | + ```bash |
| 18 | + git clone https://github.com/<your-username>/ChessEngine.git |
| 19 | + cd ChessEngine |
| 20 | + ``` |
| 21 | + |
| 22 | +2. **Backend setup** |
| 23 | + ```bash |
| 24 | + cd backend |
| 25 | + ./gradlew build |
| 26 | + ./gradlew bootRun |
| 27 | + ``` |
| 28 | + Backend will run on `http://localhost:8080` |
| 29 | + |
| 30 | +3. **Frontend setup** |
| 31 | + ```bash |
| 32 | + cd frontend |
| 33 | + npm install |
| 34 | + npm run dev |
| 35 | + ``` |
| 36 | + Frontend will run on `http://localhost:3000` |
| 37 | + |
| 38 | +### Using Make Commands |
| 39 | + |
| 40 | +The project includes a Makefile for common tasks: |
| 41 | + |
| 42 | +```bash |
| 43 | +make dev # Run backend + frontend locally |
| 44 | +make test # Run all tests |
| 45 | +make docker-up # Start with Docker Compose |
| 46 | +make docker-down # Stop Docker services |
| 47 | +``` |
| 48 | + |
| 49 | +## Development Workflow |
| 50 | + |
| 51 | +### 1. Create a Feature Branch |
| 52 | + |
| 53 | +```bash |
| 54 | +git checkout -b feature/your-feature-name |
| 55 | +``` |
| 56 | + |
| 57 | +Use descriptive branch names: |
| 58 | +- `feature/` - New features |
| 59 | +- `fix/` - Bug fixes |
| 60 | +- `docs/` - Documentation updates |
| 61 | +- `test/` - Test additions or improvements |
| 62 | +- `refactor/` - Code refactoring |
| 63 | + |
| 64 | +### 2. Make Your Changes |
| 65 | + |
| 66 | +- Follow existing code style and conventions |
| 67 | +- Write clear, descriptive commit messages |
| 68 | +- Keep commits focused and atomic |
| 69 | +- Add tests for new functionality |
| 70 | +- Update documentation as needed |
| 71 | + |
| 72 | +### 3. Test Your Changes |
| 73 | + |
| 74 | +**Backend:** |
| 75 | +```bash |
| 76 | +cd backend |
| 77 | +./gradlew test |
| 78 | +``` |
| 79 | + |
| 80 | +**Frontend:** |
| 81 | +```bash |
| 82 | +cd frontend |
| 83 | +npm run lint |
| 84 | +npm test |
| 85 | +npm run build |
| 86 | +``` |
| 87 | + |
| 88 | +**All tests:** |
| 89 | +```bash |
| 90 | +make test |
| 91 | +``` |
| 92 | + |
| 93 | +### 4. Commit Your Changes |
| 94 | + |
| 95 | +Follow conventional commit format: |
| 96 | +``` |
| 97 | +<type>(<scope>): <subject> |
| 98 | +
|
| 99 | +<body> |
| 100 | +
|
| 101 | +<footer> |
| 102 | +``` |
| 103 | + |
| 104 | +Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore` |
| 105 | + |
| 106 | +Examples: |
| 107 | +``` |
| 108 | +feat(backend): add stalemate detection |
| 109 | +fix(frontend): correct piece highlighting bug |
| 110 | +docs(readme): update Docker instructions |
| 111 | +test(chess): add castling validation tests |
| 112 | +``` |
| 113 | + |
| 114 | +### 5. Push and Create Pull Request |
| 115 | + |
| 116 | +```bash |
| 117 | +git push origin feature/your-feature-name |
| 118 | +``` |
| 119 | + |
| 120 | +Then create a Pull Request on GitHub with: |
| 121 | +- Clear title describing the change |
| 122 | +- Description of what changed and why |
| 123 | +- Steps to test the changes |
| 124 | +- Screenshots (for UI changes) |
| 125 | +- Link to related issues |
| 126 | + |
| 127 | +## Code Style Guidelines |
| 128 | + |
| 129 | +### Backend (Java) |
| 130 | + |
| 131 | +- Follow standard Java naming conventions |
| 132 | +- Use meaningful variable and method names |
| 133 | +- Document complex logic with comments |
| 134 | +- Keep methods focused and under 50 lines when possible |
| 135 | +- Write unit tests for new functionality |
| 136 | + |
| 137 | +### Frontend (TypeScript/React) |
| 138 | + |
| 139 | +- Use TypeScript for type safety |
| 140 | +- Follow Next.js and React best practices |
| 141 | +- Use functional components and hooks |
| 142 | +- Keep components focused and reusable |
| 143 | +- Use meaningful prop and state names |
| 144 | +- Follow ESLint rules: `npm run lint` |
| 145 | + |
| 146 | +## Testing Guidelines |
| 147 | + |
| 148 | +### Backend Tests |
| 149 | + |
| 150 | +- Place tests in `backend/src/test/java/` |
| 151 | +- Use JUnit 5 for test framework |
| 152 | +- Name tests descriptively: `testFeatureUnderSpecificCondition` |
| 153 | +- Test edge cases and error conditions |
| 154 | +- Aim for meaningful test coverage |
| 155 | + |
| 156 | +### Frontend Tests |
| 157 | + |
| 158 | +- Place tests next to components: `*.test.tsx` |
| 159 | +- Use Jest and React Testing Library |
| 160 | +- Test user interactions and component behavior |
| 161 | +- Mock external dependencies (API calls) |
| 162 | +- Focus on behavior, not implementation |
| 163 | + |
| 164 | +## What We're Looking For |
| 165 | + |
| 166 | +### Good Contributions |
| 167 | + |
| 168 | +✅ **Bug fixes** - Especially with test cases |
| 169 | +✅ **Test additions** - Improve code coverage |
| 170 | +✅ **Documentation improvements** - Clearer explanations |
| 171 | +✅ **Performance improvements** - With benchmarks |
| 172 | +✅ **Chess rule correctness** - Edge case handling |
| 173 | +✅ **UI/UX enhancements** - Better user experience |
| 174 | + |
| 175 | +### Contributions We Won't Accept |
| 176 | + |
| 177 | +❌ **Database additions** - Keep it in-memory by design |
| 178 | +❌ **Authentication systems** - Out of scope |
| 179 | +❌ **AI opponents** - Future feature, not ready yet |
| 180 | +❌ **Online multiplayer** - Out of scope |
| 181 | +❌ **Major architectural changes** - Discuss first |
| 182 | + |
| 183 | +## Known Limitations (As Designed) |
| 184 | + |
| 185 | +These are **intentional design choices**, not bugs: |
| 186 | + |
| 187 | +- **In-memory game state** - No persistence between restarts |
| 188 | +- **Single game instance** - One game per server |
| 189 | +- **No draw detection** - Stalemate not implemented |
| 190 | +- **No move history export** - No PGN/FEN support |
| 191 | +- **Local only** - No production deployment |
| 192 | + |
| 193 | +If you want to address these, please open an issue first to discuss. |
| 194 | + |
| 195 | +## Pull Request Process |
| 196 | + |
| 197 | +1. **Ensure CI passes** - All tests must pass |
| 198 | +2. **Update documentation** - If behavior changes |
| 199 | +3. **Add tests** - For new features |
| 200 | +4. **Keep PRs focused** - One feature/fix per PR |
| 201 | +5. **Respond to feedback** - Be open to suggestions |
| 202 | +6. **Be patient** - Reviews may take a few days |
| 203 | + |
| 204 | +## Getting Help |
| 205 | + |
| 206 | +- **Issues** - Check existing issues or open a new one |
| 207 | +- **Discussions** - For questions and ideas |
| 208 | +- **Documentation** - Read README.md thoroughly |
| 209 | + |
| 210 | +## Code of Conduct |
| 211 | + |
| 212 | +- Be respectful and professional |
| 213 | +- Welcome newcomers and help them learn |
| 214 | +- Focus on constructive feedback |
| 215 | +- Keep discussions on-topic |
| 216 | + |
| 217 | +## Recognition |
| 218 | + |
| 219 | +Contributors will be: |
| 220 | +- Acknowledged in release notes |
| 221 | +- Listed in GitHub contributors |
| 222 | +- Thanked in the community |
| 223 | + |
| 224 | +Thank you for contributing! 🎉 |
0 commit comments