quizDaddy is a web application for students to upload their notes and materials to generate flashcards and quizzes using ChatGPT API for their enhanced learning. Empowered by our spaced repetition algorithm, revision is structured and maximised for upcoming exams.
- User Authentication and Authorization: Secure sign-up and login using JWT. Email verification for users.
- CRUD Operations for Data Management: Full CRUD functionality for flashcards, quizzes, and user profiles.
- OpenAI Integration: Integrates with OpenAI’s ChatGPT API to generate quiz questions and answers from user-uploaded notes.
- Cross-Origin Resource Sharing (CORS): Configured CORS to allow secure communication between the frontend and backend.
- MySQL Database Integration: Efficient data storage and retrieval with complex queries.
- Input Validation and Error Handling: Ensures data integrity and security with meaningful error messages.
- Environment Configuration with dotenv: Manages sensitive data like API keys and database credentials.
- Spaced Repetition Algorithm: Schedules flashcard reviews to optimize learning and retention.
- Automated Email Notifications: Sends verification
- File Uploads with Multer: Supports uploading user notes and materials for generating quizzes and flashcards.
- Node.js
- Express
- MySQL
- dotenv
- nodemailer
- Json Web Tokens
- multer
- bcrypt
- cors
- Openai
- pdf-parse
- punycode
- util
- whatwg-url
- nodemon
-
Clone the repository:
git clone https://github.com/HEAPS-ACTUAL/backend.git cd backend -
Install the dependencies:
npm install
-
Set up the database:
# Assuming you have MySQL installed and running run quizDaddy.sql script in your MySQL Workbench environment
- Create a
.envfile in the root directory and add the following configuration:# STANDARD CONFIGURATION BE_PORT=your-backend-port FE_PORT=your-frontend-port CHATGPT_MODEL="gpt-4o-mini" CHATGPT_ROLE="user" CHATGPT_TEMP="0.7" CHATGPT_MAX_TOKENS=3000 CHATGPT_NUM_OF_QUESTIONS=12 # for quizzes APP_EMAIL=your-app-email # for sending emails APP_EMAIL_PASSWORD=your-gmail-app-password # generated by gmail JWT_SECRET_KEY=your-token-key # generated 32 byte string encoded in base 64 through openssl rand -base64 32 DB_NAME="heap" #quizDaddy.sql uses this database name # CHANGE ACCORDINGLY OPENAI_API_KEY=your-chatgpt-api-key DB_PASSWORD=your-db-password # TO CHANGE WHEN DEPLOYING DB_USER="root" DB_ENDPOINT="localhost" FRONTEND_ENDPOINT="http://localhost:3000"
-
Start the backend server:
npm run devStart
You should see the following in the terminal:
- Server is listening on port 8001
- Successfully connected to DB!
- Server is ready to send out emails
-
The API will be available at
http://localhost:8001. -
Open Frontend Repository
Here are some of the main endpoints available:
POST /email/verify-email- Verify a User Email through JWT TokenPOST /email/send-verification-email- Send a verification email to specified User
GET /flashcard/getAllFlashcardsWithoutSchedule- get an array of flashcards that have not been scheduledGET /flashcard/getFlashcardsByScheduleID- get an array of flashcards that have been scheduled in Calendar
POST /quiz/markQuizAsDone- Set quiz completion in the databasePOST /quiz/storeUserQuizAnswers- Post a User's response for each question of a quiz in the DBGET /quiz/reviewQuiz- get a JSON formatted array of questions and user's choicesGET /quiz/getLatestAttempt- get the latest attempt number to store a new quiz
POST /schedule/createNewExam- Post a new Exam Revision schedule using start date and end dateGET /schedule/retrieveAllRevisionDates- get all the revision dates for calendarDELETE /schedule/deleteExistingExam- delete all revision dates for specified flashcard from calendarDELETE /schedule/deleteSpecificRevisionDate- delete one specified date instead from the revision schedule
POST /test/generateAndStoreTest- create a test from uploaded file and store in dbDELETE /test/deleteTest- delete a test from dbGET /test/getTestInfo- get all the tests for the userGET /test/getQuestionsAndOptions- get questions and options for specified test
GET /user/profile- get info for profile pagePOST /user/authenticate- authenticate user for log inPOST /user/register- Register a new userDELETE /user/delete- Delete a user's accountPOST /user/update- Update a user's attributes
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name) - Make your changes
- Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature-name) - Open a Pull Request