Skip to content

tomaszbar9/picturesque_api

Repository files navigation

Picturesque API

Description:

Picturesque API is a REST API version of my CS50 final project Picturesque, which is a web application allowing a user to create a collection of posts matching literature quotes with photos. An example can a picture showing a place where the action takes place. That is why the website's users can also mark relevant places on the map. The full description of the Picturesque application is available here and there is also a short video presentation on YouTube.

The API version of the application has all the functionalities of the previous one: a user can register, log in, create a post (uploading an image) and even 'mark' the place on the map by sending coordinates or an address. My goal was just to create a better structured and easier maintainable backend, and this time to deploy it.

The program is written in Python 3.11 using Flask Smorest framework, and is deployed on render.com. The images storing is managed by Cloudinary.com, a PostgreSQL database is hosted on ElephantSQL.com, and to store revoked access tokens I use redis service also on render.com.

The deployed application is currently populated by 'populate.py' script with random data.

The full API documentation is available here: https://picturesque-r6r7.onrender.com/swagger-ui


Endpoints:

  • /register

    POST - register user

    DELETE - remove account

  • /login

    POST - authenticate user

  • /logout

    DELETE - revoke JWT

  • /refresh

    POST - get non-fresh token

  • /users/<id>/posts

    GET - get all user's posts

  • /users/<id>/collections

    GET - user's collections

  • /users/recommendations

    POST - show recommendations for user (access token required)

  • /posts [/?q=<search phrase>&page=<int>&page_size=<int>]

    GET - get all posts or by a search phrase (results paginated)

    POST - create post (access token required)

  • /posts/<id>

    GET - get one post

    PUT - update post (access token required)

    DELETE - remove post (access token required)

  • /authors

    GET - get all authors (results paginated)

  • /authors/<id>

    GET - get one author

  • /titles

    GET - get all titles (results paginated)

  • /titles/<id>

    GET - get one title

  • /collections/<id>

    POST - add post to user's collection (access token required)

    DELETE - remove post from user's collection (access token required)