ExamHub is an online exam system built with Spring Boot and Spring Cloud Microservices Architecture.
- Eureka Server (
8761): Service Registry. - API Gateway (
8080): Central entry point to the system, validates JWT tokens. - Auth Service (
8081): Manages user registration and login (generates JWTs). connects toexamhub_auth. - Exam Service (
8082): Manages exams and questions. connects toexamhub_exam. - Result Service (
8083): Evaluates exams. connects toexamhub_result.
- Java 17+ (Backend microservices)
- Maven (Backend dependencies)
- MySQL (Database)
- Node.js (v18+) & npm (To run the React frontend)
- Git (For version control)
Open MySQL shell or Workbench and run:
CREATE DATABASE examhub_auth;
CREATE DATABASE examhub_exam;
CREATE DATABASE examhub_result;Ensure your MySQL credentials are root / Aastha19@ on localhost:3306, or update application.properties in each service. The tables will be auto-created by Hibernate.
In each folder (eureka-server, api-gateway, auth-service, exam-service, result-service), run:
mvn clean installRun each service in this specific order:
- Eureka Server:
mvn spring-boot:run - API Gateway
- Auth Service
- Exam Service
- Result Service
Check http://localhost:8761 to verify all services are registered with Eureka.
Note
For all requests except Auth, pass the JWT token in the Authorization header as Bearer <token>.
POST http://localhost:8080/auth/register
{
"name": "Student One",
"email": "student1@example.com",
"password": "password123",
"role": "ROLE_STUDENT"
}POST http://localhost:8080/auth/login
{
"email": "student1@example.com",
"password": "password123"
}Response will be your raw JWT token string. Keep this token for further requests.
POST http://localhost:8080/api/exams/create
Headers: Authorization: Bearer <TOKEN>
{
"title": "Java Basics",
"description": "Basic Java terminology and concepts"
}POST http://localhost:8080/api/exams/{exam_id}/questions
Headers: Authorization: Bearer <TOKEN>
{
"text": "What is JVM?",
"optionA": "Java Viral Machine",
"optionB": "Java Virtual Machine",
"optionC": "Java Visual Machine",
"optionD": "None",
"correctOption": "B"
}POST http://localhost:8080/api/results/submit
Headers: Authorization: Bearer <TOKEN>
{
"examId": 1,
"userId": 1,
"answers": {
"1": "B"
}
}