Skip to content

Commit

Permalink
enh: arch
Browse files Browse the repository at this point in the history
  • Loading branch information
notdodo committed Sep 27, 2024
1 parent c2ab7f3 commit 2f02b17
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The bot consists of two main components:
1. **User interaction**: the code in `./app/erfiume_bot.py` is triggered by a Telegram webhook that starts an AWS Lambda function when a user interacts with the bot.
2. **Stations data update**: the code in `./app/erfiume_fetcher.py` runs on a Lambda function via an EventBridge scheduler, updating the data from the stations. This data is then used by the bot to answer to messages.

![](./assets/erfiume.png)

### Main technologies:

- **Pulumi** for IaC
Expand Down
Binary file added assets/er-allertameteo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/erfiume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/padded_erfiume_640x360.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 169 additions & 1 deletion pulumi/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pulumi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pulumi-aws = "^6.52.0"
pulumi-command = "^1.0.1"
pulumi-cloudflare = "^5.39.0"
requests = "^2.32.3"
diagrams = "^0.23.4"

[tool.poetry.group.dev.dependencies]
awscli-local = "^0.22.0"
Expand Down
49 changes: 49 additions & 0 deletions pulumi/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# mypy: disable-error-code="import-untyped"
"""
Generate architecture diagram.
"""

from diagrams import Cluster, Diagram, Edge
from diagrams.aws.compute import Lambda
from diagrams.aws.database import Dynamodb
from diagrams.aws.network import APIGateway
from diagrams.custom import Custom
from diagrams.gcp.devtools import Scheduler
from diagrams.generic.device import Mobile
from diagrams.saas.cdn import Cloudflare
from diagrams.saas.chat import Telegram

graph_attr = {
"layout": "dot",
"splines": "curved",
"bgcolor": "transparent",
"beautify": "true",
"center": "true",
}


with Diagram(
"", show=True, direction="RL", graph_attr=graph_attr, filename="../assets/erfiume"
):
user = Mobile("user")
bot = Telegram("erfiume_bot")
cf = Cloudflare("erfiume.thedodo.xyz")
api = Custom(
"allertameteo.regione.emilia-romagna.it",
icon_path="../assets/er-allertameteo.png",
)
with Cluster("AWS"):
erfiume_bot = Lambda("erfiume_bot")
erfiume_fetcher = Lambda("erfiume_fetcher")
stations = Dynamodb("Stazioni")
api_gw = APIGateway("API Gateway")
scheduler = Scheduler("every 24h or 15m")

user >> Edge(label="/command") >> bot
bot >> Edge(label="trigger webhook") >> cf
cf << api_gw >> Edge(label="invoke lambda") >> erfiume_bot
erfiume_bot >> Edge(label="fetch information") >> stations
erfiume_bot >> Edge(label="send information") >> user
api << Edge(label="read information") << erfiume_fetcher
erfiume_fetcher >> Edge(label="update information") >> stations
scheduler >> Edge(label="start") >> erfiume_fetcher

0 comments on commit 2f02b17

Please sign in to comment.