Skip to content

refactor: copy in central-settlement codebase#1286

Draft
lewisdaly wants to merge 10 commits intomojaloop:mainfrom
tigerbeetle:lewis/copy-central-settlement
Draft

refactor: copy in central-settlement codebase#1286
lewisdaly wants to merge 10 commits intomojaloop:mainfrom
tigerbeetle:lewis/copy-central-settlement

Conversation

@lewisdaly
Copy link
Copy Markdown
Contributor

Copies across central-settlement into the central-ledger codebase. This is necessary step for the TigerBeetle Integration.

The settlement api is now available under /v2/:

$ npm run start

> @mojaloop/central-ledger@19.14.0 start
> npm run start:api


> @mojaloop/central-ledger@19.14.0 start:api
> node src/api/index.js
...

method  path                                                       description
------  ---------------------------------------------------------  ----------------------------------------------------------------------
// Existing routes:
GET     /documentation
GET     /enums
GET     /health
GET     /ledgerAccountTypes                                        Get all ledger Account types
POST    /ledgerAccountTypes                                        Create a new ledger account type
GET     /metrics                                                   Prometheus metrics endpoint
GET     /participants
POST    /participants
...

// New routes added from central-settlement:
GET     /v2/api-docs                                               The OpenAPI document.
GET     /v2/health                                                 Gets the health of the service and sub-services (i.e. database).
GET     /v2/settlements                                            Returns Settlements as per parameter(s).
POST    /v2/settlements                                            Triggers settlement creation. Returns settlement report.
GET     /v2/settlements/{id}                                       Returns Settlement(s) as per parameters/filter criteria.
PUT     /v2/settlements/{id}                                       Acknowledgement of settlement by updating with Settlement Id.
GET     /v2/settlements/{sid}/participants/{pid}                   Returns Settlement(s) as per filter criteria.
PUT     /v2/settlements/{sid}/participants/{pid}                   Acknowledgement of settlement by updating the reason and state by SP.
GET     /v2/settlements/{sid}/participants/{pid}/accounts/{aid}    Returns Settlement(s) as per filter criteria.
PUT     /v2/settlements/{sid}/participants/{pid}/accounts/{aid}    Acknowledgement of settlement by updating the reason and state by SPA.
GET     /v2/settlementWindows                                      Returns Settlement Windows as per parameter(s).
GET     /v2/settlementWindows/{id}                                 Returns a Settlement Window by id.
POST    /v2/settlementWindows/{id}                                 Closes requested window and opens a new one.

Additionally, this architecture change will make the total codebase much simpler by:

  1. Reducing the number of repositories.
  2. central-ledger will no longer need to publish a @mojaloop/central-ledger package for consumption by central-settlement.
  3. Reducing the total number of docker images in a deployment.

So we go from this dependency tree:

Pasted image 20260410144124

To this dependency tree:
Pasted image 20260410144155

I chose to keep the settlement code under src/settlement for now to simplify the review process, and make it easier in the short term to keep the two repositories in sync with one another.

For deployments, we have 2 options (we may want to choose either depending on the scenario):

  1. Run the central-ledger container in the place of the settlement container, essentially running central-ledger as settlement.
  2. We remove the central-settlement container altogether, and update routes accordingly.

Recommended Followup Processes:

  1. Merge this PR.
  2. Release a preview central-ledger and test.
  3. Mark the central-settlement repository as archive only.
  4. Come back and refactor the settlement code in this repository:
    1. Distribute the code under src/settlement into the appropriate places in src/.
    2. Likewise with the code in test/settlement.

@lewisdaly lewisdaly force-pushed the lewis/copy-central-settlement branch from 9ccbea9 to e6c0bf9 Compare April 10, 2026 13:10
@lewisdaly lewisdaly force-pushed the lewis/copy-central-settlement branch from e6c0bf9 to 7ca61ab Compare April 10, 2026 13:10
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
21.8% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant