aws-serverless-airline-booking icon indicating copy to clipboard operation
aws-serverless-airline-booking copied to clipboard

rewrite(loyalty): replace Typescript with Python & pay tech debt

Open heitorlessa opened this issue 3 years ago • 0 comments

TODO

  • [ ] Rewrite Ingest function
    • [x] Create SNS+SQS Subscription
    • [x] Create DLQ for SQS
    • [x] Update timeout accordingly for SQS message visibility (6x) + BatchWindow
    • [x] Use Powertools to cycle through SQS Message
    • [x] Use Correlation ID for SQS Message
    • [x] KSUID for Python: https://github.com/timonwong/cyksuid
    • [x] Create Repository to abstract pk/sk
    • [x] Expire Loyalty transactions after a year (TTL on createdAt)
    • [x] Unit test
    • [x] Functional test
    • [ ] Handle duplicate transactions
  • [x] Rewrite Get function
    • [x] Query precomputed loyalty points aggregate over scan
    • [x] Unit test
    • [x] Functional test
  • [x] Implement Aggregate function
    • [x] Use Powertools to cycle through DynamoDB Stream image records
    • [x] Precompute Loyalty Tier
      • [x] Increment points if transaction is ACTIVE
      • [x] Increment points if transaction is REVOKED
      • [x] Decrement points if transaction when deleted (TTL)
      • [x] Ignore same customer's transactions where booking is the same (duplicate)
    • [x] Handle duplicate transactions early
  • [x] Infra
    • [x] Update packaging to ease code sharing
    • [x] Enable DynamoDB Streams
    • [x] Create Aggregate Function
    • [x] Least privilege at DynamoDB row item level on Aggregate key
    • [x] Create own layer as part of Loyalty svc for decoupling
  • [x] Storage integ test
    • [x] Loyalty transaction can be added
    • [x] Loyalty transactions are aggregated
    • [x] Expired loyalty transactions decrement current points
    • [x] Expire Fake transactions quicker to save on costs (storage+write request)
  • [ ] End-to-end test
    • [x] Enable Multi-AuthZ in AppSync
    • [x] Extend Loyalty schema to accept API Key
    • [x] Scenario: Loyalty points ingestion from booking
    • [x] Scenario: Fetch loyalty points from API GW
    • [x] Scenario: Duplicate loyalty points are not aggregated
    • [x] Adjust Loyalty resolver to allow API Key calls
    • [ ] Create Loyalty config map to optimize parameter fetching for testing
  • [ ] Dependencies
    • [ ] Update BookingConfirmation function to publish to topic instead of Notify function
  • [ ] Docs
    • [x] Diagram
    • [ ] Decision log
    • [ ] Leave note in docs as an exercise to create an archival system from TTL
  • [x] Push corrections to tests and logic on correctly using fake adapters & fake transactions
  • [ ] Move conditional update to PartiQL + futures

Optimizations after rewrite is complete

  • [ ] Fix timestamps (createAt, booking reservation) as it should be UTC and in ISO format
  • [ ] [Optional] Possibly replace Get function with direct integration due to pre-compute in Aggregate
  • [ ] Set X-Ray Trace ID as correlation ID for async operations
  • [x] Aggregate points of non-unique customers before writing to DynamoDB
  • [x] Add static analysis and linting

Unrelated

  • change stateExecutionId to workflowExecutionId
  • separate PR to propagate correlation ID from front-end all the way down
    • Create X-Ray Trace ID from front-end
    • Enable X-Ray in AppSync (Amplify CLI still doesn't support it)

heitorlessa avatar May 17 '21 19:05 heitorlessa