Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI / Deploy to GitHub Pages

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
# ── Validate ─────────────────────────────────────────────────
validate:
name: Validate HTML & JS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install validators
run: npm install -g html-validate

- name: Validate HTML
run: html-validate index.html

# ── Deploy (only on push to main) ────────────────────────────
deploy:
name: Deploy to GitHub Pages
needs: validate
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

permissions:
contents: read
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure GitHub Pages
uses: actions/configure-pages@v4

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
# Deploy everything in the repo root
path: '.'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dependencies installed locally (vendored copy in /vendor is committed)
node_modules/
package-lock.json

# OS artefacts
.DS_Store
Thumbs.db

# Editor / IDE
.vscode/
.idea/
*.swp
*.swo

# Logs
*.log
8 changes: 8 additions & 0 deletions .htmlvalidate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["html-validate:recommended"],
"rules": {
"no-inline-style": "off",
"svg-focusable": "off",
"long-title": "off"
}
}
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
# SQL_Chess
# ♟ SQL Chess

> Play chess — and watch every move translated into real SQL queries in real time.

[![Deploy to GitHub Pages](https://github.com/Devn913/SQL_Chess/actions/workflows/deploy.yml/badge.svg)](https://github.com/Devn913/SQL_Chess/actions/workflows/deploy.yml)

**Live demo:** https://devn913.github.io/SQL_Chess/

---

## Features

| Feature | Details |
|---|---|
| ♟ **Fully playable chess** | All rules enforced via [chess.js](https://github.com/jhlywa/chess.js) — en passant, castling, pawn promotion, check/checkmate/stalemate |
| ⬡ **SQL Panel** | Every move generates real `INSERT`, `UPDATE`, `DELETE` SQL statements with syntax highlighting |
| □ **Toggle SQL** | Hide the SQL panel to play as a traditional chess board |
| 👤 **Guest mode** | No login required — just open the page and play |
| ⇗ **Invite link** | Click "Invite" to generate a shareable URL that encodes the full game state — anyone who opens it continues the same game |
| ⇅ **Flip board** | Swap perspective between white and black |
| ↩ **Undo** | Take back the last move |

## How the SQL works

Each game gets its own `game_id`. Three tables are used:

```sql
chess_game -- one row per game (id, players, status, winner)
chess_piece -- one row per piece (position updated on every move)
chess_move -- one row per move (full audit log)
```

Example — white pawn e2 → e4:

```sql
INSERT INTO chess_move (game_id, move_number, color, piece_type, from_square, to_square, san)
VALUES ('a1b2-c3d4-e5f6-g7h8', 1, 'white', 'pawn', 'e2', 'e4', 'e4');

UPDATE chess_piece
SET position = 'e4'
WHERE game_id = 'a1b2-c3d4-e5f6-g7h8'
AND position = 'e2'
AND color = 'white';
```

## CI/CD

The repository uses **GitHub Actions** (`.github/workflows/deploy.yml`):

1. **Validate** — runs `html-validate` on every push/PR to `main`
2. **Deploy** — automatically publishes the site to **GitHub Pages** on every push to `main`

## Local development

No build step required — it's a plain HTML/CSS/JS site.

```bash
# Clone and open
git clone https://github.com/Devn913/SQL_Chess.git
cd SQL_Chess
# Open index.html in your browser, or serve with any static server:
npx serve .
```

## License

[MIT](LICENSE)
Loading
Loading