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
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.
The following models were created to represent the database model structure of the application:
- 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
- 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
- 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
- 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
- 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
- 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
- Python
- Django
- 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
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.
The following tests were carried out on the app:
- Manual testing of user stories
- Automated testing
- 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.
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
- 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.