This project was created thinking about using some tools and techniques in addition to the Ruby on Rails framework.
- To create a Referral you need before to have a Contact, a Contact can have many Referrals linked to it but one Referral is tied in to only one Contact;
- When a Referral is created we send they asynchronously an email to welcome;
- Every data manipulation on Referral and Contact generates en Event, so if you create a Contact, a
contact_created
event will be created with the contact id, if you create a referral, areferral_created
event will be created with the contact id and the referral id, as well as in the case of a deletion; - Events are also created when you send the welcome email to the referral, one (
referral_email_waiting_to_be_sent
) at the end of the referral creation and other (referral_email_sent
) when the email effectively is sent;
This project was built using:
Technology | Version |
---|---|
Ruby | 3.1.2 |
Rails | 7.0.3 |
Rspec | 4.0.2 |
Sidekiq | 6.5 |
Postgresql | 14.4 |
Redis | 7.0.4 |
Rubocop | 1.32 |
Brakeman | 5.2 |
First time running this project? Dont worry, just follow this instructions and evertything will be alright.
You will need to have it installed previously
Technology | Version |
---|---|
Ruby | 3.1.2 |
Bundler | 2.3.18 |
libpq | 14 |
docker and docker-compose | 20.10 and 1.29 |
This command will install all the dependencies of the project
bundle install
This command will initialize postgresql which is used as database and redis which is used as queue for sidekiq
docker-compose up -d
This command will allocate our databases for development and tests
bin/rails db:create
This command will our database migrations. more of migrations on rails
bin/rails db:migrate
Optional, If you want to generate some pre data on the application
bin/rails db:seed
Optional, If you want to sidekiq with. more of sidekiq
bin/rails db:seed
This command will start you server application
bundle exec sidekiq
This command execute the project linter
bundle exec rubocop --parallel --config .rubocop.yml
This command execute the static analysis security tool
bundle exec brakeman
This command execute all the test suit
bundle exec rspec
To list all Contacts (some additional info can be send in query params like name top filter by name or page_num and per_page to paginate)
curl --request GET \
--url http://localhost:3000/contact
To create a Contact
curl --request POST \
--url http://localhost:3000/contact \
--header 'Content-Type: application/json' \
--data '{
"name": "SomeName",
"email": "some@email",
"address": "Some Address"
}'
To find a specific Contact
curl --request GET \
--url 'http://localhost:3000/contact/CHANGE-HERE-TO-SOME-UUID'
To delete a Contact (If there is a referral linked with a contact, it will be deleted too)
curl --request DELETE \
--url 'http://localhost:3000/contact/CHANGE-HERE-TO-SOME-UUID'
To list all Referral (some additional info can be send in query params like contact_id to filter by an specific contact or page_num and per_page to paginate)
curl --request GET \
--url http://localhost:3000/referral
To create a Referral
curl --request POST \
--url http://localhost:3000/referral \
--header 'Content-Type: application/json' \
--data '{
"name": "SomeName",
"email": "some@email",
"address": "Some Address"
}'
To find a specific Referral
curl --request GET \
--url 'http://localhost:3000/referral/CHANGE-HERE-TO-SOME-UUID'
To delete a Referral
curl --request DELETE \
--url 'http://localhost:3000/referral/CHANGE-HERE-TO-SOME-UUID'