Developer Installation Guide
This guide will walk you through setting up DeltaHacks Portal for local development. Whether you’re contributing to the project or customizing it for your own hackathon, follow these steps to get a complete development environment running.Prerequisites
Before you begin, ensure you have the following installed on your system:Node.js
Version 18 or higherDownload from nodejs.org
pnpm
Package ManagerInstall with:
npm install -g pnpmGit
Version ControlDownload from git-scm.com
Docker
Container RuntimeRequired for local database
Recommended: Docker Desktop Alternative
For macOS developers, we recommend OrbStack as a fast, lightweight alternative to Docker Desktop. It’s optimized for macOS and provides better performance. Alternatively, you can use:- Docker Desktop (all platforms)
- Podman Desktop (Linux/macOS)
Development Tools
We recommend using VSCode with these extensions:- Tailwind CSS IntelliSense - Autocomplete for Tailwind classes
- Prettier - Code formatter - Automatic code formatting
- Prisma - Prisma schema support
- ESLint - Code linting
Installation Steps
Clone the Repository
Clone the DeltaHacks Portal repository to your local machine:This will create a
portal directory with the complete source code.Install Dependencies
Install all required npm packages using pnpm:This will install all dependencies defined in
package.json, including:- Next.js and React
- Prisma and database tools
- tRPC for API routes
- NextAuth.js for authentication
- TailwindCSS for styling
- And many other packages
The project uses pnpm as the primary package manager. While npm will work, pnpm is recommended for consistency with the development team.
Set Up Environment Variables
Create your local environment configuration:Edit the Copy the output and paste it as your
.env file and configure the required variables. At minimum, you’ll need:.env
Generating Your NextAuth Secret
NEXTAUTH_SECRET value.OAuth Provider Setup (Optional)
For local development, you can set up OAuth providers:Discord OAuth Setup
Discord OAuth Setup
- Go to Discord Developer Portal
- Create a new application
- Navigate to OAuth2 settings
- Add redirect URL:
http://localhost:3000/api/auth/callback/discord - Copy Client ID and Client Secret to your
.env
Google OAuth Setup
Google OAuth Setup
- Go to Google Cloud Console
- Create a new project
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Copy Client ID and Client Secret to your
.env
GitHub OAuth Setup
GitHub OAuth Setup
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Homepage URL:
http://localhost:3000 - Set Authorization callback URL:
http://localhost:3000/api/auth/callback/github - Copy Client ID and Client Secret to your
.env
Set Up Local Database
Run the automated database setup script:This script will:Docker not running:
- Check for Docker or Podman installation
- Verify that port 26257 is available
- Create a CockroachDB container named
deltahacks-cockroach - Start the database on port 26257
- Provide a web UI on port 8080
What the script does
Thesetup-db.sh script automates the setup of a local CockroachDB instance:The database runs in insecure mode for local development. Never use this configuration in production!
Accessing the Database UI
Once running, you can access the CockroachDB admin UI at:- Web UI: http://localhost:8080
- SQL Port: localhost:26257
Troubleshooting
Port already in use:Initialize Database Schema
Generate the Prisma Client and push the schema to your database:This will:
- Generate the Prisma Client based on
prisma/schema.prisma - Create all database tables and relationships
- Set up indexes and constraints
Alternative: Using Migrations
For production or when working with existing databases, use migrations instead:Start Development Server
Launch the Next.js development server:The development server will:
- Install any missing dependencies
- Generate Prisma Client (if not already generated)
- Start Next.js in development mode
- Enable hot module replacement
- Watch for file changes
The
pnpm dev command runs: pnpm i && prisma generate && next devThis ensures dependencies and Prisma Client are always up to date.Verify Installation
Open your browser and navigate to http://localhost:3000You should see the DeltaHacks Portal homepage. Try:
- Sign in with one of your configured OAuth providers
- Create your first user (will have HACKER role by default)
- Explore the interface and features
First-Time Setup
To give yourself admin privileges:- Sign in and note your user ID
- Open Prisma Studio:
- Navigate to the
Usermodel - Find your user and edit the
rolefield - Add
ADMINto the roles array - Save changes and refresh your browser
Development Commands
Here’s a comprehensive list of available commands:Server Commands
Database Commands
Code Quality Commands
Project Structure
Understanding the codebase structure will help you navigate and contribute effectively:Key Directories
src/server/trpc/router/
src/server/trpc/router/
Contains all tRPC API routers that define the backend logic:
application.ts- Hacker application managementauth.ts- Authentication logicadmin.ts- Admin operationsjudging.ts- Judging systemequipment.ts- Equipment tracking- And more…
src/components/
src/components/
Reusable React components organized by feature:
- Form components
- Layout components
- Dashboard components
- QR code scanners
- Admin tools
src/schemas/
src/schemas/
Zod schemas for input validation:
- Ensures type safety
- Validates user input
- Shared between client and server
prisma/
prisma/
Database-related files:
schema.prisma- Database models and relationshipsmigrations/- Version-controlled schema changes
Next Steps
Contributing Guide
Learn how to contribute to the project
Architecture Overview
Understand the system design and data flow
API Reference
Explore available tRPC endpoints
Database Schema
Detailed documentation of data models
Troubleshooting
Common Issues
Port 3000 already in use
Port 3000 already in use
Another application is using port 3000. Either:Option 1: Stop the other applicationOption 2: Use a different port
Database connection error
Database connection error
Ensure your database container is running:
Prisma Client not generated
Prisma Client not generated
If you see “@prisma/client did not initialize yet”, run:
OAuth authentication failing
OAuth authentication failing
- Verify your OAuth credentials in
.env - Check that redirect URLs match in provider settings
- Ensure
NEXTAUTH_URLmatches your local URL - Clear browser cookies and try again
TypeScript errors after pulling changes
TypeScript errors after pulling changes
Development Best Practices
Before making changes, read through the Contributing Guide for:
- Code style guidelines
- Development workflows
- Pull request process
- Best practices for React, TypeScript, and state management
Quick Tips
- Type Safety: Always use TypeScript, avoid
anytypes - Database Changes: Create migrations for all schema changes
- Code Formatting: Run
pnpm formatbefore committing - Testing: Test your changes thoroughly with different user roles
- Commits: Use conventional commit messages
Getting Help
Need assistance?- Discord: Ask in the
#technical-chatchannel - GitHub Issues: Open an issue
- Email: [email protected]