Backend Framework
Building a modern backend framework with Axum and SeaORM
StateSet API
StateSet API is a comprehensive, scalable, and robust backend system designed for enterprise-grade web services. It excels in order management, inventory control, returns processing, warranty management, shipment tracking, and work order handling. Built with Rust, StateSet API leverages cutting-edge web technologies and best practices to deliver a high-performance, reliable infrastructure solution tailored for e-commerce and manufacturing businesses.
Features
-
Order Management:
- Create, retrieve, update, and delete orders
- Support for complex order workflows and statuses
-
Inventory Control:
- Real-time inventory tracking across multiple locations
- Automated reorder point notifications
-
Returns Processing:
- Streamlined return authorization and processing
- Integration with refund and exchange systems
-
Warranty Management:
- Track and manage product warranties
- Automated claim processing and resolution
-
Shipment Tracking:
- Real-time tracking integration with major carriers
- Custom shipment status notifications
-
Manufacturing & Production:
- Supplier management and communication
- Bill of Materials (BOM) tracking and version control
-
Work Order Handling:
- Create and manage work orders for repairs or modifications
- Track work order progress and resource allocation
Tech Stack
Our carefully selected tech stack ensures high performance, scalability, and maintainability.
Core Technologies
- Language: Rust (for performance and safety)
- Web Framework: Axum (lightweight and fast asynchronous web framework)
- Database: PostgreSQL with SQLx (for robust, async operations)
ORM and Query Building
- SeaORM (async ORM for Rust, providing powerful database operations)
API Protocols and Services
- REST: Handled natively by Axum
- GraphQL: Async-GraphQL (high-performance GraphQL server library for Rust)
- gRPC: Tonic (for efficient, type-safe gRPC support)
Caching and Messaging
- Caching: Redis (for high-speed data caching)
- Message Queue: RabbitMQ (for reliable async processing)
Observability
- Metrics: Prometheus (for detailed system monitoring)
- Tracing: OpenTelemetry with Jaeger (for distributed tracing)
- Logging: slog (for structured, efficient logging)
Technological Advantages:
- Rust’s Performance & Safety: Ensures memory safety without sacrificing performance, making the API highly reliable and efficient.
- Asynchronous Operations: Leveraging Rust’s async capabilities for non-blocking, high-throughput processing. Comprehensive Observability: Detailed monitoring and tracing facilitate proactive maintenance and rapid issue resolution. Flexible API Protocols: Support for multiple API protocols allows seamless integration with diverse client applications and services.
Use Cases:
- E-commerce Platforms: Managing orders, inventory, shipments, and customer interactions with high efficiency and reliability.
- Manufacturing Systems: Handling production workflows, inventory control, supplier management, and quality assurance processes.
- Enterprise Solutions: Providing a scalable and maintainable backend infrastructure for various business operations and services.
Architecture
StateSet API follows a modular, asynchronous, event-driven architecture designed for scalability and maintainability.
Key Components
- Services: Implement core business logic
- Handlers: Process HTTP requests
- Commands: Handle write operations
- Queries: Manage read operations
- Events: Enable asynchronous processing
- Models: Represent domain entities
- Middleware: Provide cross-cutting concerns (auth, rate limiting, etc.)
Performance
StateSet API is designed for high performance and scalability:
- Handles 10,000+ requests per second on a single node
- Scales horizontally for increased load
- 99.99% uptime SLA
Acknowledgments
We’re grateful to the open-source community and especially:
- Axum for the web framework
- SeaORM for ORM functionality
- Tonic for gRPC support
- Async-Graphql for GraphQL
Axum Web Service
Axum is a web framework for Rust that is designed to be simple, efficient, and powerful. It is built on top of the Tokio runtime and is designed to be asynchronous and non-blocking.
Handlers
This routes our API requests to the correct modules and handlers.
Create Order Handler
Close Return Handler
Create Order Command
Return Commands
The handlers route to the commands and queries that are used to handle the requests.
Close Return Command
Queries
Get Returns By Order Query
Get Returns By Date Range Query
SeaORM
To learn more about SeaORM, check out this article.