constructive-boilerplate-nextjs-app
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-boilerplate-nextjs-app
Agent 安装分布
Skill 文档
Set up and develop with the Constructive App frontend boilerplate â a Next.js application with authentication, organization management, invites, members, and a GraphQL SDK.
When to Apply
Use this skill when:
- Setting up a new Constructive frontend application from the boilerplate
- Working with the constructive-app template (auth, orgs, invites, members)
- Needing to understand the project structure, routes, or configuration
- Running or customizing the Constructive App boilerplate
Overview
The Constructive App boilerplate is a frontend-only Next.js application that connects to a Constructive backend. It provides production-ready authentication flows, organization management, invite handling, member management, and account settings â all powered by a generated GraphQL SDK.
Setup
1. Clone the Boilerplate
Use pgpm init with the -w flag to scaffold a workspace from the template. All required arguments must be provided to avoid interactive prompts:
pgpm init -w \
--repo constructive-io/sandbox-templates \
--template nextjs/constructive-app \
--no-tty \
--name <workspace-name> \
--fullName "<Author Full Name>" \
--email "<author@example.com>" \
--repoName <workspace-name> \
--username <github-username> \
--license MIT \
--moduleName <module-name> \
--extensions "plpgsql,uuid-ossp"
Required arguments for non-interactive mode (--no-tty):
| Argument | Description |
|---|---|
--name |
Workspace directory name |
--fullName |
Author’s full name |
--email |
Author’s email |
--repoName |
Repository name (typically same as workspace name) |
--username |
GitHub username |
--license |
License (MIT, APACHE-2.0, BSD-3-CLAUSE, etc.) |
--moduleName |
Module/package name inside the workspace |
--extensions |
PostgreSQL extensions (comma-separated) |
The boilerplate is created at <workspace-name>/packages/<module-name>/.
Interactive mode (for humans): Omit
--no-ttyand the argument flags to get guided prompts:pgpm init -w --repo constructive-io/sandbox-templates --template nextjs/constructive-app
2. Install Dependencies
cd <workspace-name>/packages/<module-name>
pnpm install
3. Configure Environment
Create or verify .env.local:
# GraphQL endpoint (must point to a running Constructive backend)
NEXT_PUBLIC_SCHEMA_BUILDER_GRAPHQL_ENDPOINT=http://api.localhost:3000/graphql
4. Generate GraphQL SDK
The SDK must be generated against a running backend:
pnpm codegen
This runs @constructive-io/graphql-codegen using graphql-codegen.config.ts and outputs the SDK to src/graphql/schema-builder-sdk/api.
5. Start Development
pnpm dev
Opens at http://localhost:3001.
Backend Requirements
This boilerplate requires a running Constructive backend. The easiest way is via Constructive Hub:
# Terminal 1: Start backend infrastructure
cd /path/to/constructive-hub
pnpm start
# Terminal 2: Start this frontend
cd /path/to/constructive-app
pnpm dev
Required backend services:
| Service | Port | Purpose |
|---|---|---|
| PostgreSQL | 5432 | Database with Constructive schema |
| GraphQL Server (Public) | 3000 | API endpoint for app operations |
| GraphQL Server (Private) | 3002 | Admin operations |
| Job Service | 8080 | Background job processing |
| Email Function | 8082 | Email sending via SMTP |
| Mailpit SMTP | 1025 | Email server (development) |
| Mailpit UI | 8025 | View sent emails |
Project Structure
src/
âââ app/ # Next.js App Router pages
â âââ layout.tsx # Root layout with providers
â âââ page.tsx # Home / org listing page
â âââ login/ # Login page
â âââ register/ # Registration page
â âââ forgot-password/ # Password reset request
â âââ reset-password/ # Password reset form
â âââ check-email/ # Email check prompt
â âââ verify-email/ # Email verification
â âââ invite/ # Accept invite flow
â âââ invites/ # Pending invites list
â âââ account/ # Account management
â âââ settings/ # App settings
â âââ users/ # User management
â âââ orgs/
â âââ [orgId]/ # Org-scoped pages
â âââ layout.tsx # Org layout with sidebar
â âââ activity/ # Org activity
â âââ invites/ # Org invites management
â âââ members/ # Org members management
â âââ settings/ # Org settings
âââ components/
â âââ ui/ # shadcn/ui components (43 components)
â âââ auth/ # Auth forms (login, register, reset, etc.)
â âââ organizations/ # Org CRUD components
â âââ invites/ # Invite management components
â âââ members/ # Member management components
â âââ account/ # Account settings components
â âââ app-shell/ # Sidebar, navigation, layout shell
â âââ layouts/ # Page layout wrappers
â âââ settings/ # Settings UI
â âââ shared/ # Shared/reusable components
â âââ skeletons/ # Loading skeleton components
âââ config/
â âââ branding.ts # App name, logos, legal links
âââ graphql/
â âââ execute.ts # GraphQL execution layer
â âââ index.ts # GraphQL exports
â âââ typed-document.ts # Typed document utilities
â âââ schema-builder-sdk/ # Generated SDK (via codegen)
âââ hooks/ # Shared React hooks
âââ lib/
â âââ auth/ # Auth utilities and context
â âââ gql/ # GraphQL hooks and query factories
â âââ navigation/ # Route and navigation helpers
â âââ permissions/ # Permission checking utilities
â âââ constants/ # App constants
â âââ logger/ # Logging utilities
â âââ runtime/ # Runtime helpers
â âââ utils/ # General utilities
â âââ validation/ # Zod schemas and validation
âââ store/ # Client state management
âââ app-config.ts # App-wide configuration
âââ app-routes.ts # Route definitions
Customization
Branding
Edit src/config/branding.ts to customize:
- App name and tagline
- Logo and wordmark paths (relative to
/public) - Company name for legal footer
- Legal links (disclaimer, privacy policy, etc.)
- Home path for logo links
Adding UI Components
Components use the Constructive shadcn registry:
npx shadcn@latest add @constructive/<component>
Registry URL is configured in components.json. Components use Base UI primitives, Tailwind CSS 4, and cva for variants.
GraphQL SDK
The SDK is generated from the running backend schema. After backend schema changes:
pnpm codegen
Config in graphql-codegen.config.ts points to http://api.localhost:3000/graphql by default.
Features
- Authentication â Login, register, logout, password reset, email verification
- Organizations â Create and manage organizations
- Invites â Send and accept organization invites
- Members â Manage organization members and roles
- Account Management â Profile, email verification, account deletion
- App Shell â Sidebar navigation, theme switching, responsive layout
- Permissions â Role-based access control for org features
Troubleshooting
- GraphQL errors on startup: Ensure the Constructive backend is running and the endpoint in
.env.localis correct - Empty SDK directory: Run
pnpm codegenwith the backend running to generate the SDK - Password reset emails not arriving: Requires the full backend stack (job service + email function). Check Mailpit UI at
http://localhost:8025 - Port conflicts: The frontend runs on port 3001 by default. The backend GraphQL server uses port 3000