{"id":29879480,"url":"https://github.com/ian-rossi/backend-fighting-2025","last_synced_at":"2026-04-11T17:36:59.576Z","repository":{"id":307378477,"uuid":"1029117786","full_name":"ian-rossi/backend-fighting-2025","owner":"ian-rossi","description":"Backend fighting 2025 edition challenge solution. The challenge is to integrate with two payment processors services with the smaller tax, ensuring max profit. The plot twist is: they're quite unstable!","archived":false,"fork":false,"pushed_at":"2025-07-30T22:15:52.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-31T00:48:19.209Z","etag":null,"topics":["docker","docker-compose","java","java-21","java-21-lts","mandrel","nginx","quarkus","quarkus-maven","quarkus-native","quarkus-reactive","quarkus-resteasy","quarkus-resteasy-mutiny","quarkusio","redis","redis-search","redisearch","rinha-de-backend","rinha-de-backend-2025","vertx"],"latest_commit_sha":null,"homepage":"","language":"Java","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/ian-rossi.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,"zenodo":null}},"created_at":"2025-07-30T14:48:21.000Z","updated_at":"2025-07-30T22:15:55.000Z","dependencies_parsed_at":"2025-07-31T00:48:26.590Z","dependency_job_id":null,"html_url":"https://github.com/ian-rossi/backend-fighting-2025","commit_stats":null,"previous_names":["ian-rossi/backend-fighting-2025"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ian-rossi/backend-fighting-2025","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-rossi%2Fbackend-fighting-2025","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-rossi%2Fbackend-fighting-2025/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-rossi%2Fbackend-fighting-2025/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-rossi%2Fbackend-fighting-2025/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ian-rossi","download_url":"https://codeload.github.com/ian-rossi/backend-fighting-2025/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-rossi%2Fbackend-fighting-2025/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31689762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["docker","docker-compose","java","java-21","java-21-lts","mandrel","nginx","quarkus","quarkus-maven","quarkus-native","quarkus-reactive","quarkus-resteasy","quarkus-resteasy-mutiny","quarkusio","redis","redis-search","redisearch","rinha-de-backend","rinha-de-backend-2025","vertx"],"created_at":"2025-07-31T09:00:49.925Z","updated_at":"2026-04-11T17:36:59.546Z","avatar_url":"https://github.com/ian-rossi.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The challenge\n\n**Obs.**: here's the [original challenge URL](https://github.com/zanfranceschi/rinha-de-backend-2025)\n\n\u003e Backend fighting 2025 edition challenge solution. The challenge is to integrate with two payment processors services with the smaller tax, ensuring max profit. The plot twist is: they're quite unstable!\n\n# The solution\n\n```mermaid\nflowchart TD\n    Client[Client]\n    NGINX[NGINX]\n    Q1[Quarkus Instance 1]\n    Q2[Quarkus Instance 2]\n    Redis[Redis]\n    ProcA[Payment Processor A]\n    ProcB[Payment Processor B]\n\n    %% Client to NGINX\n    Client --\u003e|POST /payments| NGINX\n    Client --\u003e|GET /payments-summary| NGINX\n\n    %% NGINX to Quarkus\n    NGINX --\u003e|Forward request| Q1\n    NGINX --\u003e|Forward request| Q2\n\n    %% Quarkus to Redis\n    Q1 --\u003e|Read/Write| Redis\n    Q2 --\u003e|Read/Write| Redis\n\n    %% Quarkus to Payment Processors\n    Q1 --\u003e|Process Payment| ProcA\n    Q1 --\u003e|Process Payment| ProcB\n    Q2 --\u003e|Process Payment| ProcA\n    Q2 --\u003e|Process Payment| ProcB\n\n    %% Payment Processors respond to Quarkus\n    ProcA --\u003e|Result| Q1\n    ProcB --\u003e|Result| Q1\n    ProcA --\u003e|Result| Q2\n    ProcB --\u003e|Result| Q2\n\n    %% Quarkus instances may notify each other (e.g., POST /h)\n    Q1 --\u003e|POST /h| Q2\n    Q2 --\u003e|POST /h| Q1\n```\n\n## The flows\n\n- POST /payments\n\n```mermaid\nsequenceDiagram\n    participant Client\n    participant NGINX\n    participant Quarkus as Quarkus Instance\n    participant Deque as In-memory Deque\n\n    Client-\u003e\u003eNGINX: POST /payments {correlationId, amount}\n    NGINX-\u003e\u003eQuarkus: Forward request\n    alt First time running\n        Quarkus-\u003e\u003eQuarkus: Parse JSON, set amount, flag, instant, correlationId\n    else Not first time\n        Quarkus-\u003e\u003eQuarkus: Extract correlationId via substring\n    end\n    Quarkus-\u003e\u003eDeque: Store correlationId\n    Quarkus--\u003e\u003eClient: 204 No Content\n```\n\n- GET /payments-summary\n\n```mermaid\nsequenceDiagram\n    participant Client\n    participant NGINX\n    participant Quarkus as Quarkus Instance\n    participant Redis\n\n    Client-\u003e\u003eNGINX: GET /payments-summary?from\u0026to\n    NGINX-\u003e\u003eQuarkus: Forward request\n    Quarkus-\u003e\u003eRedis: FT.AGGREGATE p @t[from to] GROUP BY @d REDUCE COUNT as c\n    Redis--\u003e\u003eQuarkus: {default: {count}, fallback: {count}}\n    Quarkus-\u003e\u003eQuarkus: Calculate totalAmount = count * static amount\n    Quarkus--\u003e\u003eClient: {default, fallback summary}\n```\n\n- Pending payments background loop thread\n\n```mermaid\nflowchart TD\n    Start[Background loop thread]\n    FilterCandidates[Filter processor candidates: not failing, retry time ok]\n    OrderCandidates[If multiple candidates, order by estimated profit/second]\n    NoCandidates{Candidates empty?}\n    PollDeque[Poll last correlationId]\n    NoCorrelationId{correlationId is null?}\n    CallProcessor[Call payment processor]\n    UpdateMinRT[Update minResponseTime if changed]\n    Success{Success?}\n    RedisHSet[Redis hset payment info]\n    WasAlreadyFailing{Was already failing?}\n    YesItWasAlreadyFailing[Increase retry time scale factor]\n    NoItWasntAlreadyFailing[Set failing POST /h]\n    IsThereOtherCandidate{Is there other candidate?}\n    NotifyOther[POST /h to other instance if changed]\n    End[End]\n\n    Start --\u003e FilterCandidates\n    FilterCandidates --\u003e OrderCandidates\n    OrderCandidates --\u003e NoCandidates\n    NoCandidates -- Yes --\u003e End\n    NoCandidates -- No --\u003e PollDeque\n    PollDeque --\u003e NoCorrelationId\n    NoCorrelationId -- Yes --\u003e End\n    NoCorrelationId -- No --\u003e CallProcessor\n    CallProcessor --\u003e UpdateMinRT\n    UpdateMinRT --\u003e Success\n    Success -- Yes --\u003e RedisHSet --\u003e NotifyOther\n    Success -- No --\u003e WasAlreadyFailing\n    WasAlreadyFailing -- Yes --\u003e YesItWasAlreadyFailing --\u003e IsThereOtherCandidate\n    WasAlreadyFailing -- No --\u003e NoItWasntAlreadyFailing --\u003e IsThereOtherCandidate\n    IsThereOtherCandidate -- Yes --\u003e CallProcessor\n    IsThereOtherCandidate -- No --\u003e NotifyOther\n    NotifyOther --\u003e End\n```\n\n- Service health scheduler\n\n```mermaid\nflowchart TD\n    Start[Every 5s Scheduler]\n    ShouldCheck{SHOULD_EXECUTE_DEFAULT/FALLBACK_CHECK?}\n    CallHealth[Call GET /payments/service-health on both processors]\n    UpdateFlags[Update minResponseTime and failing flag in memory]\n    NotifyOther[POST /h to other instance if changed]\n    FlipEnv[Flip SHOULD_EXECUTE env value]\n    End[End]\n\n    Start --\u003e ShouldCheck\n    ShouldCheck -- No --\u003e FlipEnv\n    ShouldCheck -- Yes --\u003e CallHealth\n    CallHealth --\u003e UpdateFlags\n    UpdateFlags --\u003e NotifyOther\n    NotifyOther --\u003e FlipEnv\n    FlipEnv --\u003e End\n```\n\nThis project uses Quarkus, the Supersonic Subatomic Java Framework.\n\nIf you want to learn more about Quarkus, please visit its website: \u003chttps://quarkus.io/\u003e.\n\n## Running the application in dev mode\n\nYou can run your application in dev mode that enables live coding using:\n\n```shell script\n./mvnw quarkus:dev\n```\n\n\u003e **_NOTE:_**  Quarkus now ships with a Dev UI, which is available in dev mode only at \u003chttp://localhost:8080/q/dev/\u003e.\n\n## Packaging and running the application\n\nThe application can be packaged using:\n\n```shell script\n./mvnw package\n```\n\nIt produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.\nBe aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.\n\nThe application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.\n\nIf you want to build an _über-jar_, execute the following command:\n\n```shell script\n./mvnw package -Dquarkus.package.jar.type=uber-jar\n```\n\nThe application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.\n\n## Creating a native executable\n\nYou can create a native executable using:\n\n```shell script\n./mvnw package -Dnative\n```\n\nOr, if you don't have GraalVM installed, you can run the native executable build in a container using:\n\n```shell script\n./mvnw package -Dnative -Dquarkus.native.container-build=true\n```\n\nYou can then execute your native executable with: `./target/backend-fighting-2025-0.0.1-runner`\n\nIf you want to learn more about building native executables, please consult \u003chttps://quarkus.io/guides/maven-tooling\u003e.\n\n## Provided Code\n\n### REST\n\nEasily start your REST Web Services\n\n[Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-rossi%2Fbackend-fighting-2025","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fian-rossi%2Fbackend-fighting-2025","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-rossi%2Fbackend-fighting-2025/lists"}