Skip to content

API set up using Django REST Framework for Harmonize Front-End application

Notifications You must be signed in to change notification settings

JureSeselj/harmonize-drf-api

Repository files navigation

Harmonize - Django REST Framework API

Overview

This repository serves as Harmonize App Backend REST API. The purpose is to provide data to be used in Front-End design with React. js. For the main projects documentation refer to Harmonize project. The API endpoint can be found here

Table of Contents

User Stories - UX

The back-end section of the project focuses on its administration side and covers one user story:

  • As an admin, I want to be able to create, edit and delete the users, posts, comments and likes, so that I can have a control over the content of the application and remove any potential inappropriate content.

Database

The following models were created to represent the database model structure of the application:

User Model

  • The User model contains information about the user. It is part of the Django allauth library.
  • One-to-one relation with the Profile model owner field
  • ForeignKey relation with the Follower model owner and followed fields
  • ForeignKey relation with the Post model owner field
  • ForeignKey relation with the Comment model owner field
  • ForeignKey relation with the Like model owner field

Profile Model

  • The Profile model contains the following fields: owner, name, description, created_on, updated_on and image
  • One-to-one relation between the owner field and the User model id field

Post Model

  • The Post model contains the following fields: owner, created_on, updated_on, title, description, category and image
  • ForeignKey relation with the Comment model post field
  • ForeignKey relation with the Like model post field

Follower Model

  • The Follower model contains the following fields: owner, followed and created_on
  • ForeignKey relation between the owner field and the User model id field
  • ForeignKey relation between the followed field and the User model post field

Comment Model

  • The Comment model contains the following fields: owner, post, created_on, updated_on and content
  • ForeignKey relation between the owner field and the User model id field
  • ForeignKey relation between the post field and the User model post field

Like Model

  • The Like model contains the following fields: owner, post and created_on
  • ForeignKey relation between to the User model id field
  • ForeignKey relation between the owner field and the User model id field
  • ForeignKey relation between the post field and the Post model post field

Back to Top

Technologies Used

Languages & Frameworks

  • Python
  • Django

Libraries & Tools

  • GitHub was used as a remote repository to store project code
  • Gitpod) - a virtual IDE workspace used to build this site
  • APITestCase - Django Rest Framework APITestCase was used for automated testing
  • Cloudinary to store static files
  • Coverage used to produce automated testing report
  • Dbdiagram.io used for the database schema diagram
  • Git was used for version control via Gitpod terminal to push the code to GitHub
  • Django REST Framework was used to build the back-end API
  • Django AllAuth was used for user authentication
  • Pillow was used for image processing and validation
  • Psycopg2 was used as a ElephantSQL database adapter for Python
  • Heroku was used to deploy the project into live environment
  • ElephantSQL – deployed project on Heroku uses a ElephantSQL database

Validation

PEP8 Validation

All code was formatted using autopep8. Additionally, manual validation was done with PEP8 online.

The only code which was left with long-line prompts is settings.py for code functionality.

Testing

The following tests were carried out on the app:

  1. Manual testing of user stories
  2. Automated testing

Manual testing of user stories

  • As an admin, I want to be able to create, edit and delete the users, posts, comments and likes, so that I can have a control over the content of the application and remove any potential inappropriate content
Test Action Expected Result Actual Result
User Create, update & delete user A user can be created, edited or deleted Works as expected
User Change permissions User permissions can be updated Works as expected
Profile Create, update & delete User profile can be created, edited or deleted Works as expected
Post Create, update & delete A post can be created, edited or deleted Works as expected
Comment Create, update & delete A comment can be created, edited or deleted Works as expected
Like Create & delete A like can be created or deleted (like / unlike post) Works as expected
Follower Create & delete Follow or unfollow user Works as expected

In addition, posts, comments, likes and following can be created by logged-in users only. Users can only update or delete the content which was created by themselves.

USER

Create user
Change user permissions

PROFILE

Update profile
Delete profile

POST

Create post
Update post
Delete post

COMMENT

Create comment
Update comment
Delete comment

LIKE

Create like - like post
Delete like - unlike post

FOLLOWER

Create - Follow user
Delete - Unfollow user

Automated testing

Automated testing was done using the Django Rest Framework APITestCase (a very similar to Django's TestCase). The report of overall testing was produced using the coverage tool ($ coverage report & $ coverage html commands)

  • Tests summary

Detailed coverage report

Credits

Content

  • Project setup is based on Code Institute tutorial video Django REST Framework.
  • The Comment app is copied from Code Institute tutorial Django REST Framework and adjusted as needed.
  • Email confirmation functionality inspired from Stack Overflow.
  • Deployment section is based on the owner's previous project TastyBlog.

Information Sources / Resources

Back to Top


Copyright @ Jure Seselj 2023

About

API set up using Django REST Framework for Harmonize Front-End application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published