Giter Site home page Giter Site logo

api's Introduction

Overview

HadithAPI leverages a serverless architecture.

Package Structure

├── Makefile
├── README.md
├── api.raml
├── hadith_api
│   ├── __init__.py
│   ├── app.py
│   ├── chalicelib
│   │   ├── __init__.py
│   │   ├── collections.py
│   │   ├── db.py
│   │   ├── models.py
│   │   ├── rds_config.py
│   │   ├── responder.py
│   │   └── singleton.py
│   └── requirements.txt
├── requirements.txt
└── test
    ├── requirements.txt
    └── unit

Getting started

The HadithAPI uses Chalice to manage the Lambda code. Here, all of the Chalice commands are abstracted with make in order to simplify. It also uses virtualenv to contain all of the installations. Get started with develop by doing the following:

git clone REPO
cd REPO
pip install -r requirements.txt
make develop
source .env/bin/activate

When finished, remember to deactivate the virtualenv.

Development

Assuming you've completed the setup, simply run:

make run

BUT WAIT! Before you can use the API locally, you need to seed the database. The DB is not public, so you'll need to contact a collaborator for access. MySQL server needs to be running locally in order for this step to work.

To get started run:

mysql -u root -p < setup.sql

When prompted for the password, just hit enter.

This completes the basic setup - and you should be able to start the application on localhost:8000.

Testing

make run

run an AWS APIGateway-esque instance of the application. This starts a server on port 8000 that's responsive to queries (would recommend using curl).

make lint

Run Flake8 on the code under hadith_api/

make test

Run pytest unit tests and print coverage. It should Ideally be expanded to include integration tests

Routes

GET /hadith

Retrieves list of all hadith

GET /hadith/{hadithNumber}

Retrieves list of all hadith by number

GET /books

Retrieves list of all books

GET /books/{bookNumber}

Retrieves book by id

GET /collections

Retrieves list of all collections

GET /collections/{collectionName}

Retrieves a specific collection

GET /collections/{collectionName}/books

Retrieves list of books in a specific collection

GET /collections/{collectionName}/books/{bookNumber}

Retrieves book within specific collection

GET /collections/{collectionName}/books/{bookNumber}/hadiths

Retrieves ahadith for specific book and collection

GET /collections/{collectionName}/books/{bookNumber}/hadiths/{hadithNumber}

Retrieves specific hadith for specific book and collection

TODO

  1. Enforce RAML spec
  2. Bootstrap test run to local mysql instance
  3. Implement staging (dev/beta, prod)
  4. Travisci integration
  5. Test deployment
  6. Simplify AWS credential setup
  7. Add diagram
  8. Actually write the README
  9. Add docstrings and comments to code
  10. Add caching to DAO layer
  11. Add integration tests

api's People

Contributors

ammaristotle avatar mha6 avatar

Watchers

James Cloos 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.