Open
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.
Backend Development
The backend development process entails building server side logic for an application by identifying key entities and establishing a structure and rules of data flow in the system.
The command encapsulates what needs to happen, carrying all the required data (AddNoteToBudgetCommand) while the handler (AddNoteToBudgetHandler) on the other hand contains the business logic to execute that command safely and consistently.
This pattern decouples intent (command) from execution (handler), which improves maintainability, testability, and allows easy extension in the future.
The handler depends on a repository to persist the note. Using a toolkit object for dependency injection allows the handler to remain framework-agnostic and easily testable. Basic validation is implemented in the handler (e.g., empty content) to enforce data integrity before touching the database. Returning a structured result, using an interface for type, provides clear feedback about success or failure, which is important for front-end integration.
Deployment
The handler can be packaged as part of the domain library (libs/models/budgetting/budget-notes). Components or services in other modules can import this library and invoke handlers using dependency injection or a command bus pattern. CI/CD pipelines can also be used to build and publish the library to the internal Nx workspace for use across other services.
Serverless Deployment
A serverless architecture like AWS Lambda would allow the handler to execute on-demand without a dedicated server with each command execution triggered as a serverless function.
Serverless automatically scales horizontally based on demand. Multiple invocations of the handler can run in parallel without manual server provisioning.