Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodePilot AI — AI Coding Interview Preparation Platform

A full-stack platform for coding interview prep: Spring Boot + PostgreSQL backend, HTML/CSS/JS frontend, JWT auth, and Gemini-powered AI features throughout.

Note on database: This project ships configured for PostgreSQL (see application.properties). The pom.xml also includes the MySQL driver, so a MySQL setup is technically possible, but the instructions below focus on Postgres since that's what most free hosting platforms (Render, Railway, Supabase, Neon) provide out of the box — this is the easiest path to a live deployment even if you've only used MySQL before. A quick MySQL↔Postgres cheat-sheet is included at the bottom for anyone coming from MySQL.

Features

  • 🔐 Auth: Register, login (JWT + BCrypt), forgot/reset password (token-based)
  • 📊 Dashboard: solved/attempted counts, difficulty breakdown (donut chart), daily streak, gamified contest rating, GitHub-style activity heatmap
  • 🤖 AI Interviewer: ChatGPT-style chat for concept explanations and Q&A
  • 💡 AI Hints: 3 progressive hint levels per question (nudge → approach → pseudocode) — never gives the full solution
  • 📚 44 practice questions across Arrays, Strings, Linked List, Trees, Graphs, DP, Stack, Heap, Searching, Bit Manipulation
  • 🏢 Company-wise questions: browse by Amazon, Google, Meta, Netflix, Apple, Microsoft, Uber, Adobe, Oracle, Bloomberg
  • 📝 Notes: write and auto-save personal notes per question
  • Bookmarks: save favorite questions
  • 📄 Resume Analyzer: upload a PDF, get an AI-generated ATS score, weak points, missing keywords, and detected skills
  • Mock Interview: 5 random questions, countdown timer per question, end-of-round score
  • ⚙️ Admin Panel: add/edit/delete questions, view all registered users (protected by ROLE_ADMIN)
  • Dark, glassmorphic UI with subtle animations
  • Swagger/OpenAPI docs at /swagger-ui.html

Tech Stack

Backend: Java 17, Spring Boot 3.5, Spring Data JPA, Spring Security, JWT (jjwt), PostgreSQL, Apache PDFBox, springdoc-openapi Frontend: HTML, CSS, vanilla JavaScript (served as static files by Spring Boot) AI: Gemini API (default) or OpenAI API


1. Set up PostgreSQL

You have two easy options — pick whichever is less friction for you.

Option A: Install PostgreSQL locally (for local development)

Windows/Mac: download the installer from postgresql.org/download and run it (it installs a GUI tool called pgAdmin too, which works a lot like MySQL Workbench).

Mac (Homebrew):

brew install postgresql@16
brew services start postgresql@16

Linux:

sudo apt install postgresql postgresql-contrib
sudo service postgresql start

Once installed, create the database:

# Open the Postgres shell (equivalent of "mysql -u root -p")
psql -U postgres
CREATE DATABASE codepilotdb;

Type \q to exit the shell.

Option B: Use a free hosted PostgreSQL (recommended for deployment)

Since you're deploying (not just running locally), a managed Postgres instance saves you from installing anything:

  • Render – free Postgres instance, pairs naturally with a Render web service for the Spring Boot app
  • Railway – one-click Postgres, gives you a connection URL instantly
  • Supabase – free Postgres with a nice dashboard
  • Neon – free serverless Postgres

Any of these will hand you four values you need in step 2: host, port, database name, username, password (or one combined connection URL).


2. Configure the database connection

The app already reads these as environment variables (with local defaults baked in), so you don't need to edit application.properties at all — just set env vars:

Variable Example (local) Example (hosted)
SPRING_DATASOURCE_URL jdbc:postgresql://localhost:5432/codepilotdb jdbc:postgresql://<host>:5432/<dbname>
SPRING_DATASOURCE_USERNAME postgres (given by your host)
SPRING_DATASOURCE_PASSWORD (your local password) (given by your host)
JWT_SECRET any long random string same
GEMINI_API_KEY your key from aistudio.google.com/app/apikey same

Locally, you can set these in your terminal before running, e.g.:

export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/codepilotdb
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=your_local_password
export JWT_SECRET=change_this_to_a_long_random_string
export GEMINI_API_KEY=your_gemini_key

On your host (Render/Railway/etc.), set the same names in the service's "Environment Variables" panel — most hosted Postgres providers give you a ready-made SPRING_DATASOURCE_URL-style connection string you can paste directly.

If you'd rather hardcode values for a quick local test, you can still edit them directly in src/main/resources/application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/codepilotdb
spring.datasource.username=postgres
spring.datasource.password=YOUR_POSTGRES_PASSWORD

No manual table creation needed — spring.jpa.hibernate.ddl-auto=update means Hibernate creates/updates all tables automatically on startup.


3. Run the backend

./mvnw spring-boot:run

