# Microchess

A 4 × 5 chess app with friends, invitation links, rematches, personal avatars and SQLite storage.

The complete production application is in [`web/`](web/). Files outside that folder are for repository tooling and CI only. Start locally:

```sh
php -S 127.0.0.1:8080 -t web web/router.php
```

Localhost automatically uses a test account, including when served through Apache. See [`web/README.md`](web/README.md) for setup, OAuth configuration, rules and tests.

## GitLab CI/CD

The default branch is `master`. `.gitlab-ci.yml` runs PHP/chess/API tests, JavaScript checks and a real FTP fixture test. Only after all checks pass does it deploy `web/` using [`ci/deploy.py`](ci/deploy.py). Production deployments cannot run concurrently.

Required CI variables:

| Variable | Value |
| --- | --- |
| `timftphost` | FTP/FTPS/SFTP hostname or URL |
| `timftpuser` | Login name |
| `timftppassword` | Password; configure as masked/protected in GitLab |
| `projectftp` | Existing remote application directory, relative to the FTP login root or absolute |

The mirror preserves the entire production `data/` directory, including configuration, database, WAL, sessions and backups. Its access-denying `.htaccess` is installed separately. Test artifacts, the development router and the application README are excluded from upload. Obsolete application files outside these exclusions are removed.

TLS certificates are verified. First-time SFTP host keys use SSH's `accept-new` policy; changed keys fail. The remote directory must already exist. Configure OAuth separately in the generated `data/config.php` on production: local configuration is never committed or uploaded.

The deployment fixture can also run locally with Python 3, `pyftpdlib` and `lftp`:

```sh
python3 ci/test_deploy.py
```
