Self-hosted chess tutor that blends relational data (PostgreSQL) with vector search (Qdrant) to answer natural-language questions about ~4k annotated games. OCaml powers ingestion, hybrid retrieval, and CLI tooling.
- PostgreSQL client (
psql) available on thePATHfor running migrations and database writes. curl(used by the embedding worker to call the OpenAI API).
- Hybrid search: combine OpenAI FEN embeddings with keyword filters for precise tactics or opening questions.
- Structured metadata: Postgres schema stores games, players, positions, and annotations with ECO tags and ratings.
- CLI-first UX:
chessmate ingestfor PGN ingestion,chessmate queryto explore positions via natural language. - Extensible architecture: modular OCaml library (core/storage/embedding/query) plus an embedding worker scaffold for background vector sync.
- PGN → FEN tooling:
dune exec pgn_to_fen -- <game.pgn>prints the FEN after every half-move for quick analysis.
- Clone and enter the repository.
- Create an opam switch and install dependencies:
opam switch create . 5.1.0 opam install . --deps-only --with-test
- Launch backing services (Postgres, Qdrant) via Docker:
docker-compose up -d postgres qdrant
- Build and run tests:
dune build dune test - Try the CLI stubs and worker loop:
dune exec chessmate -- ingest fixtures/sample.pgn dune exec chessmate -- query "Find games with a queenside majority attack" OPENAI_API_KEY=dummy DATABASE_URL=postgres://... dune exec embedding_worker dune exec pgn_to_fen -- test/fixtures/sample_game.pgn
lib/ # Core OCaml libraries (core, storage, embedding, query, cli)
bin/ # CLI entry points
scripts/ # Database migrations (`migrate.sh`, `migrations/`, seeds)
services/ # Long-running services (e.g., embedding_worker)
docs/ # Architecture, developer, ops, and planning docs
test/ # Alcotest suites
data/ # Bind-mounted volumes for Postgres and Qdrant
- Implementation Plan
- Architecture Overview
- Developer Handbook
- Operations Playbook
- Collaboration Guidelines
PRs welcome! See Collaboration Guidelines for coding standards, testing expectations, and PR checklist. Please open an issue before large changes and include dune build && dune test output in your PR template.
Distributed under the MIT License.