Skip to content

feat: implement add note to budget command and handler#1

Open
Dennoh12 wants to merge 1 commit intomainfrom
feat/add-budget-note-command
Open

feat: implement add note to budget command and handler#1
Dennoh12 wants to merge 1 commit intomainfrom
feat/add-budget-note-command

Conversation

@Dennoh12
Copy link
Owner

Backend Development Understanding

I implemented a CQRS command pattern for adding notes to budgets. The pattern separates write operations (commands) from read operations (queries).

Design Choices

Command Class:

  • Made all properties readonly for immutability
  • Included budgetId, noteContent, and authorId as required fields
  • Made createdAt optional (handler can set it if not provided)

Handler Class:

  • Implemented ICommandHandler interface for consistency
  • Separated validation into its own method for clarity
  • Used private methods to organize code logically
  • Added comprehensive error handling with try-catch

Validation:

  • Check for empty/null values
  • Validate content length (max 5000 characters)
  • Provide clear error messages

Deployment on Current Architecture

Based on Kujali's Firebase/Google Cloud setup:

  1. Package this library as a Cloud Function
  2. Deploy using: firebase deploy --only functions:addNoteToBudget
  3. Frontend would call it via firebase.functions().httpsCallable()

Serverless Deployment Knowledge

Serverless means no server management - the cloud provider runs code on-demand.

How it scales:

  • Each request spawns a new function instance automatically
  • Can handle 1 or 1000 requests simultaneously
  • Pay only for execution time (very cost-effective)
  • Automatic load balancing

Trade-offs:

  • ✅ No infrastructure to manage
  • ✅ Automatic scaling
  • ✅ Pay per use
  • ❌ Cold start latency (first request slower)
  • ❌ Execution time limits (max 9 minutes)

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