Crate Map
Mailman is organized as a Cargo workspace with 9 crates.
mailman/
├── crates/
│ ├── core/ # Domain logic (no I/O)
│ ├── adapters-postgres/ # PostgreSQL repository
│ ├── adapters-aws/ # S3, SES, SQS adapters
│ ├── adapters-scan/ # ClamAV malware scanner
│ ├── http/ # Axum router & handlers
│ ├── config/ # Configuration loading
│ ├── bin-api/ # API service entrypoint
│ ├── bin-worker/ # Worker service entrypoint
│ └── test-utils/ # Shared test helpersDependency Graph
bin-api ──► http ──► core
──► config
──► adapters-postgres ──► core
──► adapters-aws ──► core
──► adapters-scan ──► core
bin-worker ──► core
──► config
──► adapters-postgres
──► adapters-aws
──► adapters-scan
test-utils ──► core
──► http
──► adapters-postgres
──► adapters-awscore
Pure domain logic with zero I/O dependencies.
Key modules:
lib.rs— Domain entities:Domain,Inbox,EmailMessage,Thread,AuthKey,DeliveryStatus, etc.repository.rs— Repository traits:ThreadRepository,MessageRepository,DomainRepository,InboxRepository,WebhookRepository,AttachmentRepository,DeliveryEventRepository,SuppressionRepository,HealthRepository,AuthKeyRepositorythreading.rs— Thread resolution algorithm (In-Reply-To → References → Subject fallback → New thread)parser.rs— RFC 5322 MIME email parsingmime.rs— MIME message builder for outbound emailwebhooks.rs— HMAC-SHA256 signature generation for webhook payloads
adapters-postgres
Single PostgresRepository struct implementing all repository traits from core against a PgPool.
Migrations: Embedded via SQLx, run automatically on startup. Located in migrations/ directory.
adapters-aws
AWS SDK adapters implementing traits from core:
s3.rs—S3Storagefor raw email and attachment storage (presigned URLs)ses.rs—SesEmailSenderfor outbound delivery and domain identity managementsqs.rs—SqsPublisherfor queue publishing
adapters-scan
ClamAV malware scanner connecting via TCP socket (INSTREAM protocol).
ClamAvScanner— connects to a ClamAV daemon, scans buffers for malwareNoopScanner— pass-through when ClamAV is not configured
http
Axum router with all REST endpoint handlers.
Route modules: send, messages, threads, attachments, webhooks, domains, inboxes, auth_keys, reports
Middleware: auth (JWT + API key), rate_limit (governor), volume_limit (Redis), trace (request logging), pagination
config
Figment-based configuration loading with layered sources: defaults → config file (JSON/TOML) → environment variables.
bin-api / bin-worker
Thin binary entrypoints that wire together adapters and start the respective service.
test-utils
Shared test infrastructure: TestApp, E2EClient, fixtures, and mock adapter implementations.