External Libraries and Frameworks Powering the Macro Inc Repository
The Macro Inc codebase is a Rust workspace built on axum for HTTP routing, sqlx for PostgreSQL access, the AWS SDK suite for cloud services, tokio for async execution, and tracing for observability.
The macro-inc/macro repository implements a distributed, cloud-native microservices architecture. These external libraries and frameworks form the backbone of services handling document storage, email processing, and real-time messaging, appearing consistently across the workspace's Cargo.toml and service crates.
Web Framework and API Layer
The HTTP serving stack centers on axum 0.8, which provides the routing and middleware foundation for all microservices. The repository also leverages async-graphql 7.2.1 for GraphQL endpoints and utoipa for automatic OpenAPI documentation generation.
Axum and OpenAPI Integration
In services/notification_service/src/main.rs, the application combines axum with utoipa to expose Swagger UI alongside REST endpoints:
use axum::{routing::get, Router};
use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi;
#[derive(OpenApi)]
#[openapi(
paths(
notification::list,
notification::create,
),
components(
schemas(Notification)
),
tags(
(name = "notification", description = "Notification endpoints")
)
)]
struct ApiDoc;
pub fn app() -> Router {
let api = ApiDoc::openapi();
Router::new()
.route("/notifications", get(notification::list))
.route("/notifications", post(notification::create))
.merge(SwaggerUi::new("/docs").url("/api-doc.json", api))
}
GraphQL Services
The workspace uses async-graphql to power GraphQL servers for entities like messages and channels, enabling flexible querying across service boundaries.
Database Access and Caching
For data persistence, the codebase relies on sqlx 0.8.6 with compile-time checked queries against PostgreSQL. redis provides in-memory caching for session data and temporary indices.
SQLx with PostgreSQL
The crates/attachment/src/lib.rs file demonstrates typical usage with the query_as! macro for type-safe database access:
use sqlx::Postgres;
use sqlx::query_as;
#[derive(sqlx::FromRow)]
pub struct Attachment {
pub id: i64,
pub file_key: String,
pub created_at: chrono::NaiveDateTime,
}
pub async fn fetch_by_id(pool: &sqlx::Pool<Postgres>, id: i64) -> sqlx::Result<Attachment> {
query_as!(
Attachment,
r#"SELECT id, file_key, created_at FROM attachment WHERE id = $1"#,
id
)
.fetch_one(pool)
.await
}
This pattern appears throughout services requiring durable storage, including the document storage and search services.
Message Queues and Streaming
For real-time event pipelines, the repository incorporates rdkafka to support Kafka streams. The aws-sdk-msk-iam-sasl-signer crate provides authentication for AWS Managed Streaming for Kafka (MSK) integrations.
AWS Cloud Integration
The repository extensively utilizes the AWS SDK for Rust to interact with cloud infrastructure. Key crates include aws-sdk-s3 for document storage, aws-sdk-dynamodb for connection tracking, aws-sdk-sesv2 for email delivery, and aws-sdk-sqs for message queuing.
SQS Message Publishing
In crates/notification/src/sqs.rs, the AWS SDK handles queue-based communication between services:
use aws_sdk_sqs::{Client, Error};
pub async fn send_notification(client: &Client, queue_url: &str, body: &str) -> Result<(), Error> {
client
.send_message()
.queue_url(queue_url)
.message_body(body)
.send()
.await?;
Ok(())
}
Additional AWS crates like aws-lambda-events and aws-config support serverless runtimes and SDK configuration respectively.
Async Runtime and Observability
All asynchronous operations are driven by tokio 1.43, the runtime powering HTTP handlers and background workers. For production monitoring, the codebase implements tracing and opentelemetry via crates/worker-rs-otel/src/lib.rs, exporting structured logs and distributed traces to observability backends.
The workspace root Cargo.toml lists tracing-subscriber, opentelemetry-otlp, and tracing-tree alongside the core tracing crate, ensuring comprehensive instrumentation across the microservice boundary.
Serialization and Document Processing
Data marshaling relies on the serde ecosystem, including serde_json, serde_yaml, and serde_dynamo for AWS payload handling. For document processing, pdfium-render powers PDF conversion and OCR, supported by image, zip, and ammonia for sanitization.
Utility crates like chrono for date handling, uuid for unique identifiers, and reqwest for HTTP client calls round out the dependency tree defined in the workspace Cargo.toml.
Summary
- axum and async-graphql provide the HTTP and GraphQL serving layers for all microservices.
- sqlx enables compile-time checked PostgreSQL queries, while redis handles caching.
- rdkafka and aws-sdk-msk-iam-sasl-signer support real-time event streaming via Kafka.
- The AWS SDK suite (S3, DynamoDB, SES, SQS) integrates the platform with cloud infrastructure.
- tokio drives the async runtime, supported by tracing and opentelemetry for observability.
- serde and pdfium-render handle data serialization and document processing respectively.
Frequently Asked Questions
Which web framework does Macro Inc use for HTTP routing?
The repository uses axum 0.8 as its primary web framework. This crate handles HTTP routing, request extraction, and middleware for all microservices, as evidenced by the server setup in services/notification_service/src/main.rs.
How does the codebase interact with PostgreSQL?
The codebase uses sqlx 0.8.6 with the query_as! macro for compile-time checked SQL queries. This approach appears in crates/attachment/src/lib.rs and provides type-safe database access across services like document storage and search.
Is the Macro Inc repository tied to AWS services?
Yes, the workspace heavily integrates with AWS through official SDK crates including aws-sdk-s3, aws-sdk-dynamodb, aws-sdk-sesv2, and aws-sdk-sqs. These libraries handle object storage, email delivery, and message queuing throughout the platform.
What async runtime powers the Macro Inc services?
Tokio 1.43 serves as the async runtime for all services. It drives HTTP request handling in axum and background task execution, paired with tracing and opentelemetry for structured logging and distributed tracing.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →