A Next.js 15 + TypeScript web application with NextAuth.js email authentication, Prisma ORM (PostgreSQL), and shadcn/ui components.
- Authentication: Email magic link authentication (passwordless) via NextAuth.js
- Database: PostgreSQL with Prisma ORM
- UI Components: shadcn/ui with Tailwind CSS v4
- Role-Based Access Control: Super Admin, Org Admin, and User roles
- Forecasting System: Binary, continuous, and categorical forecasts with predictions
- Leaderboard: Track prediction accuracy and performance metrics
- Framework: Next.js 15 (App Router)
- Language: TypeScript 5
- Authentication: NextAuth.js v4
- Database: PostgreSQL + Prisma ORM
- Styling: Tailwind CSS v4 + shadcn/ui
- Email: Nodemailer (SMTP)
- Testing: Vitest + jsdom
- Deployment: Vercel
- Node.js 20.x or later
- PostgreSQL database (local or hosted)
- SMTP email credentials (e.g., Gmail App Password)
- Clone the repository:
git clone <repository-url>
cd yfl-web-service- Install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit .env with your configuration:
DATABASE_URL: PostgreSQL connection stringNEXTAUTH_SECRET: Generate withopenssl rand -base64 32NEXTAUTH_URL: Your app URL (e.g.,http://localhost:3000)- Email SMTP credentials
- Admin email address
# Start PostgreSQL via Docker (optional)
docker-compose up -d
# Run migrations
npx prisma migrate dev
# Generate Prisma client
npx prisma generate
# Seed database (optional)
npm run prisma:seed
# or for demo data
npm run seed:demo
# Open Prisma Studio (optional)
npm run prisma:studionpm run devOpen http://localhost:3000 with your browser to see the result.
# Run tests once
npm run test:run
# Run tests in watch mode
npm run test:watch
# Run tests with UI
npm run test:ui
# Generate coverage report
npm run coveragenpm run lintThis project is configured for deployment on Vercel with PostgreSQL.
-
Provision a PostgreSQL database:
- Vercel Postgres (recommended)
- Neon (serverless)
- Supabase
- Railway
-
Deploy to Vercel:
# Install Vercel CLI npm i -g vercel # Deploy vercel --prod
-
Set environment variables in Vercel Dashboard:
- See
.env.examplefor required variables - Generate
NEXTAUTH_SECRETwithopenssl rand -base64 32 - Add
?sslmode=requiretoDATABASE_URLfor production
- See
-
Run migrations (automatic during build):
- Migrations run via
npm run vercel-build - Or manually:
npx prisma migrate deploy
- Migrations run via
📖 Detailed deployment guide: docs/PRODUCTION-DEPLOYMENT.md
✅ Pre-deployment checklist: docs/PRODUCTION-CHECKLIST.md
├── src/
│ ├── app/ # Next.js App Router pages
│ ├── auth/ # NextAuth.js configuration
│ ├── components/ # Reusable UI components
│ ├── constants/ # Configuration and constants
│ ├── generated/ # Generated Prisma client
│ ├── hooks/ # React hooks
│ ├── lib/ # Utilities and helpers
│ ├── providers/ # React context providers
│ ├── schemas/ # Zod validation schemas
│ ├── services/ # Business logic and data access
│ └── views/ # Presentation components
├── prisma/
│ ├── schema.prisma # Database schema
│ ├── migrations/ # Database migrations
│ └── seeds/ # Database seed scripts
├── docs/ # Documentation
├── tests/ # Test files
└── public/ # Static assets
- Server Actions Guide - Patterns for server actions
- RBAC Summary - Role-based access control
- Pagination Integration - Pagination patterns
- Forecast Implementation - Forecasting system
- Production Deployment - Deployment guide
- Production Checklist - Pre-deployment checklist
npm run dev- Start development servernpm run build- Build production bundlenpm run start- Start production servernpm run lint- Run ESLintnpm run test- Run testsnpm run prisma:seed- Seed databasenpm run prisma:studio- Open Prisma Studionpm run import:forecasts- Import forecasts from CSVnpm run import:actuals- Import actuals from CSV
See .env.example for all required environment variables. Key variables:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_SECRET- Secret for JWT signing (32+ characters)NEXTAUTH_URL- Your app URLEMAIL_SERVER_*- SMTP configurationADMIN_EMAIL- Admin user email addressNEXT_PUBLIC_APP_URL- Public app URL (for emails, etc.)
- Create a new branch for your feature
- Make your changes
- Run tests and linting
- Submit a pull request
Run database migrations to create tables:
npx prisma migrate devLaunch Prisma Studio to browse and edit data:
npx prisma studioOpen http://localhost:5555 to access Prisma Studio.
# Generate Prisma client after schema changes
npx prisma generate
# Reset database (WARNING: deletes all data)
npx prisma migrate reset
# Create a new migration
npx prisma migrate dev --name description_of_changes- Next.js Documentation
- Prisma Documentation
- NextAuth.js Documentation
- shadcn/ui Documentation
- Tailwind CSS Documentation
[Add your license here]
For questions or issues:
- Check the documentation
- Open an issue on GitHub
- Contact the development team
Maintained by: YFL Development Team
Last Updated: November 2025