Skip to content

hyperninjas/full-stack

Repository files navigation

Full Stack Monorepo

A pnpm workspace with two main packages available at the root:

  • client: Next.js app (Frontend)
  • server: NestJS API (Backend)

Prerequisites

  • Node.js 22.x
  • pnpm 10.25.0
  • Postgres (local) for server development

Quick Start

  1. Install Dependencies

    pnpm install

    This installs dependencies for both client and server.

  2. Setup Database Ensure your local Postgres is running.

    # Set the database URL environment variable (required for Prisma)
    export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
    
    # Generate Prisma Client
    pnpm --filter server prisma:generate
    # Or using the root alias:
    pnpm prebuild
    
    # Push the schema to your local database
    pnpm --filter server prisma:migrate
    # Or using the root alias:
    pnpm migrate
  3. Generate API Client The frontend uses a generated TypeScript client to interact with the backend API.

    pnpm --filter client openapi

    This runs openapi-generator-cli using the configuration in client/openapi-generator.config.json.

  4. Run Development Server Start both client and server in parallel:

    pnpm dev

Development Workflow

Managing Dependencies

Since this is a monorepo, you must specify which package to install dependencies into.

  • Add a runtime dependency (e.g., lodash to client):
    pnpm add lodash --filter client
  • Add a dev dependency (e.g., jest to server):
    pnpm add -D jest --filter server
  • Remove a dependency:
    pnpm remove <package_name> --filter client
  • Add to both packages:
    pnpm add <package_name> --filter client --filter server

Build & Start

  • Build everything:
    pnpm build
  • Start production:
    pnpm start
  • Build/Start individual apps:
    pnpm build:client
    pnpm build:server

Testing & Linting

  • Server Tests:
    pnpm --filter server test
    pnpm --filter server test:e2e
  • Lint Code:
    pnpm lint

Monorepo Structure

The project uses pnpm workspaces defined in pnpm-workspace.yaml.

/
├── client/           # Next.js Frontend
│   ├── openapi-generator.config.json
│   └── package.json
├── server/           # NestJS Backend
│   ├── prisma/
│   └── package.json
├── .changeset/       # Versioning configuration
├── package.json      # Root scripts & dev dependencies
└── pnpm-workspace.yaml

Changesets (Versioning + Changelogs)

  • Config at .changeset/config.json.
  • Create a changeset (run this when you make changes):
    pnpm changeset
  • Apply versions and update lockfile (CI/CD usually handles this):
    pnpm version-packages
  • Build and publish:
    pnpm release

Git hooks (Husky) & Commitlint

  • Hooks installation: automatic on pnpm install via prepare script.
  • Pre-commit: runs pnpm run lint.
  • Commit message check: enforces Conventional Commits.

Conventional commit examples

feat: add homepage hero
fix(server): handle missing env var
chore(client): update eslint config
docs: update README

Troubleshooting

  • Port Conflicts:
    • Client defaults to port 3001 (configured in client/package.json).
    • Server defaults to port 3000.
    • If you encounter EADDRINUSE, check for running processes or adjust ports.
  • Prisma Client Not Found:
    • If the server fails to start with this error, run pnpm --filter server prisma:generate to regenerate the client.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages