A Next.js application for tracking player rankings and matches with authentication functionality.
- Player ranking system using ELO algorithm
- Match history tracking
- User authentication and authorization
- Player statistics and head-to-head records
- Admin dashboard for player management
- Responsive design for mobile and desktop
-
Frontend:
- Next.js 15
- React 19
- TypeScript
- TailwindCSS
- DaisyUI
-
Backend:
- Next.js API Routes
- Prisma ORM
- PostgreSQL
- NextAuth.js
-
Authentication:
- NextAuth.js with Credentials Provider
- bcrypt for password hashing
-
Development Tools:
- ESLint
- Prisma CLI
- TypeScript
Before you begin, ensure you have the following installed:
git clone https://github.com/fishram/Rankly.git
cd ranklynpm installYou have several options for setting up the database:
-
Supabase (Recommended):
- Create a free account at Supabase
- Create a new project
- Go to Project Settings → Database
- Find your connection string under "Connection string" → "URI"
- Copy the connection string and replace
[YOUR-PASSWORD]with your project password
-
Local PostgreSQL:
- Install PostgreSQL locally:
brew install postgresql@14 - Start PostgreSQL Service:
brew services start postgresql - Then enter postgreSQL:
psql postgres - Create the database:
CREATE DATABASE rankly; - Exit psql:
\q - Your connection string will follow this format:
postgresql://admin:admin@localhost:5432/rankly
- Install PostgreSQL locally:
-
Other Hosted Options:
- Any PostgreSQL-compatible database service
Create a .env.local file in the root directory:
# Database:
# Option 1 - Supabase
DATABASE_URL= "transaction-pooler url from supabase"
DIRECT_URL= "session-pooler url from supabase"
# Option 2 - Local PostgreSQL
DATABASE_URL="postgresql://admin:admin@localhost:5432/rankly"
DIRECT_URL="postgresql://admin:admin@localhost:5432/rankly"
# Authentication
NEXTAUTH_URL="http://localhost:3000" # Local development URL
NEXTAUTH_SECRET="" # Add your generated secret here-
Database URLs (choose one option):
Option 1 - Supabase:
- Create account at Supabase
- Create new project
- Go to Connect at the top of the page
- Copy the connection strings
- Replace
[YOUR-PASSWORD]with your project password
Option 2 - Local PostgreSQL:
- Copy above urls
- Default port is usually 5432
-
NEXTAUTH_URL:
- For local development, use:
http://localhost:3000 - For production, use your deployed URL
- For local development, use:
-
NEXTAUTH_SECRET:
- Generate a random string using one of these commands:
# Option 1 - Using openssl (Mac/Linux) openssl rand -base64 32 # Option 2 - Using Node.js node -e "console.log(crypto.randomBytes(32).toString('base64'))"
- Copy the output and paste it as your NEXTAUTH_SECRET
- Generate a random string using one of these commands:
After setting up your environment variables, you need to initialize your database:
# Generate Prisma client (this is also run automatically after npm install)
npm run postinstall
# Push the database schema to your database
npx prisma db pushYou can use Prisma Studio to view and manage your database:
npx prisma studioThis will open a browser window at http://localhost:5555 where you can inspect your database.
If you encounter any issues:
-
Database Connection Issues:
# Verify your database connection npx prisma db pull -
Schema Issues:
# Validate your schema npx prisma validate
npx prisma studio & npm run devThis will start the development server at http://localhost:3000.
/src- Source code/app- Next.js app router pages and components/middleware.ts- Authentication middleware/lib- Utility functions and shared code
/prisma- Database schema and migrations