The application is developed with Ruby 2.5.1.
Clone this repository and run the setup script:
$ cd rails-booking-api
$ bin/setup
This app is a front-end for Samedi Bookking API. Therefore, unlike a typical Rails app, this one doesn't use a database at all.
Typical data flow goes like this:
- A user agent sends a request to the Rails app
- An appropriate controller handles the request
- If necessary, the controller builds a form object to validate and filter the request data (params)
- The controller builds an operation object that will process the request and invokes it with validated params
- The operation object performs a request to Samedi API
- The operation object transforms the API response into entities that are the part of the domain model and returns them to the controller
- If necessary, the controller decorates the returned entities or builds a view-model using those entities, exposing the built object to a view
While following the typical Rails code organization, app
contains a few non-standard directories:
app/decorators
— containts decorators for entities.app/entities
— contains entity objects. These are POROs which encapsulate various types defined by Samedi Booking API.app/forms
— contains form objects. These are typically ActiveModel objects that are used to render and validate data coming from web forms.app/mappers
— contains objects that provide data mapping between Samedi API response hashes and entities as defined within the app.app/operations
— contains operation objects. An operation object is a function object, thus their names are verbs and their only public method is#call
. Operation objects contain business logic and they work with service objects that are typically injected as dependencies in initializers.app/view_models
— contains objects that encapsulate data that should be displayed on a single page. They are typically composed of multiple objcets, which could be a mix of forms, entities, and basic Ruby types.
Front-end is built exclusively with Webpacker, using the Webpacker gem.
Tests are written with RSpec. Tu run all tests, you could simply execute the following command in terminal:
$ bundle exec rspec