kysely-org/kysely

A type-safe TypeScript SQL query builder

13,626 stars TypeScript 8 components 6 connections

Type-safe TypeScript SQL query builder with multi-database support

Query building flows from fluent API through AST compilation to database execution with type information preserved throughout.

Under the hood, the system uses 2 feedback loops, 2 data pools, 2 control points to manage its runtime behavior.

Structural Verdict

A 8-component library with 6 connections. 472 files analyzed. Well-connected — clear data flow between components.

How Data Flows Through the System

Query building flows from fluent API through AST compilation to database execution with type information preserved throughout.

  1. Query Construction — Type-safe query builders create operation node AST
  2. SQL Compilation — Dialect-specific compilers generate SQL strings from operation nodes
  3. Parameter Binding — Raw SQL expressions and parameters are safely bound
  4. Query Execution — Compiled queries executed through database connections
  5. Result Mapping — Database results mapped back to TypeScript types

System Behavior

How the system actually operates at runtime — where data accumulates, what loops, what waits, and what controls what.

Data Pools

Connection Pool (database)
Manages database connection lifecycle and pooling
Query Cache (cache)
Caches compiled SQL strings to avoid recompilation

Feedback Loops

Delays & Async Processing

Control Points

Package Structure

This monorepo contains 3 packages:

kysely (library)
The main Kysely library providing type-safe SQL query building capabilities with dialect adapters for multiple databases.
kysely-site (app)
Docusaurus-based documentation website with interactive examples and feature showcase.
kysely-cloudflare-workers-test (tooling)
Test suite for validating Kysely compatibility with Cloudflare Workers runtime environment.

Technology Stack

TypeScript (framework)
Primary language with advanced type system usage
Mocha (testing)
Test framework for unit and integration tests
PostgreSQL (database)
Primary SQL database for testing and examples
SQLite (database)
Lightweight database for testing and examples
Docusaurus (framework)
Documentation site generator
ESBuild (build)
Fast JavaScript bundler for builds

Key Components

Configuration

docker-compose.yml (yaml)

pnpm-workspace.yaml (yaml)

deno.check.json (json)

deno.lint.json (json)

Explore the interactive analysis

See the full architecture map, data flow, and code patterns visualization.

Analyze on CodeSea

Related Library Repositories

Frequently Asked Questions

What is kysely used for?

Type-safe TypeScript SQL query builder with multi-database support kysely-org/kysely is a 8-component library written in TypeScript. Well-connected — clear data flow between components. The codebase contains 472 files.

How is kysely architected?

kysely is organized into 4 architecture layers: API Layer, Compilation Layer, Dialect Layer, Execution Layer. Well-connected — clear data flow between components. This layered structure enables tight integration between components.

How does data flow through kysely?

Data moves through 5 stages: Query Construction → SQL Compilation → Parameter Binding → Query Execution → Result Mapping. Query building flows from fluent API through AST compilation to database execution with type information preserved throughout. This pipeline design reflects a complex multi-stage processing system.

What technologies does kysely use?

The core stack includes TypeScript (Primary language with advanced type system usage), Mocha (Test framework for unit and integration tests), PostgreSQL (Primary SQL database for testing and examples), SQLite (Lightweight database for testing and examples), Docusaurus (Documentation site generator), ESBuild (Fast JavaScript bundler for builds). A focused set of dependencies that keeps the build manageable.

What system dynamics does kysely have?

kysely exhibits 2 data pools (Connection Pool, Query Cache), 2 feedback loops, 2 control points, 2 delays. The feedback loops handle recursive and retry. These runtime behaviors shape how the system responds to load, failures, and configuration changes.

What design patterns does kysely use?

4 design patterns detected: Fluent Builder, Visitor Pattern, Dialect Adapter, Template Tag.

Analyzed on March 31, 2026 by CodeSea. Written by .