Git Product home page Git Product logo

favorites-backend's Introduction

Favorite Things Backend

A backend app to help keep track of your favorite things!

Disclaimer

This project has been built by using our custom cookie-cutter project that was built overtime in our careers. This is still a work in progress and having used this might mean there are a few extra libraries and functionality that are present but unused in this project. I chose to use this cookie cutter for rapid development and deployment purposes.

Also would prefer to use django-dirty-fields to track my model field changes, since my applied ModelDiffMixin might not cover most cases of state changes.

Database Entity Relationship of models

Favorite Things ER

  • A user can have many different favorite things
  • One category can have multiple favorite things
  • One favorite thing can have one category
  • Only showing the PK and FK labels
  • Used built in admin log entry models to save audit log changes. I took this approach because I thought it better to use something django already provides. This will also allow us to query for changes on a specific date. The change message stores the favorite field value model object changes.

(P.S: I think it might have been better to create another model based off of the LogEntry model for logging our model changes and not having conflicts since changes made by the admin panel are also being save in our currently used log entry model.)

Deployment

  • Deployed using dokku on a remote AWS instance (nano)
  • Added ssl using dokku built in methods since our front end that was deployed using netlify and it enabled ssl over there. As a result we had to add a certificate in order to consume our backend resources
  • Deployed link: http://13.235.4.179/
  • Login credentials:
    • username: admin
    • password: admin12345

Example requests and responses

POST http://13.235.4.179/api/v1/favorites/

request data

{
    "category": "food",
    "title": "burger",
    "ranking": 1,
    "metadata": null,
    "description": ""
}

response

{
    "id": 1,
    "logs": [],
    "category": "food",
    "created_date": "2019-06-26",
    "modified_date": "2019-06-26",
    "title": "burger",
    "ranking": 1,
    "metadata": null,
    "description": ""
}

PUT http://13.235.4.179/api/v1/favorites/1/

request data

{
    "category": "food",
    "title": "pizza",
    "ranking": 1,
    "metadata": null,
    "description": ""
}

response

{
    "id": 1,
    "logs": [
       "{'title': ('burger', 'pizza')}"
    ],
    "category": "food",
    "created_date": "2019-06-26",
    "modified_date": "2019-06-26",
    "title": "burger",
    "ranking": 1,
    "metadata": null,
    "description": ""
}

GET http://13.235.4.179/api/v1/favorites/

response

[
  {
    "id": 1,
    "title": "person",
    "favorite_things": []
  },
  {
    "id": 2,
    "title": "place",
    "favorite_things": [
      {
        "id": 2,
        "logs": [
            "{'title': ('bangkok', 'tokyo')}"
        ],
        "category": "place",
        "created_date": "2019-06-26",
        "modified_date": "2019-06-26",
        "title": "tokyo",
        "ranking": 1,
        "metadata": null,
        "description": ""
      }
    ]
  }
]

GET http://13.235.4.179/api/v1/favorites/1/

response

{
    "id": 1,
    "logs": [
        "{'title': ('burger', 'pizza')}"
    ],
    "category": "food",
    "created_date": "2019-06-26",
    "modified_date": "2019-06-26",
    "title": "pizza",
    "ranking": 1,
    "metadata": null,
    "description": ""
}

DOCUMENTATION: http://13.235.4.179/docs/

Docker compose commands to run project:

Make sure you have docker and docker compose installed docker-compose up --build

Pytest:

  • Log into docker compose shell via exec: docker-compose exec web bash
  • Run this command in shell: pytest

favorites-backend's People

Stargazers

 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.