constructive-io/constructive(新しいタブで開きます)
主要言語: TypeScript
Secure, Modular Postgres for Teams
- star 数
- 59
- watcher 数
- 2
- fork 数
- 7
- issue 数
- 135
- 最終更新
- 2026/11/01
主要言語: TypeScript
Secure, Modular Postgres for Teams
Constructive is a complete ecosystem for modular PostgreSQL development. Design your database schema, manage it with our package manager, and get a production-ready GraphQL API automatically. Build composable database modules, version them like npm packages, and deploy with confidence.
# Install pgpm globally npm install -g pgpm # Start local Postgres (via Docker) and export env vars pgpm docker start eval "$(pgpm env)"
Tip: Already running Postgres? Skip the Docker step and just export your PG* vars.
# 1. Create a workspace pgpm init workspace cd my-app # 2. Create your first module pgpm init cd packages/your-module # 3. Install a package pgpm install @pgpm/faker # 4. Deploy everything pgpm deploy --createdb --database mydb1 psql -d mydb1 -c "SELECT faker.city('MI');" > Ann Arbor
# 1. Create workspace pgpm init workspace cd my-app # 2. Create your first module pgpm init cd packages/new-module # 3. Add some SQL migrations to sql/ directory pgpm add some_change # 4. Deploy to database pgpm deploy --createdb
# 1. Install workspace dependencies pnpm install # 2. Enter the packages/<yourmodule> cd packages/yourmodule # 3. Test the module in watch mode pnpm test:watch
Constructive transforms how you build PostgreSQL applications by treating your database as a modular, version-controlled system. At its core is pgpm (PostgreSQL Package Manager), which brings npm-style package management to Postgres. Write SQL migrations, organize them into reusable modules, install database packages as dependencies, and deploy with deterministic, plan-driven migrations.
The framework automatically generates a secure, role-aware GraphQL API from your PostgreSQL schema using PostGraphile. This means you design your database once, and Constructive handles the API layer, authentication middleware, and developer tooling.
Constructive embraces a database-first development approach where your PostgreSQL schema is the source of truth. Row-Level Security (RLS) policies become your authorization layer, database functions become your business logic, and the GraphQL API is automatically derived from your carefully designed schema. This eliminates the impedance mismatch between your database and API while giving you the full power of SQL.
The heart of Constructive's modular approach. pgpm manages database schemas as versioned packages with dependency resolution, migration tracking, and reproducible deployments.
Features:
Learn more: pgpm documentation
Full-featured command-line toolkit for managing Constructive projects. Provides the complete development workflow from scaffolding to deployment.
Features:
Learn more: @constructive-io/cli documentation
Express-based server powered by PostGraphile that automatically exposes your PostgreSQL database as a secure, scalable GraphQL API.
Features:
Learn more: @constructive-io/graphql-server documentation
# Run linting across all packages pnpm lint # Run linting for a specific package cd packages/cli pnpm lint # Build all packages pnpm build # Clean build artifacts pnpm clean
# Create workspace with pgpm pgpm init workspace cd my-app # Create your first module pgpm init # Add database changes pgpm add schema/app pgpm add tables/users pgpm add functions/authenticate # Deploy to database pgpm deploy --createdb
# Install reusable database modules pgpm install @pgpm/base32 pgpm install @pgpm/faker # Deploy with dependencies pgpm deploy
# Tag a release pgpm tag v1.0.0 --comment "Initial release" # Generate deployment plan pgpm plan # Deploy to production pgpm deploy --to @v1.0.0 # Verify deployment pgpm verify
import { getConnections } from 'pgsql-test'; let db, teardown; beforeAll(async () => { ({ db, teardown } = await getConnections()); }); beforeEach(() => db.beforeEach()); afterEach(() => db.afterEach()); afterAll(() => teardown()); test('user authentication', async () => { db.setContext({ role: 'authenticated', 'jwt.claims.user_id': '123' }); const result = await db.query('SELECT current_user_id()'); expect(result.rows[0].current_user_id).toBe('123'); });
Modular by Design - Organize your database into reusable packages with clear dependencies. Share common schemas across projects, version them independently, and compose complex systems from simple building blocks.
Database-First Development - Your PostgreSQL schema is the source of truth. Design your data model with the full power of SQL, leverage Row-Level Security for authorization, and let Constructive generate your API automatically.
Production-Ready - Built for teams shipping real applications. Deterministic migrations, comprehensive testing tools, automatic API generation, and deployment automation mean you can move fast without breaking things.
Developer Experience - Hot-reload development server, GraphiQL explorer, automatic TypeScript types, and comprehensive testing utilities make building PostgreSQL applications a joy.
Constructive applications follow a clear architecture:
This architecture eliminates the traditional ORM layer and API boilerplate, letting you focus on your data model and business logic.
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.