Feature: Add Note to Budget command#187
Open
kiptoobarchok wants to merge 1 commit intoitalanta:mainfrom
Open
Conversation
Budget Command
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.
Kujali’s backend follows a CQRS (Command Query Responsibility Segregation) pattern:
Commands encapsulate all input data for a specific action (e.g., adding a note to a budget).
Handlers execute the business logic, interacting with repositories to read or write data.
Repositories abstract the data layer, allowing the handler to work with Firestore or PostgreSQL transparently.
Registrars wrap handlers as Firebase Cloud Functions, exposing them via REST, HTTP endpoints, Firestore triggers, or scheduled tasks.
This separation provides clear boundaries, enhanced testability, and scalability for complex business logic.
Command (AddNoteToBudgetCommand):
Serves as a simple, type-safe container for required fields: orgId, budgetId, and noteContent.
Does not contain any business logic—only data representation.
Enables validation and unit testing in isolation.
Handler (AddNoteToBudgetHandler):
Implements the business logic to append a note to a budget.
Uses the repository pattern for data access, maintaining decoupling from storage specifics.
Includes input validation, error handling, and structured logging.
Returns a typed result object (AddNoteToBudgetResult) indicating success/failure for frontend handling.
Result (AddNoteToBudgetResult):
Encapsulates the outcome of the operation.
Follows consistent project conventions (IObject) for compatibility across features and functions.