Skip to content

Rate My Racket is a Django + Next js (React js) Website to help tennis players to rate and find their perfect racket. It uses Django and Django Rest Framework as Backend API

Notifications You must be signed in to change notification settings

Ceci-Aguilera/rate-my-racket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate My Racket

React Image

Python version Django version Django-RestFramework version PostgreSQL version Next js version

Table of Contents

  1. Description
  2. Tech Stack and Packages Installed
  3. Install (Run) with Docker
  4. Install without Docker
  5. Structure for Docker-Compose Explained
  6. Django Files and Folders of Interest
  7. React Files and Folders of Interest
  8. About Nginx Configuration
  9. Useful Links
  10. Contributing
  11. Screenshots

Description

What is Rate My Racket?

Rate My Racket is a website that helps tennis players to find the right racket for them based on the specs they are looking for. To so, it offers a rating system that takes into account averages of ratings, the amount of users that have given an opinion about the racket, and how many times a racket has been considered as one of the 3 top choices for a feature and in what position.

Why Rate My Racket?

Finding a new tennis racket can be challenging and tricky even for advance tennis players as there are plenty of options for all playing styles, wights, and budgets. To select the best racket for a player, many parameters have to be taken into account, from the physical characteristics of the racket (weight, balance, string patters, ...) to the player own style and propose of use. As many rackets share similar specs, reading about player's pass experiences can become helpful to decide. With this in mind, Rate My Racket allows users to both rate rackets and share their experience while playing on the court. I started this project while having trouble deciding between a Head Graphene 360+ Instinct MP or a Head Graphene 360+ Speed MP, which is a perfect example of how deciding even between well-known rackets can be tricky.

Tech Stack and Packages Installed

  • Django: This is the backbone of the backend api, and has the following packages installed:

    • Django Rest Framework (For the Rest API)
    • Pillow (For managing images uploading)
    • Django-Cors-Headers (For the CORS config to allow React js to make calls)
    • Django-Environ (To Fetch the environment variables in the settings.py files)
    • Psycopg2-binary (To manage the PostgreSQL Database)
    • Gunicorn (To manage the running instance of the django web app)
    • Django-Rest-Knox (To manage Token Based Authentication)

    Note: All this packages are specified in the requirements.txt file inside the django_backend folder. Links to their official documentation can be found at the Useful Links section.

  • Next js: The frontend framework in use based on React js. This was created via npx create-next-app. The only extra packages that were installed (ignoring the ones that are automatically pre-installed) are:

    • Bootstrap and React-Bootstrap (For styling)
    • Axios (To make calls to the Django Backend)
  • Nginx: This is the server for the Docker-Compose testing build. The default configuration in use can be found at the nginx/nginx.conf file.

  • PostgreSQL: This is the default configured database for this repository. A link to How to install/configure it for Linux/Windows/MacOS is included in the Useful Links section (This is only necessary for when not running with docker-compose). In addition, a link to How to change to MySQL in Django is included as well in the Useful Links section.

Install (Run) with Docker

  1. Clone the repo:

    git clone https://github.com/Ceci-Aguilera/rate-my-racket.git
  2. Copy a default setup of the environment variables for the project:

    cp example_env .env
    cp rate-my-racket-frontend/example_env rate-my-racket-frontend/.env.local
    cp rate_my_racket_backend/rate_my_racket_backend/settings/example_env rate_my_racket_backend/rate_my_racket_backend/settings/.env
  3. (optional) Edit the values in the previous copied files to create a custom config. Note that the one set by default should work just fine for development.

  4. Run Docker-Compose:

    docker-compose up -d --build

    Congratulations !!! The app should be up and running. To access the Next js frontend go to localhost:3000, and to access the Django backend go to localhost:80.

  5. (optional) To create a super user:

       docker-compose run backend ./manage.py createsuperuser 

Install without Docker

  1. Clone the repo:

    git clone https://github.com/Ceci-Aguilera/rate-my-racket.git
  2. Copy a default configuration of the environment variables for Django:

    cp rate_my_racket_backend/rate_my_racket_backend/settings/example_env rate_my_racket_backend/rate_my_racket_backend/settings/.env
  3. (optional) Edit the values in the previous file that was copied to create a custom config. Note that the one set by default should work just fine for development.

  4. Set up the database. In this case the one in use by default is PostgreSQL. Assuming that PostgreSQL is already installed in the OS, and that the needed configurations for PostgreSQL to run in the OS are done, create a database and an user using the credentials specified in the rate_my_racket_backend/rate_my_racket_backend/settings/.env file that was just created/edited. Note: To now how to install and configure PostgreSQL, see the Useful Links section of this documentation.

  5. Change the default settings.py file in use from docker to development. To do this, go to the file rate_my_racket_backend/rate_my_racket_backend/settings/__init__.py and modify the line

    from .docker import *

    to

    from .dev import *
  6. Create and activate a virtual environment (See the Useful Links section if not know how)

  7. Install the necessary dependencies

    cd rate_my_racket_backend
    pip install -r requirements.txt
  8. Run Django:

    cd rate_my_racket_backend
    python manage.py makemigrations
    python manage.py migrate
    python manage.py runserver
  9. To configure React, from the project root folder go to rate-my-racket-frontend and install the necessary dependencies:

    cd rate-my-racket-frontend
    npm install
  10. Run React while inside the rate-my-racket-frontend folder:

    npx next dev

