$ show swiftcarrot/queryx
Queryx is a schema-first, type-safe ORM for Go and TypeScript. It provides a CLI tool that parses HCL schema files, manages database migrations using Atlas, and generates type-safe ORM client code for both Go and TypeScript. The codebase is well-structured with clear separation of concerns: schema parsing (schema/), database adapters (adapter/), code generation (generator/), and string inflection utilities (inflect/). It supports PostgreSQL, MySQL, and SQLite. The project includes comprehensive integration tests and CI/CD pipelines. While still in beta (v0), it demonstrates solid engineering practices with template-based code generation, fluent query builders, and support for associations, transactions, and custom primary keys. The generated code is type-safe and includes its own type wrappers for nullable fields and JSON serialization.
The LLM identified 3 files worth highlighting for reuse:
Provides string inflection utilities (camelCase, PascalCase, snake_case, pluralization, singularization) with support for common acronyms. Used by the code generator to produce correctly named identifiers. Self-contained package with tests, easily reusable in any Go project needing name transformations.
Parses database connection URLs for PostgreSQL, MySQL, and SQLite, extracting components (adapter, host, port, database, credentials, options). Provides methods to format URLs for Go's sql.Open and TypeScript. Demonstrates clean URL parsing and adapter-specific formatting logic. Could be extracted for any project needing database connection configuration.
Core code generation engine that loads embedded templates, executes them with schema data, and manages file creation and cleanup. Supports per-model template expansion and automatic deletion of stale generated files. The pattern of using embed.FS with Go templates and a cleanup step is reusable for any code generation tool.