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
This project is built on top of the Python FastApi framework using the awesome cloud based MongoDB Atlas database.
- Python 3.9
- FastApi
- MongoDB Cloud Atlas
- MongoEngine
git clone https://github.com/manukanne/cloudatlas-quiz-api.git
To download python, please vistit this link.
For this project the following Python version was used: 3.9.*
For more information on how to create please visit this link.
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
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
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.
This project is licensed under the Apache-2 permissive license - see the Licence file for details.
Inspiration, code snippets, etc.