Code Monkey home page Code Monkey logo

trivia-api's Introduction

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

trivia-api's People

Contributors

wanderindev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.