Venmo Api is a mobile payment service which allows friends to transfer money to each other. It also has some social features like show your friends’ payment activities as feed. It's based on Rails 6 and Ruby 2.6.5.
This template comes with:
- Get the user balance
- Send payment to a friend
- Get feeds records
- Clone this repo
- Install PostgreSQL in case you don't have it
- Run
bootstrap.sh
with the name of your your project like./bootstrap.sh my_awesome_project
rspec
and make sure all tests passrails s
- You can now try your REST services!
- Annotate for doc the schema in the classes
- Better Errors for a better error page
- Brakeman for static analysis security
- Bullet help to kill N+1
- Byebug for debugging
- DelayedJob for background processing
- Dotenv for handling environment variables
- Draper for decorators
- ExceptionHunter for exception tracking
- Factory Bot for testing data
- Faker for generating test data
- Jbuilder for json views
- Letter Opener for previewing a mail in the browser
- Oj for optimized json
- Pry for enhancing the ruby shell
- Puma for the server
- Pundit for authorization management
- Rack CORS for handling CORS
- Rails Best Practices for rails linting
- Reek for ruby linting
- RSpec for testing
- Rspec API Doc Generator for API documentation
- Rubocop for ruby linting
- Sendgrid for sending mails
- Shoulda Matchers adds other testing matchers
- Simplecov for code coverage
- Webmock for stubbing http requests
- YAAF for form objects
- Set your frontend URL in
config/initializers/rack_cors.rb
- Set your mail sender in
config/initializers/devise.rb
- Config your timezone accordingly in
application.rb
.
With rake code_analysis
you can run the code analysis tool, you can omit rules with:
- Rubocop Edit
.rubocop.yml
- Reek Edit
config.reek
- Rails Best Practices Edit
config/rails_best_practices.yml
- Brakeman Run
brakeman -I
to generateconfig/brakeman.ignore
- Bullet You can add exceptions to a bullet initializer or in the controller
- After adding the project to CC, go to
Repo Settings
- On the
Test Coverage
tab, copy theTest Reporter ID
- Set the current value of
CC_TEST_REPORTER_ID
in the circle-ci project env variables
-
Friendship concept was handled as a bidirectional association (e.g user_a and user_b friendship will be represented as only one Friendship table entry, whether user_a or user_b value is on first_friend or second_friend attribute will be exactly the same for the system.)
-
Feed was associated to a Payment to keep a unique feed by transaction between users.
API | HTTP verb | URI | Request Parameters | Response |
---|---|---|---|---|
Payment | POST | /user/{id}/payment | friend_id (integer), amount (float), description (string) | Success: return 200 code with empty body. Failure: return HTTP error code with error description. |
Feed | GET | /user/{id}/feeds | page (page_number for pagination, integer. If no page number in the params, return first page by default. Each page contains at most 10 feed items.) | Success: return 200 code, body contains a list of feed items. Failure: return HTTP error code with error description. |
Balance check | GET | /user/{id}/balance | No parameters | Success: return 200 code, body contains balance. Failure: return HTTP error code with error description. |
This project has 3 main services.
-
PaymentService handles the logic for creating a payment between two users. First it will validate that the receiver user is friend of the sender user and if the amount of money is a positive value, displaying the respective error message in case of failure. Then it will validate that the sender user's balance is equal or greater than the amount to transfer, if it's not it will proceed to call the service explained below. Finally if validations passed, a payment and a feed will be created.
-
Money Transfer Service mocks an external payment source connection which is called whenever a user tries to transfer an amount greater than his account's balance. The service will act as a successful request to an external party and will add the required value for the user to make the transfer.
-
FeedService will return all the payments that a given user should see on their feed. Such collection will be composed by his own payments plus his friends payments.
You can use CODEOWNERS file to define individuals or teams that are responsible for code in the repository.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.
Rails Api Base is maintained by Rootstrap with the help of our contributors.