Skip to content

AmandaFI/MyTopFavorite-Web-Application-Backend

Repository files navigation

My Top Favorite Web Application - Ruby on Rails Back End

Table of Content

  1. Application Overview
  2. Back End Description
  3. Technologies
  4. Installation
  5. Getting Started

Application Overview

My Top Favorite is a social media platform where registered users can create, edit and share lists containing a rank of their favorite things of a certain theme. Along with each list item, the user has the option to attach a personalized text talking about the chosen item. Users can also follow other users to keep up with their listings.

The platform is integrated with external APIs, therefore, when creating a list, the user can search for items belonging to that theme in reliable sources. As an example, a user creating a list of his favorite action movies will be able to search for them in the collection of the Tmdb platform.

Currently the platform supports lists with themes related to movies, series and public personalities.The theme possibilities are endless and new themes will be supported soon!

Back End Description

The platform has two fully functional back end (API) implementations that are interchangeable and this repository contains the Ruby on Rails version. The NestJS version can be found in this repository and the React front end implementation can be found in this repository.

The branch 'graphql-jwt-version' on this repository contains the same Ruby on Rails API but implemented using the query language GraphQL.

The API was implemented using the Ruby programming language and the Ruby on Rails framework following the REST architectural design pattern and the Model–view–controller (MVC) software design pattern.The chosen SQL database was SQlite and the Object Relational Mapping (ORM) system used was the Active Record.

For testing and validation of the API endpoints, the Visual Code extension Thunder Client was used.

As mentioned in the overview section, only registered users can interact with the platform features, therefore the authentication process was implemented. The main branch implements authentication using sessions and cookies. The jwt-authentication-version branch implements authentication following the OAuth 2 Bearer Token technique using JSON Web Tokens (JWT).

Among the many features provided by this application, a logged user is able to access certain pages to see and interact ('Like') with lists shared by the users he follows. From the API point of view, lists displayed on this areas are fetched using the offset pagination type.

While running both, back end and front end locally, the rack-cors gem was used to avoid Cross-Origin Resource Sharing (CORS) problems.

Technologies

Installation

To run this project locally the following prerequisites are necessary:

  • Ruby installed
  • Ruby on Rails installed

If your system does not meet the mentioned prerequisites the following instructions may help:

Linux systems

1 - Install rbenv by cloning its repository and configuring the shell system. Run the following sequence of commands on a bash terminal.

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv

For Ubuntu systems:

$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc

For other Linux Distros:

$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bash_profile

2 - Restart the shell and install the rbenv plugin ruby-build:

$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

3 - Install the Ruby version used on this project and the Bundler gem:

$ rbenv install -v 3.1.4
$ rbenv global 3.1.4
$ gem install bundler

4 - Install rails:

$ gem install rails

macOS systems

1 - Install rbenv:

$ brew install rbenv ruby-build

2 - Follow steps 3 and 4 from the Linux installation.

Windows systems

1 - Donwload the corresponding Ruby version installer from the official site.

2 - Run on terminal:

$ gem install rails --version “7.0.5”

Getting Started

If your system meets the mentioned prerequisites just clone this repository and run the following initialization commands:

$ git clone https://github.com/AmandaFI/MyTopFavorite-Web-Application-Backend.git
$ cd MyTopFavorite-Web-Application-Backend

Install the project dependencies and setup the database.

$ bundle install
$ rails db:setup
$ rails db:migrate

Observation: the file db/seeds.rb contains a mock data set, built with the Faker gem, that can be used to populate the database using the command:

$ rails db:seed

Finally run the API server:

$ rails s

By default, the Rails server runs on http://127.0.0.1:3000, however this can be changed if necessary.

About

API implemented using Ruby on Rails for the My Top Favorite web application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published