Skip to content

Triva API is the second project for the 2019 Udacity Full-stack Developer Nanodegree. The project is associated with the API Development and Documentation course.

License

Notifications You must be signed in to change notification settings

wanderindev/trivia-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful API for Udacity trivia application 🏆

Documentation Maintenance Coverage License: MIT Twitter: JavierFeliuA

Triva API is the second project for the 2019 Udacity Full-stack Developer Nanodegree. The project is associated with the API Development and Documentation course. Visit this repository for the starter code and project instructions.

Project overview

The project contains a working frontend and a starter code for a backend.

The work performed on the frontend was limited to adding CSS to improve the application look and feel, fixing inconsistent indentation, removing unnecessary returns, adding alt attributes to images, and fixing the number of arguments in some function signatures.

In the backend, I added all the endpoints required by the frontend, completed the SQLAlchemy models, and added automated tests.

How to use

Note: I recorded a short video showing all setup steps, running the tests and coverage report, and connecting with Postman and with the frontend.

To complete the steps, you need three terminal windows: one for running the frontend, one for running the database, and one for running the backend.

Clone the repository

In the first terminal window, clone the repository and cd into the project root:

git clone https://github.com/wanderindev/trivia-api.git
cd trivia-api

The database

I included a Dockerfile and a docker-compose.yml that runs a Postgresql instance, creates two databases (one for development and one for testing), and adds mock data to the development database.

If you have Docker installed and configured in your system, this is the recommended way for running the database. Otherwise, create and initialize the databases in your own Postgresql instance and adjust the connection string in config.py.

To use the included Postgresql setup, cd into the backend directory and run docker-compose:

cd backend
docker-compose up --build

The backend

In the second terminal window, cd into the project root, create a virtual environment, and activate it:

cd trivia-api
python3 -m venv venv
. venv/bin/activate

Install the project requirements:

cd backend
pip install -r requirements.txt

To run the tests, use:

coverage run -m unittest tests/system_tests.py tests/integration_tests.py tests/unit_tests.py

To run the RESTful API, use:

export FLASK_APP=run
flask run

With the API running, you can connect to the different endpoint using the included Postman collection (trivia_api.postman_collection) or running the frontend.

The frontend

In the third terminal window, cd into frontend directory:

cd trivia-api/frontend

Install the project dependencies:

npm install

Start the frontend:

npm start

API documentation

For additional information about the API endpoints, visit the API documentation.

References

Effective Python by Brett Slatkin

Flask Web Development by Miguel Grinberg

Essential SQLAlchemy by Jason Myers and Rick Copeland

Quickly Create Custom API Documentation

Example Google Style Python Docstrings

Author

👤 Javier Feliu

Starter code provided by Udacity.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2019 Javier Feliu.

This project is MIT licensed.


I based this README on a template generated with ❤️ by readme-md-generator

About

Triva API is the second project for the 2019 Udacity Full-stack Developer Nanodegree. The project is associated with the API Development and Documentation course.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published