|
| 1 | +--- |
| 2 | +title: Function Documentation |
| 3 | +nav_order: 6 |
| 4 | +parent: Developer Guides |
| 5 | +has_children: false |
| 6 | +has_toc: true |
| 7 | +--- |
| 8 | + |
| 9 | +This page bundles function-level README files from the Supplier API codebase. |
| 10 | + |
| 11 | +## Data Flow Overview |
| 12 | + |
| 13 | +Primary data flows passing through the system: |
| 14 | + |
| 15 | +### Inbound (letter allocation and creation) |
| 16 | + |
| 17 | +``` |
| 18 | +LetterRequestPreparedEvent (SNS) |
| 19 | + → supplier-allocator (SQS consumer) |
| 20 | + → resolves supplier via weighted fair-share algorithm |
| 21 | + → upsert-letter (SQS consumer) |
| 22 | + → inserts letter record into DynamoDB (letters table) |
| 23 | + → DynamoDB Stream → Kinesis |
| 24 | + → update-letter-queue: adds PENDING letters to queue table |
| 25 | + → letter-updates-transformer: publishes LetterStatusChangeEvent to SNS |
| 26 | +``` |
| 27 | + |
| 28 | +### Supplier-facing (status updates) |
| 29 | + |
| 30 | +``` |
| 31 | +Supplier calls GET /letters (api-handler) |
| 32 | + → reads from pending queue table with visibility timeout |
| 33 | +Supplier calls PATCH /letters/{id} or POST /letters (api-handler) |
| 34 | + → enqueues UpdateLetterCommand to SQS |
| 35 | + → transformAmendmentEvent (SQS consumer, in api-handler package) |
| 36 | + → fetches current letter, publishes LetterStatusChangeEvent to SNS |
| 37 | + → upsert-letter (SQS consumer) |
| 38 | + → updates letter status in DynamoDB (letters table) |
| 39 | + → DynamoDB Stream → Kinesis |
| 40 | + → update-letter-queue: removes letter from pending queue |
| 41 | + → letter-updates-transformer: publishes LetterStatusChangeEvent to SNS |
| 42 | +``` |
| 43 | + |
| 44 | +### MI submission |
| 45 | + |
| 46 | +``` |
| 47 | +Supplier calls POST /mi (api-handler) |
| 48 | + → persists MI record to DynamoDB (mi table) |
| 49 | + → DynamoDB Stream → Kinesis |
| 50 | + → mi-updates-transformer: publishes MISubmittedEvent to SNS |
| 51 | +``` |
| 52 | + |
| 53 | +### Supplier config ingestion |
| 54 | + |
| 55 | +``` |
| 56 | +Supplier config event (SNS, type prefix uk.nhs.notify.supplier-config) |
| 57 | + → supplier-config SQS queue |
| 58 | + → supplier-config-ingress (SQS consumer) |
| 59 | + → upserts entity into supplier-config DynamoDB table |
| 60 | +``` |
| 61 | + |
| 62 | +## Lambda Packages |
| 63 | + |
| 64 | +### API Handler |
| 65 | + |
| 66 | +{% include components/generated/readmes/lambda-api-handler.md %} |
| 67 | + |
| 68 | +### Authorizer |
| 69 | + |
| 70 | +{% include components/generated/readmes/lambda-authorizer.md %} |
| 71 | + |
| 72 | +### Supplier Allocator |
| 73 | + |
| 74 | +{% include components/generated/readmes/lambda-supplier-allocator.md %} |
| 75 | + |
| 76 | +### Upsert Letter |
| 77 | + |
| 78 | +{% include components/generated/readmes/lambda-upsert-letter.md %} |
| 79 | + |
| 80 | +### Update Letter Queue |
| 81 | + |
| 82 | +{% include components/generated/readmes/lambda-update-letter-queue.md %} |
| 83 | + |
| 84 | +### Letter Updates Transformer |
| 85 | + |
| 86 | +{% include components/generated/readmes/lambda-letter-updates-transformer.md %} |
| 87 | + |
| 88 | +### MI Updates Transformer |
| 89 | + |
| 90 | +{% include components/generated/readmes/lambda-mi-updates-transformer.md %} |
| 91 | + |
| 92 | +### Supplier Config Ingress |
| 93 | + |
| 94 | +{% include components/generated/readmes/lambda-supplier-config-ingress.md %} |
| 95 | + |
| 96 | +## Internal Packages |
| 97 | + |
| 98 | +### Datastore |
| 99 | + |
| 100 | +{% include components/generated/readmes/internal-datastore.md %} |
| 101 | + |
| 102 | +### Events |
| 103 | + |
| 104 | +{% include components/generated/readmes/internal-events.md %} |
| 105 | + |
| 106 | +### Event Builders |
| 107 | + |
| 108 | +{% include components/generated/readmes/internal-event-builders.md %} |
| 109 | + |
| 110 | +### Helpers |
| 111 | + |
| 112 | +{% include components/generated/readmes/internal-helpers.md %} |
| 113 | + |
| 114 | +## Tests |
| 115 | + |
| 116 | +{% include components/generated/readmes/tests-overview.md %} |
| 117 | + |
| 118 | +## Sandbox |
| 119 | + |
| 120 | +{% include components/generated/readmes/sandbox.md %} |
| 121 | + |
| 122 | +## Supplier Configuration |
| 123 | + |
| 124 | +{% include components/generated/readmes/config-suppliers.md %} |
0 commit comments