{"id":15101471,"url":"https://github.com/mariocc29/pokemon_tcg_api","last_synced_at":"2026-01-19T12:32:53.856Z","repository":{"id":237000056,"uuid":"793600762","full_name":"mariocc29/pokemon_tcg_api","owner":"mariocc29","description":"Exemplary Ruby on Rail RestAPI aimed at assessing code quality with meticulous attention to detail.","archived":false,"fork":false,"pushed_at":"2024-05-02T12:33:03.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T10:43:48.477Z","etag":null,"topics":["backend","elasticsearch","grape-api","rails","redis","rspec","swagger"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariocc29.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-29T14:26:05.000Z","updated_at":"2024-05-02T12:33:07.000Z","dependencies_parsed_at":"2024-10-14T01:15:34.526Z","dependency_job_id":null,"html_url":"https://github.com/mariocc29/pokemon_tcg_api","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"274877d3d3b7f57e10b2cfc4056ec03f8737ec34"},"previous_names":["mariocc29/pokemon_tcg_api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mariocc29/pokemon_tcg_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocc29%2Fpokemon_tcg_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocc29%2Fpokemon_tcg_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocc29%2Fpokemon_tcg_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocc29%2Fpokemon_tcg_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariocc29","download_url":"https://codeload.github.com/mariocc29/pokemon_tcg_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariocc29%2Fpokemon_tcg_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28567896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","elasticsearch","grape-api","rails","redis","rspec","swagger"],"created_at":"2024-09-25T18:23:49.277Z","updated_at":"2026-01-19T12:32:53.842Z","avatar_url":"https://github.com/mariocc29.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pokemon API\n**Small Door Veterinary Test Ruby backend**\n\n### Overview\n\nThe Pokemon TCG API is a RESTful service that allows evaluating the quality of the code.\n\nThe purpose of this application is to connect an APIRestful and get a list of pokemons cards.\n\n## Requirements\n\n* The project is developed as a REST API.\n* Data should be stored in a relational database (either MySQL or Postgres)\n* A deck should contain exactly 60 cards\n* 12-16 pokemon of a given type\n* 10 energy cards for that type\n* The rest of the cards should be random trainer cards where no more than 4 cards of the same kind can be repeated\n\n### Constraints\n\n1. To initialize the project, use the following command:\n\n```bash\n  rails new pokemon_tcg_api --api -d postgresql -T\n```\n\n## Technologies\n\nThe following technologies are used in this project:\n\n||Version|Command for checking\n|-|-:|-|\n|ruby|3.2.3|ruby --version|\n|rails|7.1.3.2|rails --version|\n|postgresql|16.2-1.pgdg120+2|postgres --version|\n|elasticsearch|7.15.2||\n\n## Deployment\n\nTo deploy the application, follow these steps:\n\n1. Install dependencies:\n\n```bash\n  bundle install\n```\n\n3. Run migrations:\n\n```bash\n  bin/rails db:migrate; RAILS_ENV=test bin/rails db:migrate\n```\n\n4. Run seeders:\n\n```bash\n  bin/rails db:seed\n```\n\n5. Start the server:\n\n```bash\n  bin/rails serve\n```\n\n## API Reference\n\nTo access the API documentation, perform the following steps:\n\n1. Retrieve the documentation:\n\n```bash\ncurl  -X GET \\\n  'localhost:3000/api/docs' \\\n  --header 'Accept: */*'\n```\n\n2. Copy the content and visualize it using [Swagger Editor](https://editor.swagger.io/)\n\n## Running Tests\n\nExecute the following command to run the tests:\n\n```bash\n   bundle exec rspec spec/\n```\n\n## Solution Approach\n\nThe solution for building the Pokemons TCG API involves the following steps:\n\n1. **Choosing the Framework:** We opted to use the Grape framework for building our RESTful API. Grape provides a lightweight and flexible approach to define API endpoints and manage request handling.\n\n2. **Entity Serialization:** To ensure clean and structured responses from our API, we use Grape Entity for entity serialization. This allows us to define the structure of our API responses in a clear and organized manner.\n\n3. **Documentation Generation:** We integrate Grape Swagger and Grape Swagger Entity to automatically generate Swagger-compliant documentation for our API. This ensures that our API endpoints are well-documented and easy to explore.\n\n4. **Testing Strategy:** We employ RSpec and related gems for behavior-driven development (BDD) and testing. RSpec Rails provides a robust framework for testing Rails applications, while Rack Test allows us to test Rack applications with a simple API. Additionally, we use RSpec JSON Expectations for validating JSON responses in our tests.\n\n5. **Code Quality:** To maintain code quality and adherence to best practices, we utilize RuboCop, a linter for Ruby code. RuboCop helps us enforce consistent coding styles and identify potential issues in our codebase.\n\n6. **Service Objects:** The core functionality of the system is organized using the concept of service objects. The service objects responsible for retrieving pokemon cards data and processing it reside in the `app/services/pokemon` directory. This approach promotes encapsulation and modularity, making our codebase easier to understand and maintain.\n\n7. **Implementation of Data Retrieval Solutions:** Regarding the extraction of data from the External API, we implemented two solutions. For downloading Pokemon types data and optimizing the rate limit, we implemented Redis as a cache for the extracted data. In relation to retrieving cards, we implemented Elasticsearch for handling the data.\n\n8. **Job Implementation:** Due to the constraints of the External API, which has a volume of 17,000 registered cards and enforces a maximum of 250 records per page, we implemented the `app/jobs/pokemon_cards_indexer_job` to download data concurrently. This way, when creating a random deck under the given conditions, all the information is already available on the Elasticsearch server.\n\n## Installed Gems\n\nThe following gems are installed for the project:\n\n- `byebug`: Debugging tool for Ruby.\n- `chewy`: ODM (Object Document Mapper) to integrate Elasticsearch with Rails\n- `dotenv-rails`: Loads environment variables from a .env file into ENV when the Rails app initializes.\n- `elasticsearch`: Integrates Elasticsearch with Rails\n- `factory_bot_rails`: Provides support for defining and using factories in RSpec tests\n- `faker`: Generates fake data for testing purposes\n- `grape`: REST-like API framework for Ruby\n- `grape-entity`: Entity serialization for Grape APIs\n- `grape-swagger`: Adds swagger compliant documentation to your Grape API\n- `grape-swagger-entity`: Swagger documentation for Grape entities\n- `rack-test`: Add the 'rack/test' gem for testing Rack applications with a simple API.\n- `rspec-json_expectations`: Integrate 'rspec/json_expectations' gem for additional JSON-related expectations in RSpec.\n- `rspec-rails`: Behavior-driven development for Ruby on Rails applications\n- `rubocop`: Linter for Ruby code\n- `shoulda-matchers`: Simple one-liner tests for common Rails functionality\n- `sidekiq`: Background processing for Ruby.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariocc29%2Fpokemon_tcg_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariocc29%2Fpokemon_tcg_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariocc29%2Fpokemon_tcg_api/lists"}