Skip to content

Commit ba5f521

Browse files
authored
Merge pull request #172 from refactor-group/add_mailersend
Add mailersend
2 parents f9d97bf + 9043d55 commit ba5f521

File tree

16 files changed

+1116
-40
lines changed

16 files changed

+1116
-40
lines changed

.github/workflows/deploy_to_do.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ jobs:
112112
# JWT signing key for TipTap
113113
TIPTAP_JWT_SIGNING_KEY=${{ secrets.TIPTAP_JWT_SIGNING_KEY }}
114114
115+
# -------- Mailersend Config
116+
# Template ID for welcome emails
117+
WELCOME_EMAIL_TEMPLATE_ID=${{ vars.WELCOME_EMAIL_TEMPLATE_ID }}
118+
MAILERSEND_API_KEY=${{ vars.MAILERSEND_API_KEY }}
119+
115120
# -------- Frontend Config
116121
# Docker image for frontend
117122
FRONTEND_IMAGE_NAME=${{ vars.FRONTEND_IMAGE_NAME }}

Cargo.lock

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,37 @@ To run the backend directly outside of a container:
6262
The first example will start the backend with log level DEBUG and attempt to connect to a Postgres DB server on the same machine with user `refactor` and password `password` on port `5432` and selecting the database named `refactor_platform`.
6363
6464
```bash
65-
cargo run -- --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID>
65+
cargo run -- --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID> --mailersend-api-key=<MAILERSEND_API_KEY> --welcome-email-template-id=<MAILERSEND_TEMPLATE_ID>
6666
```
6767
6868
To run with a custom Postgresql connection string:
6969
7070
```bash
71-
cargo run -- -d postgres://refactor:my_password@localhost:5432/refactor_platform --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID>
71+
cargo run -- -d postgres://refactor:my_password@localhost:5432/refactor_platform --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID> --mailersend-api-key=<MAILERSEND_API_KEY> --welcome-email-template-id=<MAILERSEND_TEMPLATE_ID>
7272
```
7373
7474
To run with an additional list of allowed cross-site network origins:
7575
7676
```bash
77-
cargo run -- --allowed-origins="http://192.168.1.2:3000,https://192.168.1.2:3000" --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID>
77+
cargo run -- --allowed-origins="http://192.168.1.2:3000,https://192.168.1.2:3000" --tiptap-url https://<TIPTAP_APP_ID>.collab.tiptap.cloud --tiptap-auth-key=<TIPTAP_API_SECRET> --tiptap-jwt-signing-key=<TIPTAP_CLOUD_APP_SECRET> --tiptap-app-id=<TIPTAP_APP_ID> --mailersend-api-key=<MAILERSEND_API_KEY> --welcome-email-template-id=<MAILERSEND_TEMPLATE_ID>
78+
```
79+
80+
### Email Configuration
81+
82+
The platform uses MailerSend for transactional emails. To configure email functionality:
83+
84+
1. **Environment Variables** (for Docker):
85+
- `MAILERSEND_API_KEY`: Your MailerSend API key
86+
- `WELCOME_EMAIL_TEMPLATE_ID`: The template ID for welcome emails
87+
88+
2. **Command Line Arguments** (for direct execution):
89+
- `--mailersend-api-key`: Your MailerSend API key
90+
- `--welcome-email-template-id`: The template ID for welcome emails
91+
92+
Example:
93+
```bash
94+
export MAILERSEND_API_KEY="your-api-key"
95+
export WELCOME_EMAIL_TEMPLATE_ID="your-template-id"
7896
```
7997
8098
---

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ services:
8282
TIPTAP_URL: ${TIPTAP_URL}
8383
TIPTAP_AUTH_KEY: ${TIPTAP_AUTH_KEY}
8484
TIPTAP_JWT_SIGNING_KEY: ${TIPTAP_JWT_SIGNING_KEY}
85+
MAILERSEND_API_KEY: ${MAILERSEND_API_KEY}
86+
WELCOME_EMAIL_TEMPLATE_ID: ${WELCOME_EMAIL_TEMPLATE_ID}
8587
PLATFORM: ${PLATFORM}
8688
depends_on:
8789
- migrator

docs/architecture/system_architecture_diagram.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The Refactor Platform is a coaching management system built with Rust (Axum back
3535
### External Integrations
3636
- **TipTap**: Collaborative document editing service
3737
- **JWT**: Token generation and validation service
38+
- **MailerSend**: Transactional email service for notifications
3839

3940
## Data Flow Example
4041

@@ -84,6 +85,7 @@ graph TB
8485
%% External Services
8586
TipTap[TipTap Gateway<br/>Document Collaboration]
8687
JWT[JWT Service<br/>Token Generation]
88+
MailerSend[MailerSend<br/>Email Service]
8789
8890
%% Request Flow
8991
Client --> Nginx
@@ -135,6 +137,7 @@ graph TB
135137
%% External Integrations
136138
Domain --> TipTap
137139
Domain --> JWT
140+
Domain --> MailerSend
138141
139142
%% Styling
140143
classDef external fill:#e1f5fe

docs/runbooks/Container-README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ FRONTEND_SERVICE_PORT=3000 # Port for the front-end service
5959

6060
PLATFORM="linux/arm64/v8" # Or linux/amd64
6161

62+
# ==============================
63+
# Email Service Configuration
64+
# ==============================
65+
MAILERSEND_API_KEY="" # MailerSend API key for sending emails
66+
WELCOME_EMAIL_TEMPLATE_ID="" # Template ID for welcome emails
67+
6268
# ==============================
6369
# TipTap Service Configuration
6470
# ==============================

domain/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ edition = "2021"
55

66
[dependencies]
77
chrono = { version = "0.4.38", features = ["serde"] }
8+
email_address = "0.2"
89
entity_api = { path = "../entity_api" }
910
jsonwebtoken = "9"
1011
service = { path = "../service" }
1112
log = "0.4.22"
1213
reqwest = { version = "0.12.12", features = ["json", "rustls-tls"] }
1314
serde_json = "1.0.128"
1415
serde = {version = "1.0.210", features = ["derive"] }
16+
tokio = { version = "1.0", features = ["full"] }
1517

1618
[dependencies.sea-orm]
1719
version = "1.1.0" # sea-orm version
1820
features = ["debug-print", "runtime-tokio-native-tls", "sqlx-postgres"]
1921

22+
[dev-dependencies]
23+
mockito = "1.6"
24+
serial_test = "3.1"
25+
26+
27+

0 commit comments

Comments
 (0)