Database Module (Drizzle ORM)
Composable database connection and query layer built on Drizzle ORM with pluggable drivers. Ships with PostgreSQL (node-postgres), SQLite (better-sqlite3), and Turso (libSQL) drivers that self-register through a driver registry. Provides a singleton database client with lazy initialization, typed Drizzle schema definitions, and a migration runner powered by drizzle-kit. Designed to be dropped into any TypeScript service as a standalone data-access module.
| Name | module-database-ts |
| Version | 0.1.0 |
| Category | composable-modules |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | database, drizzle, orm, typescript, sql |
| Source | templates/module-database-ts |
Render it
Three front doors, one catalog. Pick whichever suits the caller.
# CLI
npx @nanohype/sdk render module-database-ts --out ./my-app
# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "module-database-ts", variables);
# MCP — from an agent
get_template({ name: "module-database-ts" })Prerequisites
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for Drizzle ORM and database drivers |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toDatabase module with Drizzle ORM and pluggable drivers- Short project description for package.json and README
DatabaseDriverstring — defaults topostgres- Default database driver (postgres, sqlite, turso, or a custom name)
What it produces
22 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.
.env.example
.gitignore
biome.json
drizzle.config.ts
drizzle/.gitkeep
package.json
src/db/__tests__/client.test.ts
src/db/__tests__/registry.test.ts
src/db/bootstrap.ts
src/db/client.ts
src/db/drivers/index.ts
src/db/drivers/postgres.ts
src/db/drivers/registry.ts
src/db/drivers/sqlite.ts
src/db/drivers/turso.ts
src/db/drivers/types.ts
src/db/index.ts
src/db/migrate.ts
src/db/schema.ts
src/db/types.ts
tsconfig.json
vitest.config.tsComposes with
- Pairs with
ts-service - Pairs with
agentic-loop - Pairs with
rag-pipeline - Nests inside
monorepo
Composites that use it
- AI Platform — Full AI platform with HTTP service, LLM gateway, vector store, data pipeline, auth, billing, and monitoring.
- AI Web Application — Full-stack web application with Next.js frontend, RAG pipeline, authentication, database, and deployment..
- Background Processor — Async job processing service with queue, database, storage, observability, and deployment.
- Document Intelligence — Document search and question-answering system with RAG pipeline, HTTP service, file storage, database, and deployment..
- Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and Kubernetes deployment..
- Production API Service — Production-grade TypeScript API service with auth, database, caching, rate limiting, background jobs, observability, and deployment..
- RAG-Powered Agent — AI agent that uses retrieval-augmented generation as a tool.