NIN Connect Docs
Platform (Self-Host)

Database Schema

Complete reference for the PostgreSQL schema — all tables, columns, constraints, and relations managed by Drizzle ORM.

Overview

NIN Connect uses PostgreSQL via Drizzle ORM. The schema is defined in apps/web/src/lib/db/schema.ts.

Entity Relationship

developers ──< api_keys
developers ──< connected_accounts >── plugins
developers ──< execution_logs >── tools
developers ──< plugins (created_by)
developers ──< plugins (reviewed_by)
plugins ──< auth_methods
plugins ──< tools
plugins ──< mcp_tool_cache
plugins ──< plugin_categories >── categories
connected_accounts >── auth_methods (nullable for MCP-only)
plugins ──< pending_connections

Tables

developers

Platform users who sign in via Firebase and use the SDK.

ColumnTypeConstraintsDescription
iduuidPK, default random
firebase_uidtextunique, not nullFirebase Auth UID
emailtextunique, not null
nametextnullable
avatar_urltextnullable
roletextnot null, default "developer"developer or admin
plantextnot null, default "free"
created_attimestampnot null, default now

api_keys

Developer API keys for SDK/API authentication.

ColumnTypeConstraintsDescription
iduuidPK, default random
developer_iduuidFK → developers, cascade delete
key_hashtextnot nullSHA-256 hash of the raw key
prefixtextnot nullVisible portion (nk_live_...)
labeltextnullableUser-assigned label
rate_limitintegernot null, default 1000
last_used_attimestampnullableUpdated on each API call
created_attimestampnot null, default now

plugins

Service integrations — created by any user, go live after admin approval.

ColumnTypeConstraintsDescription
iduuidPK, default random
slugtextunique, not nullURL-safe identifier
nametextnot nullDisplay name
descriptiontextnullable
icon_urltextnullable
base_urltextnullableAPI root URL
plugin_prompttextnullableLLM context injected during tool calls
statustextnot null, default "active"active, beta, deprecated
tool_sourcetextnot null, default "manual"manual, mcp, or both
mcp_configjsonbnullableMCP server configuration (serverUrl, clientId, oauthMetadata)
created_byuuidFK → developers, set null on delete, nullableWho created this plugin (null for legacy/seed data)
review_statustextnot null, default "approved"draft, pending_review, approved, declined, revision_requested
admin_notestextnullableAdmin feedback when declining or requesting revision
reviewed_byuuidFK → developers, set null on delete, nullableWhich admin reviewed this plugin
reviewed_attimestampnullableWhen the review decision was made
created_attimestampnot null, default now

The default review_status is "approved" so all existing (pre-migration) plugins remain unaffected. New plugins created through the dashboard or API start as "draft" and must be approved by an admin before they appear in the public SDK/API.

categories

Tags for organizing plugins.

ColumnTypeConstraintsDescription
iduuidPK, default random
slugtextunique, not null
nametextnot null
icontextnullable
created_attimestampnot null, default now

plugin_categories

Many-to-many join between plugins and categories.

ColumnTypeConstraints
iduuidPK, default random
plugin_iduuidFK → plugins, cascade delete
category_iduuidFK → categories, cascade delete

Unique constraint on (plugin_id, category_id).

auth_methods

Authentication options for a plugin.

ColumnTypeConstraintsDescription
iduuidPK, default random
plugin_iduuidFK → plugins, cascade delete
typetextnot nulloauth2, bearer_token, api_key, service_account, no_auth, custom
labeltextnot nullHuman-readable name
is_defaultbooleannot null, default false
configjsonbnot null, default {}Type-specific configuration
created_attimestampnot null, default now

Unique constraint on (plugin_id, type).

tools

API actions within a plugin.

ColumnTypeConstraintsDescription
iduuidPK, default random
plugin_iduuidFK → plugins, cascade delete
slugtextnot nullUnique within plugin
nametextnot null
descriptiontextnot nullShown to AI agents
methodtextnot nullGET, POST, PUT, PATCH, DELETE
pathtextnot nullURL path appended to plugin base URL
input_schemajsonbnullableJSON Schema for parameters
output_schemajsonbnullableJSON Schema for response
headersjsonbnullableStatic headers merged per request
enabledbooleannot null, default true
created_attimestampnot null, default now

Unique constraint on (plugin_id, slug).

connected_accounts

End-user credentials linking a user to a plugin. Supports both REST and MCP credentials.

ColumnTypeConstraintsDescription
iduuidPK, default random
developer_iduuidFK → developers, cascade delete
user_idtextnot nullDeveloper's end-user ID (opaque)
plugin_iduuidFK → plugins, cascade delete
auth_method_iduuidFK → auth_methods, nullableNull for MCP-only connections
credentialstextnullableAES-256-GCM encrypted JSON (null for MCP-only)
account_labeltextnullable
scopestext[]nullable
expires_attimestampnullableToken expiry for REST OAuth
mcp_access_tokentextnullableAES-256-GCM encrypted MCP access token
mcp_refresh_tokentextnullableAES-256-GCM encrypted MCP refresh token
mcp_token_expires_attimestampnullableMCP token expiry
created_attimestampnot null, default now

Unique constraint on (developer_id, user_id, plugin_id).

A single record can hold both REST credentials and MCP tokens when the plugin uses "both" tool source.

execution_logs

Audit trail for every tool execution.

ColumnTypeConstraintsDescription
iduuidPK, default random
developer_iduuidFK → developers, cascade delete
user_idtextnullable
tool_iduuidFK → tools, set null on delete
statustextnot nullsuccess, error, auth_expired
latency_msintegernullable
error_messagetextnullable
created_attimestampnot null, default now

mcp_tool_cache

Cached tool definitions discovered from MCP servers.

ColumnTypeConstraintsDescription
iduuidPK, default random
plugin_iduuidFK → plugins, cascade delete
mcp_tool_nametextnot nullOriginal tool name from MCP server
slugtextnot nullNormalized uppercase slug (e.g. NOTION_SEARCH)
nametextnot nullDisplay name
descriptiontextnot null, default ""Tool description
input_schemajsonbnullableJSON Schema for tool parameters
last_synced_attimestampnot null, default nowLast sync timestamp

Unique constraint on (plugin_id, mcp_tool_name).

pending_connections

Temporary records during OAuth flows (both REST and MCP).

ColumnTypeConstraintsDescription
iduuidPK, default random
developer_iduuidFK → developers, cascade delete
user_idtextnot null
plugin_iduuidFK → plugins, cascade delete
auth_method_iduuidFK → auth_methods, nullableNull for MCP OAuth flows
state_tokentextunique, not nullHMAC-signed state parameter
redirect_urltextnot nullWhere to redirect after completion
expires_attimestampnot nullTTL for the pending connection
created_attimestampnot null, default now

Drizzle Commands

CommandDescription
pnpm db:generateGenerate migration files from schema changes
pnpm db:migrateRun pending migrations
pnpm db:pushPush schema directly (dev only)
pnpm db:studioOpen Drizzle Studio (visual DB browser)
pnpm db:seedSeed with sample plugins (Gmail, Slack, Stripe, etc.)

On this page