Congratulations !!! The app should be up and running. To access the Next js frontend go to localhost:3000, and to access the Django backend go to localhost:8000.

Structure for Docker-Compose Explained

This repository is divided into 3 main folders (not counting the .readme_assets as it contains only the images displayed in the Readme). These folders are:

  • rate_my_racket_backend: Has the Django project created with django-admin startproject.
  • rate-my-racket-frontend: Has the Next js project create with npx create-next-app.
  • nginx: Has the Dockerfile used in the docker-compose.yml file and the default config to run Django + Next js. When running the project locally without Docker this folder can be ignored.

Each project (Django and Next js as separate projects) is intended to be self contained, and so it can be separately tested without the need of docker-compose.

When running with Docker Compose, there are 4 images that are created: A Django backend Image, a Next js frontend Image, a Nginx Image, and a PostgreSQL Image. The Dockerfiles for Django, Next js, and Nginx can be found in their respective folders, i.e, the Django Dockerfile is inside the rate_my_racket_backend folder, and so on. The PostgreSQL image has no custom Dockerfile, instead it is pulled from the Docker Hub, and the environment variables for the docker-compose file can be found at the .env file in the project root folder. This repository does not include that file, instead it offers an example_env file that can be renamed to .env and it should work out of the box (the default environment variables set do not need to be modified).

Django Files and Folders of Interest

So far, there is no app created for Django, and so, the only important folder so far is the settings folder inside the rate_my_racket_backend/rate_my_racket_backend folder. This contains different settings.py files for different environment. For example, the dev.py file has the default settings to run in the development environment, while the docker.py file has the default settings to run when using docker-compose. All of these files has the base.py file as their parent file (the base.py file has the settings to be shared among the environments), and so they all should have

from .base import *

as their first line. To change between environments, go to the rate_my_racket_backend/rate_my_racket_backend/__init__.py file and edit its first line. By default it should be

from .docker import *

To change to the environment x, replace that line with

from .x import *

Next, the templates, static, and media folders have been created (and configured in the settings) to store the hml, css, ... files.

The Django Project only has 2 apps in use, the accounts_app to manage users, and the comments_rackets_app to manage the comments and ratings of the rackets.

Next js Files and Folders of Interest

Aside from the package.json and the src/index.js files there are no other edited files in this folder.

The following structure is used by the owner of this repository when working on the Next js project:

    rate-my-racket-frontend
        |____ components
        |____ pages
        |____ styles
        |____ assets

Inside the pages folder, there should be a folder named credentials, that managed the user-account related views, such as register, login, view account, ...

The rest of the folder are racket-related, which means that they contain the views related to the comments, ratings, ... of the rackets. The grids, cards, and other constructions used to display the comments and the rackets are implemented as components, and so they can be found at the components folder. However, some of the pages that do not required heavy UI/UX components have the components embedded as part of the code instead of having them imported from the components folder.

The context folder has the AuthContext file used to globally manage the user states.

All the axios calls are implemented at the pages (not at the components), and sometimes so the pages pass properties and helper functions to the components.

Contributing

Inputs and contributions to this project are appreciated. To make them as transparent and easy as possible, please follow this steps:

  • How to contribute:

    1. Fork the repo and create your branch from master
    2. Clone the project to your own machine
    3. Commit changes to your own branch
    4. Update documentation
    5. Push your work back up to your fork
    6. Submit a Pull request
  • How to report a bug:

    1. Open a new Issue.
    2. Write a bug report with details, background, and when possible sample code. That's it!

Useful Links

PostgreSQL and other Databases

Docker

Django and DRF

Next js

Miscellaneous

Screenshots

Mobile Image Mobile Image Mobile Image

Mobile Image Mobile Image Mobile Image


Desktop Image


Desktop Image


Desktop Image


Desktop Image


Desktop Image


Desktop Image

Releases

No releases published

Packages

No packages published