Allow users to share content¶
TLDR¶
Set up a new service that allows users of Employee Referrals (ER) to create and share curated web content, generate personalized links and reward participation with points.
My Role¶
Tech lead of the team that implemented this feature.
Context¶
Here's the feature: administrators select and manage web content to be shared by platform users. These users can generate personalized shareable links for the curated content and distribute them externally. The platform tracks engagement with these links and rewards users for successful shares.
Details¶
We set up a new service for this feature, and decided to try out several new things with it.
- Scala 3 as the language
- cats-effect - a pure asynchronous runtime for managing effects and concurrency
- Terraform for defining and deploying infrastructure
- Proper telemetry (manually traced) for all workflows (this turned out to be very helpful)
Here are some diagrams from my technical design for this feature.
Previewing URLs¶
sequenceDiagram
autonumber
participant FE
participant CS as content-service
participant RS1 as remote-server-1
participant RS2 as remote-server-2
participant FS as files-service
FE->>+CS: request social media<br/>preview via GET /preview
rect rgb(191, 223, 255)
note right of CS: fetching of OG data
CS->>+RS1: fetches HTML response
RS1-->>-CS: HTML is returned
CS->CS: retrieves open graph<br/>tags from HTML
CS->>+RS2: fetches image asset
RS2-->>-CS: image bytes are returned
CS->CS: validates mime type of<br/>media
end
rect rgb(200, 150, 255)
note right of CS: upload of media asset
CS->>+FS: upload image bytes via POST /api/files/binary
FS-->>-CS: uploaded file ID is returned
end
CS->CS: persist provisional preview data<br/>along with uploaded file ID
CS-->>-FE: respond back with preview information<br/>and a preview token
Saving content¶
sequenceDiagram
autonumber
participant FE
participant CS as content-service
participant FS as files-service
participant DS as data-store
participant RL as replication-lambda
FE->>+CS: request saving content<br/>via POST or PUT /content
CS->CS: retrieve <br/>previously saved preview data<br/>from "preview token" in the request
rect rgb(191, 223, 255)
note right of CS: handling of media asset
CS->>+FS: request resized image bytes<br/>via GET /api/files/<file_id>/content
FS-->>-CS: image bytes are returned
CS->>+DS: upload image bytes to data store
DS-->>-CS: a success response
end
par
CS->CS: save new content (if needed)<br/>and associate aforementioned preview data with it
CS-->>-FE: success
RL-->DS: replicate file to<br/>CDN data store
end