Skip to content

NK2552003/Intern2Earn

Repository files navigation

Intern2Earn

A full-stack internship management platform built with Next.js, Clerk (authentication), and Supabase (database). Students can browse and apply for internships, mentors can post and review applications, and admins can manage the entire platform.


Table of Contents


Prerequisites

Make sure you have the following installed before you begin:

Tool Version Download
Node.js v18 or higher https://nodejs.org
npm v8 or higher npm i
Git Latest https://git-scm.com

You also need free accounts on:


Tech Stack

  • Framework: Next.js 16 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS + shadcn/ui
  • Auth: Clerk
  • Database: Supabase (PostgreSQL)
  • Package Manager: pnpm

Getting Started

1. Clone the repository

git clone <repo-url>
cd Intern2Earn

2. Install dependencies

npm install

If you run into peer dependency issues, try: pnpm install --legacy-peer-deps


Environment Variables (.env.local)

Create a file named .env.local in the root of the project:

touch .env.local

Then paste the following template and fill in your own keys:

# ─── Clerk Authentication ─────────────────────────────────────────────────────
# Get these from https://dashboard.clerk.com → Your App → API Keys
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CLERK_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# Clerk redirect URLs (leave these as-is)
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/login
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard/student
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/onboarding

# ─── Supabase ─────────────────────────────────────────────────────────────────
# Get these from https://app.supabase.com → Your Project → Settings → API
NEXT_PUBLIC_SUPABASE_URL=https://xxxxxxxxxxxxxxxxxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxxx
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxxx

# ─── Clerk Webhook ────────────────────────────────────────────────────────────
# Get this from https://dashboard.clerk.com → Webhooks → your endpoint → Signing Secret
CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Where to find each key

Clerk Keys

  1. Go to https://dashboard.clerk.com
  2. Select your application (create one if you haven't)
  3. Click API Keys in the left sidebar
  4. Copy Publishable keyNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
  5. Copy Secret keyCLERK_SECRET_KEY

Supabase Keys

  1. Go to https://app.supabase.com
  2. Select your project (create one if you haven't — choose a region close to you)
  3. Go to SettingsAPI
  4. Copy Project URLNEXT_PUBLIC_SUPABASE_URL
  5. Copy anon / public key → NEXT_PUBLIC_SUPABASE_ANON_KEY
  6. Copy service_role / secret key → SUPABASE_SERVICE_ROLE_KEY

Important: Never commit .env.local to Git. It is already in .gitignore.


Database Setup

You need to run SQL migration scripts in Supabase SQL Editor to create all the tables.

Step 1 — Open the SQL Editor

  1. Go to https://app.supabase.com → your project
  2. Click SQL Editor in the left sidebar
  3. Click New Query

Step 2 — Run the migrations in order

Copy and paste the contents of each file below into the SQL editor and click Run:

Order File Description
1 scripts/001_create_tables.sql Creates all tables (profiles, internships, applications, submissions, progress, messages, certificates)
2 scripts/002_create_profile_trigger.sql Adds a trigger to auto-create a profile on user signup
3 scripts/003_add_certificate_constraint.sql Adds constraints to the certificates table

Run them one by one in order. Do not skip any.

Step 3 — Enable Row Level Security (RLS) (Recommended)

After running the migrations, go to Authentication → Policies in Supabase and enable RLS on all tables to restrict access appropriately.


Clerk Webhook Setup

The webhook sends user data from Clerk to Supabase automatically when someone signs up.

For Local Development

  1. Install ngrok to expose your local server:
    npm install -g ngrok
    ngrok http 3000
  2. Copy the ngrok HTTPS URL (e.g. https://abc123.ngrok.io)

Configure the Webhook in Clerk

  1. Go to https://dashboard.clerk.comWebhooks
  2. Click Add Endpoint
  3. Set the URL to: https://<your-ngrok-or-domain>/api/webhooks/clerk
  4. Under Subscribe to events, check: user.created
  5. Click Create
  6. Copy the Signing Secret (starts with whsec_)
  7. Add it to .env.local as CLERK_WEBHOOK_SECRET

For Production (Vercel)

Use your live domain instead of ngrok: https://yourdomain.vercel.app/api/webhooks/clerk


Running the App

# Development mode (with hot reload)
pnpm dev

Open your browser at http://localhost:3000

# Build for production
pnpm build

# Start production server
pnpm start

User Roles & Routes

After signing up, users complete an onboarding flow to choose their role.

Student

Route Description
/dashboard/student Overview, stats, recent activity
/internships Browse available internships
/applications Track your applications
/submissions Submit project work
/progress Weekly progress logs
/certificates Download earned certificates

Mentor

Route Description
/dashboard/mentor Overview of your internships
/internships/manage Create and manage internships
/applicants Review student applications
/submissions/review Review student submissions

Admin

Route Description
/dashboard/admin Platform statistics
/admin/users Manage all users
/admin/internships Manage all internships
/admin/applications Review all applications
/admin/reports Generate reports

Project Structure

Intern2Earn/
├── app/                    # Next.js App Router pages
│   ├── api/                # API routes (webhooks, certificates)
│   ├── auth/               # Login & sign-up pages
│   ├── dashboard/          # Role-specific dashboards
│   ├── admin/              # Admin pages
│   └── ...                 # Other feature pages
├── components/             # Reusable React components
│   └── ui/                 # shadcn/ui component library
├── hooks/                  # Custom React hooks
├── lib/                    # Utility functions
│   ├── auth/               # Auth helpers
│   ├── clerk/              # Clerk client helpers
│   └── supabase/           # Supabase client helpers
├── scripts/                # SQL migration files
├── types/                  # TypeScript type definitions
├── middleware.ts            # Route protection middleware
└── .env.local              # Your environment variables (not committed)

Troubleshooting

pnpm install fails

Try clearing the cache and reinstalling:

pnpm store prune
pnpm install

"Missing Publishable Key" error on startup

  • Make sure .env.local exists in the project root
  • Make sure NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is set correctly
  • Restart the dev server after editing .env.local

Users are not being saved to Supabase after sign-up

  • Verify the webhook is configured in Clerk Dashboard
  • Check that CLERK_WEBHOOK_SECRET matches the signing secret in Clerk
  • For local dev, make sure ngrok is running and the URL is up to date in Clerk

SQL migration errors

  • Run the scripts in order: 001002003
  • If a table already exists and causes an error, the scripts use IF NOT EXISTS so re-running is safe
  • Check the Supabase Logs tab for detailed error messages

Port 3000 already in use

# Run on a different port
pnpm dev -- -p 3001

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages