Trivia is a Spring Boot application designed to manage trivia questions across various programming languages. It integrates MongoDB for data storage and exposes a RESTful API to manage questions. Additionally, it leverages Swagger to document the API and provide an interactive UI for testing the endpoints.
- Question Management: Add, update, and delete trivia questions for multiple programming languages.
- Report Management: Mark trivia questions as resolved or unresolved based on reports.
- Difficulty Levels: Categorize questions by difficulty (Easy, Medium, Hard).
- Random Selection: Fetch random questions based on difficulty.
- Swagger Integration: Provides API documentation and an interactive interface for testing.
- Exception Handling: Custom error handling for invalid inputs and rate-limiting.
- Technologies Used
- Getting Started
- Installation
- Running the Application
- API Endpoints
- Swagger Documentation
- Contributing
- License
- Java 17
- Spring Boot 3.3.3
- MongoDB for the database.
- Postgres for second database.
- Swagger for API documentation.
- Lombok for reducing boilerplate code.
- Maven for project management and build automation.
- Jackson for JSON processing.
To get a copy of the project running on your local machine, follow the steps below.
- Java 17 or higher.
- Maven for building the project.
- MongoDB for the database.
-
Clone the repository:
git clone https://github.com/Skill-Forge-Project/skill_forge_trivia.git cd skill_forge_trivia
-
Install dependencies:
mvn clean install
-
Set up MongoDB:
Ensure MongoDB is running locally, or update the connection string in
application.properties
orapplication.yml
with your MongoDB instance details. -
Create application-env.properties in main directory with the Postgres username and password.
You can run the application using the following methods:
-
Using Maven:
mvn spring-boot:run
-
Using the JAR file:
java -jar target/Trivia-0.0.1-SNAPSHOT.jar
Here are some key API endpoints:
-
Get Random Questions:
GET /trivia/{language}/{difficulty}
-
Add a New Question:
POST /trivia/questions/{language}/{difficulty}
-
Update a Question:
PUT /trivia/questions/{language}/{id}
-
Delete a Question:
DELETE /trivia/questions/{language}/{id}
-
Mark a Reported Question as Resolved:
PUT /trivia/reports/{id}/resolve
Replace {language}
with java
, csharp
, javascript
, or python
. Replace {difficulty}
with Easy
, Medium
, or Hard
.
Swagger provides an interactive interface for testing the API. Once the application is running, visit:
http://localhost:8080/swagger-ui.html
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push to your fork.
- Submit a pull request with a detailed description of your changes.
This project is licensed under the MIT License. See the LICENSE file for more details.