Documentation

Getting Started

Everything you need to design, build, and export database schemas with konik.

1

Installation & Setup

Install the konik CLI and authenticate with your account to get started.

Terminal
# Install the konik CLI globally
npm install -g @konik/cli

# Authenticate with your account
konik auth login

# Initialize a new project
konik init my-database

You can also use konik directly in the browser at studio without installing the CLI.

2

Creating Your First Schema

Initialize a schema with a name, target database, and description.

TypeScript
// Create a new schema programmatically
import { Konik } from "@konik/sdk";

const konik = new Konik({ apiKey: process.env.KONIK_API_KEY });

const schema = await konik.schemas.create({
  name: "my-app-db",
  database: "postgresql",
  description: "Main application database",
});
3

Adding Tables & Attributes

Define tables with typed attributes, constraints, and default values.

TypeScript
const users = await schema.tables.create({
  name: "users",
  attributes: [
    { name: "id", type: "uuid", primaryKey: true },
    { name: "email", type: "varchar", unique: true },
    { name: "created_at", type: "timestamp", default: "now()" },
  ],
});
4

Defining Relationships

Connect tables with one-to-one, one-to-many, or many-to-many relationships.

TypeScript
// One-to-many: a user has many posts
await schema. relationships.create({
  from: "posts.user_id",
  to: "users.id",
  type: "one-to-many",
  onDelete: "cascade",
});
5

Exporting Code

Export your schema to production-ready code in your preferred language and ORM.

Terminal
# Export to TypeScript (Drizzle ORM)
konik export --schema my-app-db --lang typescript --orm drizzle

# Export to Python (SQLAlchemy)
konik export --schema my-app-db --lang python --orm sqlalchemy

# Export raw SQL migrations
konik export --schema my-app-db --format sql --output ./migrations

Key Concepts

Schema

A complete database design containing tables, relationships, and constraints.

Table

A data entity with named attributes, types, and constraints like PK/FK.

Attribute

A column in a table with a data type, default value, and optional constraints.

Relationship

A connection between tables — one-to-one, one-to-many, or many-to-many.

Migration

A versioned set of SQL statements that evolves your database schema.

Workspace

An isolated environment containing schemas, settings, and team members.

Canvas Controls

Keyboard-first shortcuts to design schemas at the speed of thought.

Add a new tableT
Draw a relationshipR
Save schema⌘ / Ctrl + S
Undo last action⌘ / Ctrl + Z
Export schema⌘ / Ctrl + ⇧ + E
Pan the canvasSpace + drag
Zoom in / out⌘ / Ctrl + scroll
Open shortcut palette?

API Reference

REST endpoints for programmatic access. Bearer-token auth required.

GET/api/v1/schemasList all schemas in your workspace
POST/api/v1/schemasCreate a new schema
GET/api/v1/schemas/:idGet schema by ID with all tables
PUT/api/v1/schemas/:idUpdate an existing schema
DELETE/api/v1/schemas/:idDelete a schema