The Order Management System is a backend service designed for an e-commerce platform. It allows users to:
- Create orders via a REST API.
- Manage order processing using RabbitMQ and a worker service.
- Query and list orders.
This system is built using .NET 8, Entity Framework Core, RabbitMQ, and SQLite.
- REST API Endpoints:
POST /api/orders
: Create a new order and enqueue it to RabbitMQ.GET /api/orders
: Retrieve a list of all orders.GET /api/orders/{id}
: Get details of a specific order by ID.
- Order Processing:
- Orders are processed by a background worker service and RabbitMQ.
- After creating an order, the handler publishes an event to the RabbitMQ queue, and the consumer consumes the event message by updating order statuses from "Pending" to "Processed".
- The worker works every 1 min and updates order statuses from "Processed" to "Completed".
- Database:
- SQLite is used to store order data.
- Validation:
- FluentValidation ensures input data is valid.
- .NET 8.0: Core framework for building the application.
- Entity Framework Core: ORM for database management.
- RabbitMQ: Message broker for order processing.
- MassTransit: Abstraction layer for RabbitMQ.
- SQLite: Lightweight database for persistent storage.
- xUnit: Unit testing framework.
- Moq: For mocking dependencies in unit tests.
- Docker: For containerized deployment.
- .NET 8 SDK
- Docker
- RabbitMQ Management Plugin (enabled in Docker Compose)
git clone https://github.com/halilcifttur/OrderManagementSystem.git
cd OrderManagementSystem
Ensure Docker is installed and running, then execute:
docker-compose up --build
This command will:
- Start RabbitMQ with the management interface at
http://localhost:15672
. - Start the API service on
http://localhost:5000
. - Start the Worker service.
- Swagger UI: The API documentation and testing interface is available at:
http://localhost:5000/swagger
Run the unit tests with:
dotnet test
OrderManagementSystem
├── src
│ ├── OrderManagementSystem.API # API service
│ ├── OrderManagementSystem.Application # Business logic and CQRS
│ ├── OrderManagementSystem.Domain # Domain entities and interfaces
│ ├── OrderManagementSystem.Infrastructure # Data and messaging implementations
│ └── OrderManagementSystem.Worker # Background worker service
├── tests
│ └── OrderManagementSystem.Tests # Unit tests
├── docker-compose.yml # Docker Compose configuration
└── README.md # Project documentation
-
POST /api/orders:
- Description: Creates a new order.
- Request Body:
{ "productName": "string", "price": decimal }
- Response:
{ "id": "guid" }
-
GET /api/orders:
- Description: Retrieves a list of all orders.
-
GET /api/orders/{id}:
- Description: Retrieves the details of an order by its ID.