|
4 | 4 |
|
5 | 5 | ## Architecture Overview |
6 | 6 |
|
7 | | -Unicorn Web is primarily responsible for allowing customers to search and view property listings. It also supports ability for agents to request approval for specific property. Those approval requests are sent to Property service for validation, before Properties table is updated with approval evaluation results. |
| 7 | +Unicorn Web lets customers search for and view property listings. The Web API also allows Unicorn Properties agents to request approval for specific properties that they want to publish so they may be returned in customer searches results. These requests are sent to the Unicorn Approvals service for validation. |
8 | 8 |
|
9 | | -A core component of Unicorn Web are the Lambda functions which are responsible with completing API Gateway requests to: |
| 9 | +Lambda functions handle API Gateway requests to: |
10 | 10 |
|
11 | | -- search approved property listings |
12 | | -This function interacts with DynamoDB table to retrieve property listings marked as `APPROVED`. The API Gateway implementation and lambda code support multiple types of search patterns, and allow searching by city, street, or house number. |
| 11 | +- Search approved property listings: The **Search function** retrieves property listings marked as APPROVED from the DynamoDB table using multiple search patterns. |
13 | 12 |
|
14 | | -- request approval of property listing |
15 | | -This function sends an event to EventBridge requesting an approval for a property listing specified in the payload sent from client |
| 13 | +- Request property listing approval: The **Approval function** sends an EventBridge event requesting approval for a property listing specified in the payload. |
16 | 14 |
|
17 | | -- publication approved function |
18 | | -There is also a lambda function responsible for receiving any "Approval Evaluation Completed" events from EventBridge. This function writes the evaluation result to DynamoDB table. |
| 15 | +- Process approved listings: The **Publication Evaluation Event Handler function** processes `PublicationEvaluationCompleted` events from the Unicorn Approvals service and writes the evaluation result to the DynamoDB table. |
| 16 | + |
| 17 | +### Testing the APIs |
| 18 | + |
| 19 | +```bash |
| 20 | +export API=`aws cloudformation describe-stacks --stack-name uni-prop-local-web --query "Stacks[0].Outputs[?OutputKey=='ApiUrl'].OutputValue" --output text` |
| 21 | + |
| 22 | +curl --location --request POST "${API}request_approval" \ |
| 23 | +--header 'Content-Type: application/json' \ |
| 24 | +--data-raw '{"PropertyId": "usa/anytown/main-street/111"}' |
| 25 | + |
| 26 | + |
| 27 | +curl -X POST ${API_URL}request_approval \ |
| 28 | + -H 'Content-Type: application/json' \ |
| 29 | + -d '{"PropertyId":"usa/anytown/main-street/111"}' | jq |
| 30 | +``` |
0 commit comments