Coder Social home page Coder Social logo

tangent's Introduction

Comment Tone Analyzer Api

This api follows restful architecture and provides two endpoints for crud operations:

/comments

  • GET - For retrieval of all resources. Response is list of comments and status code 200 if successful.
  • POST - To submit a new comment send a POST request with 'comment' as parameter and the actual comment as a value. Succesful response contains the new comment with tone if identified and status code 201. API returns 400 if comment is missing.

/comments/{sku}

  • GET - Returns comment with the specified sku if it exists else returns 404.
  • PUT - Update the comment of the specific resource by submitting a new comment in the body. Returns the new comment and tone if it exists else returns 404.
  • DELETE - Deletes the resources if it exists else returns 404.

Setup

  1. Create and activate virtualenv with python 3.6
  2. Pip install -r requirements.txt
  3. Database creation and migration with python migration.py db upgrade
  4. Run tests with python test_api.py
  5. Run Server with flask run while in root dir

Scalability

  • The api can easily scale horizontally on multiple instances since it is stateless. They can all be located behind a load-balancer that would route requests between the servers, the database would be stored on separate instances(AWS RDS) to complitely decouple the architecture.
  • To easily handle a large number of requests caching would be important. Solutions such as Redis and Memcache can help drastically decrease load on the servers.
  • For even larger scale a NoSQL database can replace the SQL solution in order to increase the amount of concurrent writes that the database can handle.

Restful Api

  • Simple uniform interface
  • The api is stateless as is required by the Representational State Transfer architecture. Each request contains the necessary state to be handled correctly by the server.
  • Responses are cacheable
  • Client server separation

Architecture

Given the small scope of the project I made the decision to use Flask web framework as it is light and well suited to small api development and SQLite as a database since the project is not intended for production. The main api is isolated in its own folder that contains main api logic and models. The main folder contains the test file, migrations and run command. I used Application Factory in order to have instances with different settings specifically for testing.

tangent's People

Contributors

bash-maistora avatar

Watchers

 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.