Skip to content

buildwithcirex/hackday-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HackDay Backend

Backend API for HackDay Hackathon Management Platform with RBAC and dual-track participation.

Tech Stack

  • Node.js + Express
  • PostgreSQL (NeonDB)
  • Prisma ORM
  • JWT Authentication

Setup Instructions

1. Install Dependencies

npm install

2. Environment Configuration

Copy .env.example to .env and update with your values:

cp .env.example .env

Update the following:

  • DATABASE_URL: Your NeonDB connection string
  • JWT_SECRET: A secure random string
  • FRONTEND_URL: Your frontend URL (for CORS)

3. Database Setup

# Generate Prisma client
npm run prisma:generate

# Run migrations
npm run prisma:migrate

# (Optional) Open Prisma Studio to view/edit data
npm run prisma:studio

4. Create Admin Account

After running migrations, you need to create an admin account manually in the database:

INSERT INTO users (id, email, password, role, created_at, updated_at)
VALUES (
  gen_random_uuid(),
  'admin@hackday.com',
  -- Password: 'admin123' (hashed with bcrypt)
  '$2a$10$YourHashedPasswordHere',
  'ADMIN',
  NOW(),
  NOW()
);

Or use Prisma Studio to create the admin user.

5. Run the Server

Development mode (with auto-reload):

npm run dev

Production mode:

npm start

API Endpoints

Authentication (/api/auth)

  • POST /login - Login (all roles)
  • POST /logout - Logout
  • GET /profile - Get current user profile

Admin (/api/admin) - ADMIN only

  • POST /users - Create team/judge account
  • GET /users - Get all users
  • POST /problem-statements - Create problem statement
  • GET /problem-statements - Get all problem statements
  • PUT /problem-statements/:id - Update problem statement
  • DELETE /problem-statements/:id - Delete problem statement
  • POST /toggle-submissions - Open/close submissions
  • POST /toggle-leaderboard - Show/hide leaderboard
  • GET /system-config - Get system configuration
  • GET /teams - Get all teams with progress
  • GET /leaderboard - Get master leaderboard

Team (/api/teams) - TEAM only

  • PATCH /select-track - Select track (Agentic AI or Open Innovation)
  • GET /me - Get team data and scores
  • POST /submit - Submit project
  • GET /problem-statements - Get problem statements
  • GET /leaderboard - Get leaderboard (if visible)

Judge (/api/judge) - JUDGE only

  • GET /teams - Get all teams for judging
  • GET /teams/:teamId - Get specific team project
  • POST /score - Submit/update score for a team
  • GET /my-scores - Get judge's own scores

Database Schema

Users

  • Admin, Team leaders, and Judges

Teams

  • Team information with track selection
  • Custom tech stack and tags for Open Innovation

ProblemStatements

  • Admin-created problems for Agentic AI track

Submissions

  • Team project submissions (GitHub, demo, PPT, video)

Scores

  • Judge scores with criteria breakdown

SystemConfig

  • Global settings (submissions open/closed, leaderboard visibility)

Deployment to Railway

  1. Create a new project on Railway
  2. Add NeonDB as a service (or use external NeonDB)
  3. Add environment variables from .env.example
  4. Deploy from GitHub or using Railway CLI
  5. Run migrations: railway run npm run prisma:migrate

Security Notes

  • Always use HTTPS in production
  • Set COOKIE_SECURE="true" in production
  • Use a strong JWT_SECRET
  • Regularly update dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published