Skip to content

FlyWeight-org/Backend

Repository files navigation

FlyWeight: Passenger weights, in the cloud

FlyWeight is a website where pilots can list flights they intend to take, and where passengers can discreetly add their weights to those flights. Weights are only shared with the pilot, not with other passengers, and are no longer accessible some time after the flight is complete.

This website allows pilots to perform an accurate weight and balance while giving passengers a basic assurance of privacy.

Development

Installation and Running

FlyWeight requires Ruby 3.3, PostgreSQL, and Redis. (If you use Homebrew, you can install those dependencies with brew install.) After cloning the repository, run bundle install to install all gem requirements. Run rails db:create db:migrate to create the development database.

The Rails back-end is paired with a Vue.js front-end whose repository is hosted at https://github.com/FlyWeight-org/Frontend. You must clone both repositories.

To run the server in development mode, you can create a Procfile with contents such as:

backend: cd Backend && rvm 3.3.5@flyweight exec rails server
frontend: cd Frontend && yarn dev
jobs: cd Backend && rvm 3.3.5@flyweight exec bundle exec good_job start
anycable: cd Backend && rvm 3.3.5@flyweight exec anycable
ws: cd Backend && rvm 3.3.5@flyweight exec bin/anycable-go --port=8080

Install the foreman gem to run the Procfile.

Documentation

Comprehensive API documentation can be generated by running rake yard. HTML docs are generated into the doc/ directory.

Testing

Unit tests can be run with rspec spec. Unit tests and request tests are provided.

End-to-end testing is documented in the readme for the front-end.

Deployment

The back-end and front-end are both deployed using Fly.io. A GitHub Action, defined in the deploy.yml workflow, runs after CI is complete.

Architecture

FlyWeight is a Ruby on Rails application with an independent Vue 3 front-end.

Only basic assurances of privacy are provided. Flights are only ever referenced by a generated UUID, to prevent URL-crafting attacks. Pilots can only access flights whose planned dates are at most one week old.

Data Model

The account model on FlyWeight is called {Pilot}. Only Pilots are required to have accounts; passengers can add their weights without logging in. {Pilot}s create {Flight} records for each of their flights; then they or their passengers can add {Load} records to those flights.

Authorization

Authentication is handled by Devise. The {Pilot} class is the user model for Devise, and users are authenticated by their email and password.

Passengers do not need to authenticate. They are provided with an unguessable URL where they can add themselves to a flight. When a passenger re-enters their information, any Load with a matching slug is updated.

Controllers

Controllers serve exclusively JSON and are organized in a RESTful, resource-oriented manner.

The root path / is a redirect to the front-end URL.

Releases

No releases published

Packages

No packages published

Languages