Skip to content

Commit d020cad

Browse files
committed
Update sequence diagrams for sending submission emails
We no longer use GOV.UK Notify to send submission emails, instead we use Amazon SES asynchronously. Our documentation and sequence diagrams need to be updated to reflect this, this commit: - Add Amazon SES to high level architecture diagram - Removes references to GOV.UK Notify from sequence diagram for filling in a form - Moves sequence diagrams related to sending submission emails from file upload file to a new file
1 parent c26bdc6 commit d020cad

4 files changed

Lines changed: 165 additions & 165 deletions

File tree

diagrams/sequence-diagrams/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ graph TD
3939
filler --- runner --- api
4040
4141
notify(GOV.UK Notify)
42+
ses(Amazon Simple Email Service)
4243
4344
pay(GOV.UK Pay)
4445
filler -.- pay -.- runner
4546
4647
filler -.- notify
47-
notify --- runner
48-
processor --- notify
49-
50-
48+
notify -.- runner
49+
ses --- runner
50+
processor --- ses
5151
```
5252

5353
## Links to Sequence Diagrams

diagrams/sequence-diagrams/file-upload.md

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -141,157 +141,3 @@ runner->>browser: HTTP 302 redirect response
141141
142142
note over user,runner: User completes the rest of the questions
143143
```
144-
145-
### User submits their form
146-
```mermaid
147-
148-
---
149-
title: User submits their form
150-
---
151-
152-
sequenceDiagram
153-
154-
autonumber
155-
156-
actor user as User
157-
158-
participant browser as Browser
159-
160-
participant runner as Forms Runner
161-
participant runner-db as Forms Runner database
162-
participant solidqueue-db as Solid Queue database
163-
164-
browser->>runner: GET check your answers
165-
runner->>browser: HTTP 200 response
166-
browser->>user: display check your answers page
167-
168-
user->>browser: select "Submit"
169-
browser->>runner: POST submit form
170-
runner->>runner-db: save Submission
171-
runner->>solidqueue-db: enqueue send submission job
172-
173-
runner->>browser: HTTP 302 response
174-
browser->>runner: GET confirmation page
175-
runner->>browser: HTTP 200 response
176-
browser->>user: Display confirmation page
177-
178-
```
179-
180-
### Sending the submission email asynchronously
181-
182-
```mermaid
183-
184-
---
185-
title: Sending the submission email asynchronously
186-
---
187-
188-
sequenceDiagram
189-
190-
autonumber
191-
192-
participant worker as Forms runner worker
193-
participant solidqueue-db as Solid Queue database
194-
participant runner-db as Forms Runner database
195-
participant s3 as Amazon S3
196-
participant ses as Amazon SES
197-
participant sns as Amazon SNS
198-
participant inbox as Email inbox
199-
participant sentry as Sentry
200-
201-
actor processor
202-
203-
worker->>solidqueue-db: dequeue send submission job
204-
worker->>runner-db: get Submission
205-
worker->>s3: get file(s)
206-
worker->>ses: send email
207-
208-
break error
209-
alt AWS SDK error and max retries not reached
210-
worker->>solidqueue-db: schedule retry
211-
else
212-
worker->>sentry: send error
213-
end
214-
end
215-
216-
ses->>worker: return message_id
217-
worker->>runner-db: set mail_message_id on Submission
218-
worker->>runner-db: update mail_status of Submission to "pending"
219-
220-
ses-)inbox: send email
221-
note over ses,inbox: happens some time later
222-
223-
alt email sent successfully
224-
ses->>sns: send delivery notification
225-
processor->>inbox: get form from inbox
226-
processor->>processor: process form
227-
else email bounces
228-
ses->>sns: send bounce notification
229-
note over ses,sns: We have an SQS queue subscribed to the<br/> SNS topic and a recurring task to poll<br/>the SQS queue.
230-
end
231-
232-
worker->>worker: Recurring task deletes Submissions<br/>that haven't bounced after 7 days
233-
```
234-
235-
### Handling email bounces/complaints
236-
```mermaid
237-
238-
---
239-
title: Handling email bounces/complaints
240-
---
241-
242-
sequenceDiagram
243-
244-
autonumber
245-
246-
participant worker as Solid Queue worker
247-
participant solidqueue-db as Solid Queue database
248-
participant runner-db as Forms Runner database
249-
participant sqs as Amazon SQS
250-
participant sentry as Sentry
251-
252-
actor support as Forms team tech support
253-
254-
worker->>solidqueue-db: enqueue recurring receive bounces job
255-
worker->>solidqueue-db: dequeue receive bounces job
256-
worker->>sqs: get messages from bounces and complaints queue
257-
alt there is a bounce SQS message
258-
worker->>runner-db: get Submission by the message_id in the SQS message
259-
worker->>runner-db: update mail_status of Submission to "bounced"
260-
worker->>worker: Log with the submission details
261-
worker->>sentry: send error event
262-
sentry->>support: Alert via Slack
263-
support->>support: Identify why the email bounced
264-
support->>support: Run rake task to retry submission
265-
else there is a complaint SQS message
266-
worker->>runner-db: get Submission by the message_id in the SQS message
267-
worker->>worker: Log with the submission details
268-
end
269-
270-
```
271-
272-
### Handling successful deliveries
273-
274-
```mermaid
275-
276-
---
277-
title: Handling successful deliveries
278-
---
279-
280-
sequenceDiagram
281-
282-
autonumber
283-
284-
participant worker as Solid Queue worker
285-
participant solidqueue-db as Solid Queue database
286-
participant runner-db as Forms Runner database
287-
participant sqs as Amazon SQS
288-
289-
actor support as Forms team tech support
290-
291-
worker->>solidqueue-db: enqueue recurring receive deliveries job
292-
worker->>solidqueue-db: dequeue receive deliveries job
293-
worker->>sqs: get messages from deliveries queue
294-
worker->>runner-db: get Submission by the message_id in the SQS message
295-
worker->>runner-db: update mail_status of Submission to "delivered"
296-
note over worker,runner-db: we don't currently use the "delivered" status for anything other than for information
297-
```

