@@ -5,33 +5,22 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
55## Build & Development Commands
66
77``` bash
8- # Install dependencies
9- pnpm install
10-
11- # Build all packages
12- pnpm build
13-
14- # Build all packages (dev mode - faster, no optimizations)
15- pnpm build:dev
16-
17- # Lint all packages (auto-fix enabled)
18- pnpm lint
19-
20- # Clean build artifacts
21- pnpm clean
22-
23- # Update dependencies interactively
24- pnpm deps
8+ pnpm install # Install dependencies
9+ pnpm build # Build all packages
10+ pnpm build:dev # Build all packages (dev mode - faster, no optimizations)
11+ pnpm lint # Lint all packages (auto-fix enabled)
12+ pnpm clean # Clean build artifacts
13+ pnpm deps # Update dependencies interactively (pnpm up -r -i -L)
2514```
2615
2716### Per-Package Commands
2817
29- Navigate to any package directory (e.g., ` cd pgpm/cli ` ) and run :
18+ From any package directory (e.g., ` cd pgpm/cli ` ):
3019
3120``` bash
32- pnpm build # Build the package
21+ pnpm build # Build the package (uses makage)
3322pnpm lint # Lint with auto-fix
34- pnpm test # Run tests
23+ pnpm test # Run tests (Jest)
3524pnpm test:watch # Run tests in watch mode
3625pnpm dev # Run in development mode (where available)
3726```
@@ -41,54 +30,74 @@ pnpm dev # Run in development mode (where available)
4130``` bash
4231cd packages/cli
4332pnpm test -- path/to/test.test.ts
44- # or with pattern matching:
4533pnpm test -- --testNamePattern=" test name pattern"
4634```
4735
36+ ### Publishing
37+
38+ Lerna with independent versioning and conventional commits. Publishing only from ` main ` branch:
39+
40+ ``` bash
41+ npx lerna version # Bump versions
42+ npx lerna publish # Publish to npm
43+ ```
44+
4845## Project Architecture
4946
50- This is a ** pnpm monorepo** using Lerna for versioning/publishing. The workspace is organized into domain-specific directories:
47+ A ** pnpm monorepo** with Lerna for versioning. PostgreSQL-first framework: design your database schema, manage it with pgpm, and get a production-ready GraphQL API automatically via PostGraphile.
48+
49+ ### Data Flow
50+
51+ ```
52+ PostgreSQL (schema + RLS policies, managed by pgpm migrations)
53+ ↓
54+ PostGraphile (graphql/server + graphile/* plugins)
55+ ↓
56+ GraphQL Schema (auto-generated from database)
57+ ↓
58+ graphql/codegen (--react-query mode OR --orm mode)
59+ ↓
60+ React Query Hooks or Prisma-like ORM Client
61+ ```
5162
52- ### Core Package Groups
63+ ### Workspace Groups
5364
5465| Directory | Purpose |
5566| -----------| ---------|
56- | ` pgpm/ ` | PostgreSQL Package Manager - CLI, core engine, types |
57- | ` graphql/ ` | GraphQL layer - server, codegen, React hooks, testing |
58- | ` graphile/ ` | PostGraphile plugins - filters, i18n, meta-schema, PostGIS |
59- | ` postgres/ ` | PostgreSQL utilities - introspection, testing, seeding, AST |
60- | ` packages/ ` | Shared utilities - CLI, ORM, query builder |
61- | ` uploads/ ` | File streaming - S3, ETags, content-type detection |
62- | ` jobs/ ` | Job scheduling and worker infrastructure |
67+ | ` pgpm/ ` | PostgreSQL Package Manager - CLI (` pgpm ` ), core engine, types, env, logger |
68+ | ` graphql/ ` | GraphQL layer - server, codegen, query builder, explorer, AST utilities |
69+ | ` graphile/ ` | PostGraphile plugins - filters, i18n, meta-schema, PostGIS, search, uploads, settings |
70+ | ` postgres/ ` | PostgreSQL utilities - introspection, testing (pgsql-test), seeding, AST, query context |
71+ | ` packages/ ` | Shared utilities - CLI (` cnc ` ), ORM base, query builder, server utils, client |
72+ | ` uploads/ ` | File streaming - S3/MinIO, ETags, content-type detection, UUID hashing |
73+ | ` jobs/ ` | Knative job scheduling - worker, scheduler, service, functions |
74+ | ` functions/ ` | Knative cloud functions (e.g., send-email-link) |
6375
64- ### Key Packages
76+ ### Key Packages & CLIs
6577
66- ** pgpm (PostgreSQL Package Manager)**
67- - ` pgpm/cli ` - Main CLI tool (` pgpm ` command)
68- - ` pgpm/core ` - Migration engine, dependency resolution, deployment
78+ ** ` pgpm ` CLI** (` pgpm/cli ` ) - PostgreSQL Package Manager. Commands: ` init ` , ` add ` , ` deploy ` , ` revert ` , ` verify ` , ` plan ` , ` install ` , ` export ` , ` docker ` , ` dump ` , ` tag ` . Manages SQL migrations in Sqitch-compatible format with dependency resolution.
6979
70- ** GraphQL Stack**
71- - ` graphql/server ` - Express + PostGraphile API server
72- - ` graphql/codegen ` - SDK generator (React Query hooks or Prisma-like ORM)
73- - ` graphql/query ` - Fluent GraphQL query builder
80+ ** ` cnc ` CLI** (` packages/cli ` , binary: ` cnc ` or ` constructive ` ) - Full dev toolkit. Commands: ` server ` (start PostGraphile), ` explorer ` (GraphiQL UI), ` codegen ` (generate SDK), ` get-graphql-schema ` , ` jobs ` , ` context ` , ` auth ` , ` execute ` .
7481
75- ** Testing Infrastructure**
76- - ` postgres/pgsql-test ` - Isolated PostgreSQL test environments with transaction rollback
77- - ` graphile/graphile-test ` - GraphQL testing utilities
82+ ** ` graphql/codegen ` ** - Generates type-safe clients from GraphQL schema or endpoint:
83+ - ` --react-query ` mode: TanStack Query v5 hooks with query key factories
84+ - ` --orm ` mode: Prisma-like fluent API with ` InferSelectResult<T, S> ` type inference, discriminated union error handling (` .unwrap() ` , ` .unwrapOr() ` )
85+ - Sources: GraphQL endpoint URL, .graphql schema file, or direct database introspection
7886
79- ### Testing Pattern
87+ ** ` graphql/server ` ** - Express + PostGraphile. Supports multi-endpoint routing via subdomain/host detection (schema builder with app-public/auth/admin sub-endpoints). Uses ` LISTEN/NOTIFY ` for schema cache invalidation.
8088
81- Tests use ` pgsql-test ` for database testing with per-test transaction rollback:
89+ ** ` graphile/graphile-settings ` ** - Centralizes all PostGraphile plugin config: connection filters, full-text search, PostGIS, i18n, meta-schema, many-to-many, search, upload plugin. Single ` getGraphileSettings(opts) ` entry point.
8290
83- ``` typescript
84- import { getConnections } from ' pgsql-test' ;
91+ ** ` packages/query-builder ` ** - Fluent SQL query builder for SELECT/INSERT/UPDATE/DELETE with JOINs, WHERE, GROUP BY. Schema-qualified tables.
8592
86- let db, teardown;
93+ ### Testing Infrastructure
8794
88- beforeAll (async () => {
89- ({ db , teardown } = await getConnections ());
90- });
95+ ** ` postgres/pgsql-test ` ** - Isolated PostgreSQL test environments with per-test transaction rollback:
9196
97+ ``` typescript
98+ import { getConnections } from ' pgsql-test' ;
99+ let db, teardown;
100+ beforeAll (async () => ({ db , teardown } = await getConnections ()));
92101beforeEach (() => db .beforeEach ());
93102afterEach (() => db .afterEach ());
94103afterAll (() => teardown ());
@@ -100,26 +109,35 @@ test('example', async () => {
100109});
101110```
102111
112+ ** ` graphile/graphile-test ` ** - GraphQL testing with PostGraphile snapshot support.
113+
114+ ### Job System
115+
116+ Background jobs use Knative: jobs are added to ` app_jobs.jobs ` table → ` knative-job-worker ` polls and picks up → POSTs to Knative function URL → function executes (e.g., send email) → returns status.
117+
103118### Database Configuration
104119
105- Tests require PostgreSQL. Standard PG environment variables:
106- - ` PGHOST ` (default: localhost)
107- - ` PGPORT ` (default: 5432)
108- - ` PGUSER ` (default: postgres)
109- - ` PGPASSWORD ` (default: password)
120+ Tests require PostgreSQL. Standard PG env vars:
121+ - ` PGHOST ` (default: localhost), ` PGPORT ` (default: 5432)
122+ - ` PGUSER ` (default: postgres), ` PGPASSWORD ` (default: password)
110123
111124For S3/MinIO tests: ` MINIO_ENDPOINT ` , ` AWS_ACCESS_KEY ` , ` AWS_SECRET_KEY ` , ` AWS_REGION `
112125
113- ### Build System
126+ ## Build System
114127
115- - Uses ` makage ` for TypeScript compilation (handles both CJS and ESM output)
116- - Jest with ts-jest for testing
117- - ESLint with TypeScript support
118- - Each package has its own ` tsconfig.json ` extending root config
128+ - ** makage** compiles TypeScript to both CJS and ESM, outputs to ` dist/ `
129+ - ` makage build --dev ` for faster dev builds
130+ - Some packages use ` copyfiles ` for non-TS assets (SQL files, templates)
131+ - Jest with ` ts-jest ` preset per-package ( ` jest.config.js ` in each package)
119132
120- ### Code Conventions
133+ ## Code Conventions
121134
122- - TypeScript with ` strict: true ` (but ` strictNullChecks: false ` )
123- - Target: ES2022, Module: CommonJS
124- - Packages publish to npm from ` dist/ ` directory
135+ - TypeScript with ` strict: true ` but ` strictNullChecks: false `
136+ - Target: ES2022, Module: CommonJS, ModuleResolution: node
137+ - 2-space indent, single quotes, semicolons required, no trailing commas
138+ - Imports auto-sorted by ` simple-import-sort ` , unused imports auto-removed
139+ - ` @typescript-eslint/no-explicit-any ` : allowed (turned off)
140+ - Unused var pattern: prefix with ` _ ` (e.g., ` _unused ` )
125141- Workspace dependencies use ` workspace:^ ` protocol
142+ - Packages publish from ` dist/ ` directory
143+ - GraphQL pinned to ` 15.10.1 ` via overrides
0 commit comments