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.
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.
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.
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
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
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.
In the third terminal window, cd into frontend directory:
cd trivia-api/frontend
Install the project dependencies:
npm install
Start the frontend:
npm start
For additional information about the API endpoints, visit the API documentation.
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
👤 Javier Feliu
- Twitter: @JavierFeliuA
- Github: @wanderindev
Starter code provided by Udacity.
Give a ⭐️ if this project helped you!
Copyright © 2019 Javier Feliu.
This project is MIT licensed.
I based this README on a template generated with ❤️ by readme-md-generator