Skip to content

MaxAndreasLundin/QuizGenie

Repository files navigation

Overview

QuizGenie allows users to generate quizzes based on text provided directly or by scraping text from a webpage URL. The application currently supports two main endpoints.

Endpoints

  • POST /text
  • POST /url

1. POST /text

This endpoint accepts a JSON object containing text data. It generates a quiz based on the provided text.

  • Request URL: http://localhost:3000/text

  • Method: POST

  • Content-Type: application/json

  • Request Body:

    {
      "text": "Your text here"
    }
  • Response:

    {
      "quiz": {
        "title": "Quiz Title",
        "questions": [
          {
            "question": "Question 1?",
            "answer": "Answer 1"
          },
          {
            "question": "Question 2?",
            "answer": "Answer 2"
          }
          // More questions...
        ]
      }
    }

2. POST /url

This endpoint accepts a JSON object containing a URL. It scrapes text content from the provided URL and generates a quiz based on the scraped text.

  • Request URL: http://localhost:3000/url

  • Method: POST

  • Content-Type: application/json

  • Request Body:

    {
      "url": "https://example.com/page"
    }
  • Response:

    {
      "quiz": {
        "title": "Quiz Title",
        "questions": [
          {
            "question": "Question 1?",
            "answer": "Answer 1"
          },
          {
            "question": "Question 2?",
            "answer": "Answer 2"
          }
          // More questions...
        ]
      }
    }

TypeScript Interfaces

For TypeScript users, here are the interfaces for the response data:

interface QuizQuestion {
  question: string;
  answer: string;
}

interface QuizResponse {
  title: string;
  questions: QuizQuestion[];
}

3. Setup

Clone the Repository

git clone https://github.com/MaxAndreasLundin/QuizGenie
cd quizgenie

Create a .env File

Create a .env file in the root directory with the following content:

QUIZGENIE_OPENAI_API_KEY=your_openai_api_key

4. Usage

Run with docker

Installation instructions for Docker: https://docs.docker.com/compose/install/

docker compose build
docker compose up

Run with Bun

Installation instructions for Bun: https://bun.sh/docs/installation

Install dependencies.

bun install

To start the server.

bun start

5. Send Requests

Use a tool like curl, Postman, or any HTTP client to send POST requests to the endpoints.

Examples POST /text Example

curl -X POST http://localhost:3000/text \
 -H "Content-Type: application/json" \
 -d '{
"text": "Volvo CE is a leading international manufacturer of premium construction equipment..."
}'

POST /url Example

curl -X POST http://localhost:3000/url \
 -H "Content-Type: application/json" \
 -d '{
"url": "https://en.wikipedia.org/wiki/Volvo_Construction_Equipment"
}'

Notes

Ensure the text provided is substantial enough for quiz generation. For the /url endpoint, the scraper targets common content elements to work across various websites.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published