Skip to content

manukanne/cloudatlas-quiz-api

Repository files navigation

MongoDB Quiz API

This project was created as part of the MongoDB Hackathon, it is a quiz API that provides the following functions:

  • Authentication/ Authorization using OAuth2
  • CRUD Operations for quiz categories
  • CRUD Operations for quizzes
    • Including Quiz submition and calulating the total and reached points
  • Also, the project is fully covered by unit tests

Getting Started

This project is built on top of the Python FastApi framework using the awesome cloud based MongoDB Atlas database.

Dependencies

Tech-stack

Installing

1. Clone the git repo:

git clone https://github.com/manukanne/cloudatlas-quiz-api.git

2. Download and install Python

To download python, please vistit this link.

For this project the following Python version was used: 3.9.*

3. Create a python virtual envrionment:

For more information on how to create please visit this link.

4. Install the required packages

pip install requirement.txt

For more information, please vist this link.

For a full list of all dependices, have a look at the file requirements.txt

5. Create the .env paramater file

Create a file named ".env" Specify the parameters as needed:

AUTH_SECRET_KEY=MY_SECRET_KEY
AUTH_ALGORITHM=HS256
MONGODB_CONN_STR=mongodb+srv://dbuser:MY_DB_USER@MY_MONGODB_DATABASE?retryWrites=true&w=majority

For generating a secret key you can use the following command:

openssl rand -hex 32

Executing program

To start the API use the following command:

python app.py

This should start a server listening on http://127.0.0.1:8000

After starting the server you can visit the OpenAPI definition (API Docs): http://127.0.0.1:8000/docs

As previously mentioned, this projects contains unit tests. To execute the tests, use the following command:

pytest

Also, this project contains a Postman Collection

For more information on how to import a Postman Collection, please check out this link. After importing the Postman Collection, an environment must be created with the following parameters:

  • api_url
    • API url
  • username
    • Emailadress of your user (this address is used for authentication)
  • password:
    • plain text password of your user

After creating the environment, the access token can be obtained (for more information, please visit this link) This step is important because some endpoints require authentication.

Authors

Manuel Kanetscheider

License

This project is licensed under the Apache-2 permissive license - see the Licence file for details.

Acknowledgments

Inspiration, code snippets, etc.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages