A modern gallery application built with Next.js, TypeScript, and Tailwind CSS, featuring secure authentication with NextAuth.js.
- β‘ Next.js 15 with App Router
- π· TypeScript for type safety
- π¨ Tailwind CSS for styling
- π NextAuth.js for authentication
- ποΈ Vercel Postgres for database
- π ZenStack for schema management
- π Google OAuth for sign-in
- β ESLint for code linting
- π Prettier for code formatting
- π§ͺ Vitest for testing
- π Storybook for component development
- πͺ Husky for git hooks
This application requires authentication to access protected areas. Follow these steps to set up authentication:
Copy .env.example to .env.local and fill in the required values:
cp .env.example .env.localRequired environment variables:
NEXTAUTH_URL- Your application URL (e.g., http://localhost:3000)NEXTAUTH_SECRET- A random secret for NextAuth.js (generate withopenssl rand -base64 32)GOOGLE_CLIENT_ID- Google OAuth client IDGOOGLE_CLIENT_SECRET- Google OAuth client secretDATABASE_URL- Vercel Postgres connection string
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Copy the Client ID and Client Secret to your
.env.local
- Create a Vercel Postgres database
- Copy the connection string to
DATABASE_URLin.env.local - Generate and push the database schema:
# Generate Prisma client
yarn db:generate
# Deploy schema migrations to database
yarn db:migrate# Install dependencies
yarn install
# Set up environment variables (see Authentication Setup above)
cp .env.example .env.local
# Generate database schema and client
yarn db:generate
# Deploy schema migrations to database
yarn db:migrate
# Start development server
yarn devOpen http://localhost:3000 in your browser. You'll be redirected to the sign-in page where you can authenticate with Google.
# Build for production
yarn build
# Start production server
yarn start# Run tests
yarn test
# Run tests with UI
yarn test:ui
# Run tests once
yarn test:run# Generate schema from ZenStack and Prisma client
yarn db:generate
# Deploy schema migrations to database
yarn db:migrate
# Open Prisma Studio (database GUI)
yarn db:studio# Run ESLint
yarn lint
# Fix ESLint issues
yarn lint:fix
# Check Prettier formatting
yarn format:check
# Format code with Prettier
yarn format# Start Storybook development server
yarn storybook
# Build Storybook for production
yarn build-storybookThis project uses multiple GitHub Actions workflows for comprehensive testing and deployment:
- π§Ή Lint & Format: Validates code quality with ESLint and Prettier formatting
- π§ͺ Test: Runs the test suite using Vitest with coverage reporting
- π¨ Chromatic: Deploys Storybook to Chromatic for visual testing
- π PR Title Format: Automatically enforces Linear Issue ID format in PR titles (
${LinearIssueId} ${title}) - ποΈ Neon DB Cleanup: Automatically deletes Neon database branches when pull requests are closed
- π¦ Weekly Package Upgrade: Automatically creates issues for package upgrades using GitHub Copilot Coding Agent
All workflows run on every push and pull request to main and develop branches using pull_request_target for enhanced security.
The test workflow automatically generates coverage reports and comments them on pull requests, providing:
- Overall coverage percentage
- File-by-file coverage breakdown
- Coverage changes compared to the base branch
To enable Chromatic deployment, add your CHROMATIC_PROJECT_TOKEN as a repository secret:
- Sign up at chromatic.com
- Create a new project or find your existing project token
- Add the token as
CHROMATIC_PROJECT_TOKENin your repository secrets
To enable automatic cleanup of Neon database branches when pull requests are closed, configure the following repository secrets:
- NEON_API_KEY: Your Neon API key for authentication
- Obtain from Neon Console under Account Settings β Developer Settings
- NEON_PROJECT_ID: Your Neon project ID where database branches are created
- Found in your Neon project URL or project settings
The workflow will automatically:
- Trigger when any pull request is closed (merged or just closed)
- Sanitize the branch name to match Neon's naming requirements
- Call the Neon API to delete the corresponding database branch
- Handle errors gracefully (branches that don't exist are ignored)
The Weekly Package Upgrade workflow automatically creates issues for package maintenance using GitHub Copilot Coding Agent:
Schedule: Every Monday at 07:00 JST (Sunday 22:00 UTC)
Process:
- Creates a new GitHub issue with detailed package upgrade instructions
- Assigns the issue to
@copilotfor automated processing - Provides comprehensive guidelines for:
- Listing outdated packages with
yarn outdated - Upgrading packages individually with proper testing
- Running mandatory checks: format β lint β test β build β storybook
- Handling build errors and compatibility issues
- Listing outdated packages with
Manual Trigger: The workflow can also be triggered manually from the Actions tab using workflow_dispatch.
The PR Title Format workflow automatically ensures that all pull request titles follow the Linear Issue ID format: ${LinearIssueId} ${title}.
How it works:
- Triggers: Automatically runs when pull requests are opened, synchronized, edited, or converted from draft to ready for review
- Format Check: Validates if the PR title already follows the
[A-Z]+-\d+ Titlepattern - Issue Detection: If format is incorrect, searches for associated GitHub issue number from:
- PR body (keywords like "Fixes #123", "Closes #123", "Resolves #123")
- Branch name (e.g., "copilot/fix-123" β issue #123)
- Linear ID Extraction: Fetches issue comments to find Linear bot comment containing the Linear Issue ID
- Auto-correction: Updates PR title to include the Linear Issue ID at the beginning
- Notification: Adds a comment explaining the automatic title change
Example:
- Original: "Fix content upload issue"
- Corrected: "RDG-106 Fix content upload issue"
This ensures consistent PR naming that aligns with the project's issue tracking and Copilot instructions.
For automated GitHub Copilot Coding Agent workflow approvals, see Copilot Actions Setup Guide.
This project uses Husky to run git hooks that ensure code quality:
- Runs
lint-stagedto automatically fix ESLint issues and format code with Prettier for staged files - Only processes files that are staged for commit
- Runs
yarn format:checkto verify all files are properly formatted - Runs
yarn lintto check for ESLint issues - Prevents push if formatting or linting issues are found
Important: Always ensure your code is properly formatted before pushing. If you encounter formatting errors, run yarn format to fix them automatically.
βββ app/ # Next.js App Router pages
β βββ api/auth/ # NextAuth.js API routes
β βββ auth/signin/ # Custom sign-in page
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout with SessionProvider
β βββ page.tsx # Protected home page
βββ components/ # React components
β βββ Providers.tsx # SessionProvider wrapper
βββ prisma/ # Prisma schema and migrations
β βββ schema.prisma # Generated Prisma schema
βββ public/ # Static assets
βββ src/
β βββ stories/ # Storybook stories
β βββ setup.ts # Test setup
βββ .storybook/ # Storybook configuration
βββ schema.zmodel # ZenStack schema definition
βββ middleware.ts # Authentication middleware
βββ ...
- Access Protection: All routes except
/auth/signinand API routes are protected by middleware - Sign In: Users are redirected to
/auth/signinif not authenticated - Google OAuth: Users can sign in with their Google account
- Session Management: NextAuth.js manages user sessions with database storage
- Protected Access: Authenticated users can access the main application
The application uses ZenStack to define the database schema, which includes:
- User: User profile information
- Account: OAuth account information
- Session: User session data
- VerificationToken: Email verification tokens
yarn dev- Start development serveryarn build- Build for productionyarn start- Start production serveryarn lint- Run ESLintyarn lint:fix- Fix ESLint issuesyarn format- Format code with Prettieryarn format:check- Check code formattingyarn test- Run tests in watch modeyarn test:run- Run tests onceyarn test:ui- Run tests with UIyarn storybook- Start Storybookyarn build-storybook- Build Storybookyarn chromatic- Deploy to Chromaticyarn db:generate- Generate ZenStack and Prisma schemasyarn db:migrate- Deploy schema migrations to databaseyarn db:studio- Open Prisma Studio
- Framework: Next.js 15
- Language: TypeScript
- Styling: Tailwind CSS
- Authentication: NextAuth.js
- Database: Vercel Postgres
- ORM: Prisma
- Schema Management: ZenStack
- OAuth Provider: Google
- Testing: Vitest + Testing Library
- Linting: ESLint
- Formatting: Prettier
- Components: Storybook
- Git Hooks: Husky + lint-staged