Skip to content

It's only a sample project with a funny name. Tagarela in Portuguese means Chatterbox (FYI - That's the funny part). It's a minified backed-RESTFul API, of a twitter-like application.

GabrielSousa02/tagarela

Repository files navigation

Tagarela

This is a sample project, demonstrating the usage of Django, Django REST Framework, Django-rest-knox.

What is Tagarela?

  • It's only a sample project with a funny name.
    • Tagarela in Portuguese means Chatterbox (FYI - That's the funny part)
  • It's a minified backed-RESTFul API, of a twitter-like application.

Installation:

  • Python version: 3.9.11

  • REQUIRED packages:

    • django>=4.0
    • django-rest-framework>=3.13.1
    • knox>=4.2.0
    • gunicorn>=20.1.0
    • psycopg2>=2.9.3
  • OPTIONAL packages:

    • django-filter>=22.1
    • Markdown>=3.3.7
    • black>=22.6.0
    • pylint>=2.14.4

It's highly recommended that you use a python virtual environment.

  • Tagarela is set to connect to a Postgresql database using these parameters:
         "default": {
         "ENGINE": "django.db.backends.postgresql_psycopg2",
         "NAME": "tagarela",
         "USER": "postgres",
         "PASSWORD": "",
         "HOST": "127.0.0.1",
         "PORT": "5432",
         }

Important:

  • This project is NOT meant for production as it is!!! The Django SECRET_KEY is only a sample key for testing.
  • If you want to use different database params, edit the path/to/tagarela/settings.py file.

Tagarela's Entity-Relationship Diagram

It can be run locally by following these steps:

  • Activate your local environment:

mac-OS and linux:

source ./.venv/bin/activate

Windows:

/.venv/Script/activate
  • Update pip and install all dependencies:

make install

or

make install-required

to install only the required packages.

Please note that some make features such as format and lint require the optional packages.

  • Run migrations to the database:

make migrations

  • Run locally:

make run

  • Optional features:
    • make format
      • This option will format your code using the black package.
    • make lint
      • This option will perform a static code analysis using the pylint package.

Example of usage

It can be found running on Heroku

  • Base URL: https://tagarela-test.herokuapp.com
  • Endpoints for user/account usage:
    • Register a user: /api/account/signup
         POST https://tagarela-test.herokuapp.com/api/account/signup
         Content-Type: application/json
         {
           "username": "Gabe",
           "first_name": "Gabe",
           "last_name": "Sousa",
           "password": "MySuperSafePassword",
           "email": "gabe@email.com.br"
         }
    • Login: /api/account/login
       POST https://tagarela-test.herokuapp.com/api/account/login
       Content-Type: application/json
       {
         "username": "Gabe",
         "password": "MySuperSafePassword",
       }
    • Logout from current device: /api/account/logout
       POST https://tagarela-test.herokuapp.com/api/account/logout
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • Logout from all devices: /api/account/logoutall
       POST https://tagarela-test.herokuapp.com/api/account/logoutall
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • See current user detail: /api/account/detail
       POST https://tagarela-test.herokuapp.com/api/account/detail
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • List all users: /api/account/
       GET https://tagarela-test.herokuapp.com/api/account/logout
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • Follow user by username: /api/account/follow
       PATCH http://localhost:8000/api/account/follow
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
       Content-Type: application/json
      
       {
           "username": "john"
       }
    • Unfollow user by username: /api/account/unfollow
      PATCH http://localhost:8000/api/account/unfollow
      Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
      Content-Type: application/json
      
      {
          "username": "john"
      }
  • Endpoints for posts:
    • See general feed: /api/post/general
       GET https://tagarela-test.herokuapp.com/api/post/general
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • See personalized feed (Only users being followed): /api/post/
       GET https://tagarela-test.herokuapp.com/api/post/
       Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
    • Create a post: /api/post
      POST https://tagarela-test.herokuapp.com/api/post/
      Authorization: Token MySuperSafeToken-79e160a07bb5b976e7a87d60b4
      Content-Type: application/json
      {
         "content": "Tweet 213214!"
      }

About

It's only a sample project with a funny name. Tagarela in Portuguese means Chatterbox (FYI - That's the funny part). It's a minified backed-RESTFul API, of a twitter-like application.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published