DO NOT MERGE, Refactor: ApiHandler Migration to Service Layer Architecture#1731
Draft
cakesoft-shashank wants to merge 2 commits intosprintfrom
Draft
DO NOT MERGE, Refactor: ApiHandler Migration to Service Layer Architecture#1731cakesoft-shashank wants to merge 2 commits intosprintfrom
cakesoft-shashank wants to merge 2 commits intosprintfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR migrates the monolithic
ApiHandlerclass to a modular service layer architecture with dedicated services and React hooks. This refactoring improves code maintainability, testability, and follows React best practices by separating concerns.The legacy
ApiHandlerclass had grown to over 3,400 lines and violated several software engineering principles:Architecture Changes
New Service Layer
Created six specialized services following the Single Responsibility Principle:
1. AuthService (
src/services/auth/AuthService.ts)ApiHandlerinitialization withNodeService.initApi()2. AppService (
src/services/app/AppService.ts)ApiHandlerto useWalletService,NodeService,BackupService, andRgbService3. WalletService (
src/services/wallet/WalletService.ts)receiveTestSats,updateProfile,removeWalletPicturegetNodeOnchainBtcTransactionsto useNodeService4. RgbService (
src/services/rgb/RgbService.ts)receiveAsset,searchAssetFromRegistry,handleTransferFailure5. NodeService (
src/services/node/NodeService.ts)getNodeOnchainBtcTransactions6. BackupService (
src/services/backup/BackupService.ts)Custom React Hooks
Created six custom hooks for React components:
useAuth- Authentication operationsuseApp- App-level operationsuseWallet- Wallet operationsuseRgb- RGB asset operationsuseNode- Node managementuseBackup- Backup operations