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!
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.
- Ruby version 3.1.4
- Ruby on Rails version 7.0.5
- rbenv version 1.2.0
- sqlite3 gem version 1.4
- Thunder Client
- rack-cors gem version 2.0
- Faker gem version 3.2
- JWT
- GraphQL
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:
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 ~/.rbenvFor Ubuntu systems:
$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrcFor other Linux Distros:
$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bash_profile2 - Restart the shell and install the rbenv plugin ruby-build:
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build3 - 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 bundler4 - Install rails:
$ gem install rails1 - Install rbenv:
$ brew install rbenv ruby-build2 - Follow steps 3 and 4 from the Linux installation.
1 - Donwload the corresponding Ruby version installer from the official site.
2 - Run on terminal:
$ gem install rails --version “7.0.5”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-BackendInstall the project dependencies and setup the database.
$ bundle install
$ rails db:setup
$ rails db:migrateObservation: 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:seedFinally run the API server:
$ rails sBy default, the Rails server runs on http://127.0.0.1:3000, however this can be changed if necessary.