Skip to content

Feature: Add Note to Budget command#187

Open
kiptoobarchok wants to merge 1 commit intoitalanta:mainfrom
kiptoobarchok:feat/add-budget-notecommand
Open

Feature: Add Note to Budget command#187
kiptoobarchok wants to merge 1 commit intoitalanta:mainfrom
kiptoobarchok:feat/add-budget-notecommand

Conversation

@kiptoobarchok
Copy link

  1. Understanding the Backend Development Process

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.

  1. Design Choices

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.

Budget Command
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