diagrams/sequence-diagrams/filling-in-a-form.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ sequenceDiagram
77
participant govuk as GOV.UK website
88
participant runner as forms-runner
99
participant api as forms-api
10-
participant notify as GOV.UK Notify
1110
participant inbox as shared email inbox
1211
actor processor as Form processor
1312
@@ -41,13 +40,13 @@ sequenceDiagram
4140
user->>browser: Click "Submit"
4241
browser->>runner: POST /form/{form id}/{form slug}/submit-answers
4342
runner->>api: GET /api/v1/forms/{form id}/live
44-
runner->>notify: client.send_email()
45-
runner->>runner: Delete user session
43+
runner->>runner: save Submission
44+
runner->>runner: enqueue send submission job
4645
runner-->>browser: 302
4746
browser->>runner: GET /form/{form id}/{form slug}/submitted
4847
runner->>api: GET /api/v1/forms/{form id}/live
4948
browser-->>user: Show confirmation page
50-
notify->>inbox: Send email
49+
runner->>inbox: Send email
5150
inbox->>processor: Read email
5251
```
5352

@@ -61,7 +60,6 @@ sequenceDiagram
6160
participant browser as Web Browser
6261
participant runner as forms-runner
6362
participant api as forms-api
64-
participant notify as GOV.UK Notify
6563
6664
user->>browser: Click link to form
6765
browser->>runner: GET /form/{form id}/{form slug}
@@ -75,8 +73,6 @@ sequenceDiagram
7573
end
7674
```
7775

78-
79-
8076
## Brief summary
8177

8278
The users answers are store in Redis in the following structure as they progress through the form.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Sending submission emails asynchronously
2+
3+
forms-runner uses SolidQueue and Amazon SES/SNS to send submissions asynchronously.
4+
5+
## User submits their form
6+
7+
```mermaid
8+
9+
---
10+
title: User submits their form
11+
---
12+
13+
sequenceDiagram
14+
15+
autonumber
16+
17+
actor user as User
18+
19+
participant browser as Browser
20+
21+
participant runner as Forms Runner
22+
participant runner-db as Forms Runner database
23+
participant solidqueue-db as Solid Queue database
24+
25+
browser->>runner: GET check your answers
26+
runner->>browser: HTTP 200 response
27+
browser->>user: display check your answers page
28+
29+
user->>browser: select "Submit"
30+
browser->>runner: POST submit form
31+
runner->>runner-db: save Submission
32+
runner->>solidqueue-db: enqueue send submission job
33+
34+
runner->>browser: HTTP 302 response
35+
browser->>runner: GET confirmation page
36+
runner->>browser: HTTP 200 response
37+
browser->>user: Display confirmation page
38+
39+
```
40+
41+
## Sending the submission email asynchronously
42+
43+
```mermaid
44+
45+
---
46+
title: Sending the submission email asynchronously
47+
---
48+
49+
sequenceDiagram
50+
51+
autonumber
52+
53+
participant worker as Forms runner worker
54+
participant solidqueue-db as Solid Queue database
55+
participant runner-db as Forms Runner database
56+
participant s3 as Amazon S3
57+
participant ses as Amazon SES
58+
participant sns as Amazon SNS
59+
participant inbox as Email inbox
60+
participant sentry as Sentry
61+
62+
actor processor
63+
64+
worker->>solidqueue-db: dequeue send submission job
65+
worker->>runner-db: get Submission
66+
worker->>s3: get file(s)
67+
worker->>ses: send email
68+
69+
break error
70+
alt AWS SDK error and max retries not reached
71+
worker->>solidqueue-db: schedule retry
72+
else
73+
worker->>sentry: send error
74+
end
75+
end
76+
77+
ses->>worker: return message_id
78+
worker->>runner-db: set mail_message_id on Submission
79+
worker->>runner-db: update mail_status of Submission to "pending"
80+
81+
ses-)inbox: send email
82+
note over ses,inbox: happens some time later
83+
84+
alt email sent successfully
85+
ses->>sns: send delivery notification
86+
processor->>inbox: get form from inbox
87+
processor->>processor: process form
88+
else email bounces
89+
ses->>sns: send bounce notification
90+
note over ses,sns: We have an SQS queue subscribed to the<br/> SNS topic and a recurring task to poll<br/>the SQS queue.
91+
end
92+
93+
worker->>worker: Recurring task deletes Submissions<br/>that haven't bounced after 7 days
94+
```
95+
96+
## Handling email bounces/complaints
97+
```mermaid
98+
99+
---
100+
title: Handling email bounces/complaints
101+
---
102+
103+
sequenceDiagram
104+
105+
autonumber
106+
107+
participant worker as Solid Queue worker
108+
participant solidqueue-db as Solid Queue database
109+
participant runner-db as Forms Runner database
110+
participant sqs as Amazon SQS
111+
participant sentry as Sentry
112+
113+
actor support as Forms team tech support
114+
115+
worker->>solidqueue-db: enqueue recurring receive bounces job
116+
worker->>solidqueue-db: dequeue receive bounces job
117+
worker->>sqs: get messages from bounces and complaints queue
118+
alt there is a bounce SQS message
119+
worker->>runner-db: get Submission by the message_id in the SQS message
120+
worker->>runner-db: update mail_status of Submission to "bounced"
121+
worker->>worker: Log with the submission details
122+
worker->>sentry: send error event
123+
sentry->>support: Alert via Slack
124+
support->>support: Identify why the email bounced
125+
support->>support: Run rake task to retry submission
126+
else there is a complaint SQS message
127+
worker->>runner-db: get Submission by the message_id in the SQS message
128+
worker->>worker: Log with the submission details
129+
end
130+
131+
```
132+
133+
## Handling successful deliveries
134+
135+
```mermaid
136+
137+
---
138+
title: Handling successful deliveries
139+
---
140+
141+
sequenceDiagram
142+
143+
autonumber
144+
145+
participant worker as Solid Queue worker
146+
participant solidqueue-db as Solid Queue database
147+
participant runner-db as Forms Runner database
148+
participant sqs as Amazon SQS
149+
150+
actor support as Forms team tech support
151+
152+
worker->>solidqueue-db: enqueue recurring receive deliveries job
153+
worker->>solidqueue-db: dequeue receive deliveries job
154+
worker->>sqs: get messages from deliveries queue
155+
worker->>runner-db: get Submission by the message_id in the SQS message
156+
worker->>runner-db: update mail_status of Submission to "delivered"
157+
note over worker,runner-db: we don't currently use the "delivered" status for anything other than for information
158+
```

0 commit comments

Comments
 (0)