How tjni/langgraph-checkpoint-mysql works
Project Type and Purpose
• This is an open-source Python library (“LangGraph Checkpoint MySQL”) that implements checkpoint saving/loading functionality on top of MySQL (or MariaDB).
• It provides both synchronous and asynchronous checkpointer implementations, mirroring the official Postgres version.
File Structure
• Top-level directories:
• langgraph/checkpoint/mysql – core checkpoint saver modules (sync + async drivers, base classes).
• langgraph/store/mysql – store modules (similar driver variants).
• tests & langgraph-tests – unit/integration test suites for sync/async behavior and edge cases.
• .github/workflows & Makefile – CI, linting, testing, and release automation.
• Key modules: pymysql.py, aio.py, asyncmy.py (driver-specific implementations), _internal.py (shared logic), base classes, utils.
README Insights
• Usage examples for synchronous (PyMySQLSaver) and asynchronous (AIOMySQLSaver / AsyncMySaver) checkpointers.
• Emphasis on a .setup() step to create tables and on passing autocommit=True.
• Dependency variants via extras (e.g., [pymysql], [aiomysql], [asyncmy]).
Main Components & Relationships
a. Components:
• Client Code (LangGraph or user application)
• Checkpointer Library
• Sync Layer: PyMySQLSaver
• Async Layer: AIOMySQLSaver / AsyncMySaver
• Shared Base & Internal Modules (_internal, utils)
• MySQL Database (or MariaDB)
• Driver Adapters: PyMySQL, aiomysql, asyncmy
• CI/CD Pipeline (GitHub Actions)
• Test Harness (pytest + Docker Compose for MySQL/MariaDB)
b. Interactions:
• Client invokes from_conn_string() → library instantiates appropriate Saver.
• Saver .setup() issues DDL statements to MySQL.
• Saver methods (put/aput, get/aget, list/alist) translate checkpoint operations into SQL queries.
• Driver adapter executes queries against the MySQL server.
• Results flow back to client in Python data structures.
c. Architectural Patterns:
• Strategy Pattern: different driver implementations (sync vs async, PyMySQL vs aiomysql vs asyncmy) share a common interface.
• Repository Pattern: Checkpointer classes encapsulate persistence logic.
• Layered Modules: separation between public API, internal shared logic, and driver-specific code.
d. Technologies & Frameworks:
• Python 3, MySQL/MariaDB ≥ required versions
• Database drivers: PyMySQL, aiomysql, asyncmy
• Testing: pytest, Docker Compose for test databases
• CI: GitHub Actions, Poetry setup
Detailed Capture of Architectural Elements
• Version gating for MySQL/MariaDB features.
• GitHub Actions workflow invoking lint, test, and release steps.
• Test suite spinning up MySQL/MariaDB via Docker Compose and running pytest.