Expert guidance for developing a Next.js 15 vacation request application with Prisma, NextAuth.js, and Microsoft Entra ID authentication. Includes architecture patterns, testing strategies, and database workflows.
Expert guidance for developing and maintaining a Next.js 15 vacation request application with enterprise authentication and comprehensive testing.
This skill provides specialized knowledge for working with a vacation request application built with:
```bash
npm run dev # Start development server with Turbopack
npm run build # Build for production (runs prisma generate first)
npm start # Start production server
```
```bash
npm test # Run unit tests
npm run test:ui # Run tests with Vitest UI
npm run coverage # Generate coverage report
npm run test:e2e # Run Playwright E2E tests
npm run test:e2e:ui # Run Playwright with UI
```
```bash
npm run migrate:dev # Run Prisma migrations in development
npm run db:reset # Reset database and re-seed
npm run prisma:seed # Seed database with initial data
```
```bash
npm run lint # Run ESLint
```
When working with this vacation request application codebase, follow these guidelines:
**Authentication Flow:**
**Data Models (Prisma):**
**Service Layer Pattern:**
- `user.service.ts` - User management and authentication
- `time-off-request.service.ts` - Request creation and approval workflow
- `time-off-balance.service.ts` - Balance tracking and updates
- `department.service.ts` - Department management
**API Structure:**
**Environment Configuration:**
Before starting development, ensure these environment variables are set:
```
DATABASE_URL="postgresql://..."
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="..."
AZURE_AD_CLIENT_ID="..."
AZURE_AD_CLIENT_SECRET="..."
AZURE_AD_TENANT_ID="..."
```
**Prisma Workflow:**
1. Schema location: `prisma/schema.prisma`
2. Generated client outputs to: `src/lib/generated/prisma/` (custom path)
3. After schema changes:
- Run `npm run migrate:dev` to create migration
- Run `npm run build` to regenerate Prisma client
4. Import Prisma client from: `src/lib/generated/prisma/`
**Unit Tests (Vitest):**
**E2E Tests (Playwright):**
**Coverage:**
**Service Layer:**
**Component Structure:**
**TypeScript:**
**Date Handling:**
**Branch Strategy:**
**Before Committing:**
1. Run `npm run lint` to check code style
2. Run `npm test` to verify unit tests pass
3. Run `npm run test:e2e` for critical features
4. Write descriptive commit messages
**Pull Requests:**
**Authentication:**
**Data Access:**
**Adding a New Feature:**
1. Create service layer functions with tests
2. Add API routes if needed
3. Build UI components following shadcn/ui patterns
4. Add E2E tests for user flows
5. Update documentation
**Modifying Database Schema:**
1. Edit `prisma/schema.prisma`
2. Run `npm run migrate:dev`
3. Run `npm run build` to regenerate client
4. Update affected services and types
5. Run tests to verify changes
**Debugging Authentication:**
1. Check environment variables are set
2. Verify Microsoft Entra ID configuration
3. Review `src/middleware.ts` for route protection
4. Check session data in NextAuth callbacks
**Example 1: Adding a New Service Function**
```typescript
// src/lib/services/time-off-request.service.ts
export async function approveRequest(
requestId: string,
approverId: string
): Promise<TimeOffRequest> {
const request = await prisma.timeOffRequest.findUnique({
where: { id: requestId }
});
if (!request) {
throw new Error('Request not found');
}
return await prisma.timeOffRequest.update({
where: { id: requestId },
data: {
status: 'APPROVED',
approverId,
approvedAt: new Date()
}
});
}
```
**Example 2: Creating an API Route**
```typescript
// app/api/requests/[id]/approve/route.ts
import { approveRequest } from '@/lib/services/time-off-request.service';
import { getServerSession } from 'next-auth';
export async function POST(
request: Request,
{ params }: { params: { id: string } }
) {
const session = await getServerSession();
if (!session?.user) {
return new Response('Unauthorized', { status: 401 });
}
try {
const result = await approveRequest(params.id, session.user.id);
return Response.json(result);
} catch (error) {
return new Response('Error approving request', { status: 500 });
}
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/vacation-request-app-development/raw