A professional Microservice Starter Kit built with Rust, implementing Domain-Driven Design (DDD) and Clean Architecture.
RustKit is a production-ready template designed to accelerate the development of scalable and maintainable microservices. It leverages the power of Rust's ecosystem to provide a robust foundation for enterprise-grade applications.
- Domain-Driven Design (DDD): Strictly enforces separation of concerns through Domain, Application, Infrastructure, and Presentation layers.
- Clean Architecture: Ensures business logic remains independent of frameworks and external agents.
- CQRS Pattern: Implements Command Query Responsibility Segregation for optimized data handling.
- High Performance: Built on
Actix WebandTokiofor asynchronous, non-blocking execution. - Reliable Storage: Integrated PostgreSQL with
DieselORM and migration management. - OpenAPI Documentation: Automatic API documentation generation with Swagger UI.
- Container Native: Docker and Docker Compose configurations included for effortless deployment.
- Testing Model: Pre-configured integration testing environment using
Testcontainers.
The project is organized into four distinct layers, adhering to the Dependency Rule:
- Domain Layer: The core of the system, containing entities, value objects, and business rules. It has zero external dependencies.
- Application Layer: Contains application specific business rules and use cases. It orchestrates the flow of data to and from the domain entities.
- Infrastructure Layer: Provides implementations for interfaces defined in the application layer (e.g., database persistence, external API calls).
- Presentation Layer: The entry point for the application, handling HTTP requests and routing them to the appropriate application logic.
- Language: Rust
- Framework: Actix Web
- Database: PostgreSQL
- ORM: Diesel
- Async Runtime: Tokio
- Documentation: Utoipa (OpenAPI/Swagger)
- Testing: Testcontainers
- Rust (Latest Stable)
- Docker & Docker Compose
-
Clone the project
git clone https://github.com/yourusername/rustkit.git cd RustKit -
Start the environment Launch the database and service using the provided script.
cd deployment/docker ./docker-compose-all.sh up --build -d -
Explore the API Once running, the API documentation is available at:
http://localhost:8080/swagger-ui/ -
Run Locally You can also run the service directly with Cargo (ensure the database is running):
cargo run --package starter
Configuration is centralized in config.app.toml and can be overridden by environment variables.
Default Configuration:
[service]
http_url = '127.0.0.1:8181'
service_name = 'rustkit_service'
[database]
database_url = 'postgres://postgres:postgres@localhost:5432/rustkit_db'This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by kaftandev