A modern full-stack application built with:
- Backend: NestJS
- Frontend: NextJS (App Router)
- Package Manager: pnpm workspace
snapdocs/
├── apps/
│ ├── backend/ # NestJS backend application
│ └── frontend/ # NextJS frontend application
├── packages/ # Shared packages (if any)
├── pnpm-workspace.yaml # pnpm workspace configuration
└── package.json # Root package.json with workspace scripts
- Node.js >= 18.0.0
- pnpm >= 8.0.0
- Install dependencies:
pnpm install- Copy environment files:
cp apps/backend/.env.example apps/backend/.env
cp apps/frontend/.env.example apps/frontend/.envRun both applications simultaneously:
pnpm devOr run individually:
# Backend only
pnpm dev:backend
# Frontend only
pnpm dev:frontendThe applications will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:3001/api
Build all applications:
pnpm buildBuild individually:
pnpm build:backend
pnpm build:frontendpnpm dev- Start both backend and frontend in development modepnpm dev:backend- Start only the backend applicationpnpm dev:frontend- Start only the frontend applicationpnpm build- Build all applications for productionpnpm lint- Run linting on all packagespnpm typecheck- Run TypeScript type checking on all packages
The backend is configured with:
- CORS enabled for frontend communication
- Global API prefix (
/api) - Swagger documentation (when configured)
- Environment-based configuration
- Validation pipes
src/main.ts- Application bootstrapsrc/app.module.ts- Root modulesrc/app.controller.ts- Main controllersrc/app.service.ts- Main service
The frontend uses:
- App Router (Next.js 13+)
- TypeScript
- Modern React patterns with hooks
- Environment variable for API URL
src/app/layout.tsx- Root layoutsrc/app/page.tsx- Home pagesrc/app/globals.css- Global styles
GET /- Welcome messageGET /health- Health check endpoint
Backend (.env):
PORT- Server port (default: 3001)NODE_ENV- Environment modeFRONTEND_URL- Frontend URL for CORS
Frontend (.env):
NEXT_PUBLIC_API_URL- Backend API URL
- Hot Reload: Both applications support hot reload during development
- TypeScript: Full TypeScript support across the workspace
- Linting: ESLint configuration is set up for both applications
- Package Sharing: Easy to add shared packages in the
packages/directory
Add dependencies to specific apps:
pnpm --filter backend add package-name
pnpm --filter frontend add package-nameAdd to root workspace:
pnpm add -w package-name