Lambda Functions

This page details the various Lambda functions that make up the Underwriting Service.

API (cmd/api)

Type: REST API Trigger: AWS API Gateway Responsibilities: * Serves as the entry point for external requests. * Handles authentication and authorization. * Retrieves float profiles and evaluation results from DynamoDB. * Enqueues requests to SQS for asynchronous processing (e.g., re-running rules).

Rule Runner (cmd/rule-runner)

Type: Worker Trigger: SQS (underwriting-rule-runner) Responsibilities: * Consumes messages to evaluate users for floats/loans. * Fetches necessary data from external services (Float, Transactions, User, etc.). * Executes the configured Rulebooks against the user data. * Writes individual Rule Outcomes to DynamoDB. * Enqueues a completion message to the Result Runner queue.

Result Runner (cmd/result-runner)

Type: Worker Trigger: SQS (underwriting-result-runner) Responsibilities: * Consumes messages indicating rules have finished running. * Aggregates all Rule Outcomes for a specific execution. * Determines the final eligibility (Approved/Denied) and amounts based on the aggregation logic. * Writes the final Evaluation Result to DynamoDB.

Float Created Handler (cmd/float-created-handler)

Type: Event Handler Trigger: SQS (triggered by EventBridge float-created event) Responsibilities: * Reacts to a user successfully taking a float. * Retrieves the relevant Evaluation Result that authorized the float. * Creates a generic Historical Evaluation record in DynamoDB to freeze the state at the time of the float. * Updates float-service or other downstream dependencies if needed.

Profile Handler (cmd/profile-handler)

Type: Worker Trigger: SQS Responsibilities: * Creates new default float profiles for new users after a user has completed signing up.