Runs on http://localhost:8080. On first startup:

  • 44 practice questions are seeded automatically (with company tags)
  • A default admin account is created: admin@codepilot.ai / Admin@123 — change this password in any real deployment, and use it to access /admin.html

4. Use the app

Open http://localhost:8080 — you'll be routed to login/register automatically.

Page Path
Register /register.html
Login /login.html
Forgot password /forgot-password.html
Dashboard /dashboard.html
Practice Questions /questions.html → click into /question.html?id=N
Companies /companies.html
AI Interviewer /mentor.html
Resume Analyzer /resume.html
Mock Interview /mock-interview.html
Admin Panel /admin.html (ADMIN role only)

Deploying (Docker)

A Dockerfile is included and builds/runs the app out of the box:

docker build -t codepilot-ai .
docker run -p 8080:8080 \
  -e SPRING_DATASOURCE_URL=jdbc:postgresql://<host>:5432/<dbname> \
  -e SPRING_DATASOURCE_USERNAME=<user> \
  -e SPRING_DATASOURCE_PASSWORD=<password> \
  -e JWT_SECRET=<your_secret> \
  -e GEMINI_API_KEY=<your_key> \
  codepilot-ai

Point SPRING_DATASOURCE_URL at your hosted Postgres instance from step 1B and it just works — no code changes needed.


Coming from MySQL? Quick cheat-sheet

What you know (MySQL) Postgres equivalent
mysql -u root -p psql -U postgres
SHOW DATABASES; \l
USE mydb; \c mydb
SHOW TABLES; \dt
DESCRIBE table_name; \d table_name
MySQL Workbench (GUI) pgAdmin (GUI, installed alongside Postgres) or TablePlus
Default port 3306 Default port 5432
Default admin user root Default admin user postgres
AUTO_INCREMENT SERIAL / GENERATED ALWAYS AS IDENTITY (Hibernate handles this for you automatically — no action needed)

You don't need to write any raw SQL yourself for this project — Hibernate/JPA generates and manages all the tables. You only need psql/pgAdmin to create the initial empty database and, optionally, to peek at the data.


API Overview

Method Endpoint Auth Description
POST /api/auth/register No Create account
POST /api/auth/login No Log in
POST /api/auth/forgot-password No Get a reset token
POST /api/auth/reset-password No Reset password with token
GET /api/questions/all No List all questions
GET /api/questions/{id} No Get one question
GET /api/questions/topic/{topic} No Filter by topic
GET /api/questions/difficulty/{difficulty} No Filter by difficulty
POST/PUT/DELETE /api/questions/... ADMIN Manage questions
POST /api/mentor/ask Yes Chat with AI Interviewer
POST /api/mentor/hint Yes Get a progressive hint (level 1-3)
GET/POST /api/progress, /api/progress/update Yes Dashboard stats
GET /api/progress/heatmap Yes Activity heatmap data
GET/POST/DELETE /api/bookmarks Yes Manage bookmarks
GET/PUT /api/notes/{questionId} Yes Per-question notes
POST /api/resume/analyze Yes Upload + analyze resume PDF
GET /api/admin/users ADMIN List all users

Full interactive docs: http://localhost:8080/swagger-ui.html

Project structure

codepilot-ai/
├── pom.xml
├── Dockerfile
└── src/main/
    ├── java/CodePilotAI/
    │   ├── config/     (Security, CORS, Swagger, WebClient, DataSeeder, AdminSeeder)
    │   ├── controller/ (Auth, Question, Mentor, Bookmark, Progress, Note, Resume, Admin)
    │   ├── dto/
    │   ├── entity/     (User, Question, Bookmark, StudentProgress, Note, ActivityLog, PasswordResetToken)
    │   ├── exception/
    │   ├── repository/
    │   ├── security/   (JWT service, filter, UserDetailsService)
    │   └── service/
    └── resources/
        ├── application.properties
        └── static/     (13 pages — see table above)

Design notes & honest limitations

  • Forgot password works end-to-end (token generation, expiry, reset), but since there's no SMTP server configured, the reset token is returned directly in the API response and shown on-screen instead of emailed. Wire up a mail sender in UserService if you need real email delivery.
  • Contest rating is an internal gamified score (+5/+12/+25 per easy/medium/hard solve), not a true competitive rating system — there's no real contest infrastructure behind it.
  • Company tags are topic-based groupings for practice variety, not a verified "this exact question was asked at this company" dataset.
  • No real code execution/judging — there's a code editor to draft your solution and a "Mark Solved/Attempted" flow that updates your dashboard, plus a direct link to the real LeetCode problem to verify. Building an actual sandboxed code judge (running arbitrary user code safely) is a separate, much larger project with real security considerations.
  • Resume ATS scoring is AI-generated (Gemini) based on resume text extracted via PDFBox — treat scores as directional feedback, not a certified ATS simulation.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages