Skip to content

nhatng01/AssessmentAI

Repository files navigation

Assessment AI

An AI-powered assignment management platform that allows admins to create assignments with built-in Q&A chatbots for candidates.

Features

Phase 1 (Complete)

  • ✅ Admin authentication with Google OAuth
  • ✅ Create/publish assignments with Q&A database
  • ✅ Public assignment pages with AI chatbot
  • ✅ Together AI integration for answering candidate questions
  • ✅ Email notifications for unanswered questions
  • ✅ Candidate submission form
  • ✅ Admin dashboard to view submissions & chat history

Tech Stack

  • Framework: Next.js 14 (App Router)
  • Database: PostgreSQL with Prisma ORM
  • Authentication: NextAuth.js with Google OAuth
  • AI: Together AI (Llama 3.1)
  • Email: Resend
  • Styling: Tailwind CSS
  • Deployment: Vercel (recommended)

Setup Instructions

1. Prerequisites

  • Node.js 18+ installed
  • PostgreSQL installed and running
  • Google OAuth credentials
  • Together AI API key
  • Resend API key

2. Environment Variables

Create a .env file in the root directory:

# Database
DATABASE_URL="postgresql://your-username@localhost:5432/assessmentai"

# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="generate-with: openssl rand -base64 32"

# Google OAuth (Get from https://console.cloud.google.com)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# Together AI (Get from https://api.together.xyz)
TOGETHER_API_KEY="your-together-ai-key"

# Resend (Get from https://resend.com)
RESEND_API_KEY="your-resend-api-key"
ADMIN_EMAIL="your-email@example.com"

3. Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project (or select existing)
  3. Enable Google+ API
  4. Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
  5. Set application type to "Web application"
  6. Add authorized redirect URI: http://localhost:3000/api/auth/callback/google
  7. Copy Client ID and Client Secret to .env

4. Together AI Setup

  1. Sign up at Together AI
  2. Get your API key from the dashboard
  3. Add to .env as TOGETHER_API_KEY

5. Resend Setup

  1. Sign up at Resend
  2. Get your API key
  3. Important: Configure your sending domain (or use test mode)
  4. Update the from address in lib/email.ts to match your domain
  5. Add to .env as RESEND_API_KEY

6. Install Dependencies

npm install

7. Database Setup

The database should already be created. If not:

createdb assessmentai

Then run migrations:

npx prisma migrate dev

8. Generate NextAuth Secret

openssl rand -base64 32

Copy the output to NEXTAUTH_SECRET in .env

9. Run the Development Server

npm run dev

Open http://localhost:3000 in your browser.

Usage Guide

For Admins

  1. Sign In: Visit the app and sign in with Google
  2. Create Assignment:
    • Click "Create Assignment"
    • Fill in company name, assignment name, compensation, expected time
    • Add assignment details (description, requirements)
    • Add Q&A pairs (questions candidates might ask + answers)
    • Click "Publish Assignment" or "Save as Draft"
  3. Share Link: Copy the public link and share with candidates
  4. View Submissions: Click on an assignment to see all submissions
  5. Review Chat History: See what questions each candidate asked
  6. Monitor Unanswered Questions: Get email alerts when AI can't answer

For Candidates

  1. Visit Assignment Link: Open the link shared by the company
  2. Read Details: Review assignment requirements
  3. Ask Questions: Use the AI chatbot to get answers
  4. Submit Work:
    • Enter your name, email, phone
    • Paste link to your completed assignment (GitHub, etc.)
    • Optionally add LinkedIn profile
    • Click "Submit Assignment"

Project Structure

/app
  /admin                    # Protected admin pages
    /assignments
      /new                  # Create assignment form
      /[id]                 # Assignment details
        /submissions        # View submissions
  /api
    /auth                   # NextAuth configuration
    /assignments            # Assignment CRUD
    /chat                   # AI chatbot endpoint
    /submissions            # Submission handling
  /assignment/[id]          # Public candidate page
  /auth/signin              # Sign-in page

/lib
  /prisma.ts               # Database client
  /email.ts                # Email utilities

/prisma
  /schema.prisma           # Database schema
  /migrations              # Database migrations

Deployment

Deploy to Vercel

  1. Push your code to GitHub
  2. Go to Vercel
  3. Import your repository
  4. Add all environment variables from .env
  5. Update NEXTAUTH_URL to your production URL
  6. Update Google OAuth redirect URI to include production URL
  7. Deploy!

Database

For production, use:

  • Vercel Postgres
  • Supabase
  • Railway
  • Any PostgreSQL provider

Update DATABASE_URL accordingly.

Troubleshooting

Google OAuth not working

  • Check redirect URI matches exactly in Google Console
  • Make sure GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are correct
  • Try clearing cookies

Together AI errors

  • Verify API key is correct
  • Check you have credits in your Together AI account
  • Review API rate limits

Email not sending

  • Verify Resend API key
  • Configure your domain in Resend dashboard
  • Check from address in lib/email.ts matches your verified domain
  • In development, Resend may require domain verification

Database connection issues

  • Make sure PostgreSQL is running: brew services list
  • Check DATABASE_URL is correct
  • Run npx prisma studio to test connection

Future Enhancements (Phase 2 & 3)

  • Rating system for submissions (1-10)
  • Admin notes on submissions
  • Edit assignments after creation
  • Update Q&A database from admin panel
  • Bulk actions on submissions
  • Export submissions to CSV
  • Analytics dashboard
  • Multiple admin users
  • Assignment templates

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages