- Install Erlang and Elixir dependencies using asdf:
asdf install- Install project dependencies and compile:
mix deps.get && mix compile- Set up database (requires local Postgres instance):
mix ecto.setup- Start the server:
mix phx.serverThe main reason that this project exists is to act as a working example of Elixir's pipeline processing capabilities.
Hermes is a webhook processing system designed for high throughput and low latency. The system implements a complete three-stage pipeline architecture:
- Ingestion - Fast webhook acceptance with queue-based buffering
- Processing - Message normalization and conversation management
- Dispatch - Reliable delivery through provider-specific clients
The system features automatic back-pressure propagation from persistent storage through to upstream API clients, ensuring stability under load.
-
Web API Layer
- Phoenix-based REST endpoints
- HMAC-SHA256 signature verification
- Immediate 202 Accepted responses
- Queue-based request buffering
-
Ingestion Pipeline
- Broadway-based message processing
- GenStage producer with configurable buffer
- Parallel processors for message normalization
- Batched database writes
-
Data Layer
- Postgres-backed relational model
- Ecto schema validation
- Automatic conversation resolution
- Entity conflict handling
-
Dispatch Layer
- Provider-specific API clients
- Mock clients for development/testing
- Automatic retries with exponential backoff
-
Observability
- Telemetry with metrics
- Structured JSON logging
Hermes implements a comprehensive back-pressure strategy across all system layers:
-
Web API Layer
- Immediate queue capacity checks on ingress
- 503 Service Unavailable responses with Retry-After header
- Configurable max buffer size (currently 100,000 messages)
-
Ingestion Pipeline
- GenStage demand-based flow control
- Batch size/timeout thresholds
- Parallel processor pools scaled to CPU cores
- Automatic message requeuing on failure
-
Database Layer
- Connection pool sizing aligned with batch concurrency
- Bulk insert optimizations
- Transactional error handling with automatic retries
-
Dispatch Layer
- Provider client rate limiting
- Exponential backoff retry strategy
| Entity | Description | Key Constraints |
|---|---|---|
| Party | Communication participant (email/phone) | Unique email/phone |
| Provider | Service provider (Twilio, SendGrid, etc) | Unique name |
| Channel | Communication channel (SMS, Email, etc) | Unique per provider |
| Conversation | Persistent message thread between two parties | Ordered party pairs |
| Message | Individual communication unit | Sent-at timestamp indexing |
| Attachment | Media/file associated with messages | URL validation |
- Conversations limited to two participants
- Single channel per message
- Attachment storage metadata not tracked
Webhook Verification
- HMAC-SHA256 signature validation middleware
- Secret rotation support
- Header-based channel authentication
Note: HMAC verification is implemented in lib/hermes_web/plugs/webhook.ex but needs route integration.
Built-in telemetry includes:
- Message throughput metrics
- Attachment volume tracking
- Broadway pipeline performance
- VM resource utilization
- Phoenix endpoint latency
mix test --trace