diff --git a/README.md b/README.md index 76ed2a7..c6669d0 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,112 @@ [![Parallel Docker Builds with Cache](https://github.com/ParagNaikade/OrderTrackingApp/actions/workflows/ci-pipeline.yml/badge.svg)](https://github.com/ParagNaikade/OrderTrackingApp/actions/workflows/ci-pipeline.yml) -# ๐Ÿงฑ OrderTrackingApp - Docker Commands +# ๐Ÿงพ Order Tracking System -This section lists the Docker build and run commands for each project in the solution. +A distributed order processing system built with **.NET Clean Architecture**, featuring **CQRS**, **RabbitMQ messaging**, and dual persistence in **SQL Server** and **MongoDB**. + +This project demonstrates a scalable microservice pattern using domain events and message queues to decouple the system. --- -## ๐Ÿณ Docker Commands for Local Development +## ๐Ÿ“ Architecture Overview -### ๐Ÿ“ฆ `OrderTrackingApp.Api` +``` +API โ”€โ”€> Application โ”€โ”€> Infra โ”€โ”€> RabbitMQ โ”€โ”€> Consumer + โ”‚ โ”‚ + SQL Server MongoDB +``` -```bash -# Build -docker build -f OrderTrackingApp.Api/Dockerfile -t ordertrackingapp-api . +### ๐Ÿ”„ Flow Description -# Run - docker run -it --rm -v "$(Get-Location):/app" -w /app/OrderTrackingApp.Api -p 5000:8080 mcr.microsoft.com/dotnet/sdk:8.0 dotnet watch run --urls=http://0.0.0.0:8080 +1. **API** + - Exposes endpoints to create and retrieve orders. + - Triggers a `SaveOrderCommand` when a POST request is received. -# Run within corporate network where internet is not available and need to use company certificates -docker run -it --rm -v "$(Get-Location):/app" -v "$(Get-Location)/nscacert.crt:/usr/local/share/ca-certificates/nscacert.crt:ro" -w /app/OrderTrackingApp.Api -p 5000:8080 mcr.microsoft.com/dotnet/sdk:8.0 bash -c "update-ca-certificates && dotnet watch run --urls=http://0.0.0.0:8080" -``` +2. **Application** + - Implements **CQRS** to separate command and query logic. + - Handles business rules (e.g., inventory validation). + - Saves the order to **SQL Server**. + - Raises an `OrderCreatedEvent` as a domain event. -### ๐Ÿ“ฆ `OrderTrackingApp.Consumer` +3. **Infra** + - Listens for domain events. + - Publishes messages to **RabbitMQ** queue (`order.created`). -```bash -# Build -docker build -f OrderTrackingApp.Consumer/Dockerfile -t ordertrackingapp-consumer . +4. **Consumer** + - Subscribes to the RabbitMQ queue. + - Reads order details from SQL. + - Syncs the order into **MongoDB** for read-side optimization or analytics. + +--- -# Run - docker run -it --rm -v "$(Get-Location):/app" -w /app/OrderTrackingApp.Consumer mcr.microsoft.com/dotnet/sdk:8.0 dotnet watch run +## ๐Ÿ› ๏ธ Tech Stack + +| Layer | Technology | +|--------------|--------------------------------| +| API | ASP.NET Core Web API | +| Application | MediatR, CQRS, FluentValidation| +| Infra | Entity Framework Core, RabbitMQ| +| Consumer | Background Worker, MongoDB | +| Messaging | RabbitMQ | +| Databases | SQL Server, MongoDB | +| Architecture | Clean Architecture | +| DevOps | Docker, GitHub Actions (CI/CD) | + +--- + +## ๐Ÿ“‚ Project Structure -# Run within corporate network where internet is not available and need to use company certificates - docker run -it --rm -v "$(Get-Location):/app" -v "$(Get-Location)/nscacert.crt:/usr/local/share/ca-certificates/nscacert.crt:ro" -w /app/OrderTrackingApp.Consumer mcr.microsoft.com/dotnet/sdk:8.0 bash -c "update-ca-certificates && dotnet watch run" +``` +OrderTrackingApp/ +โ”œโ”€โ”€ API # Entry point +โ”œโ”€โ”€ Application # CQRS, Commands/Queries, COre app logic +โ”œโ”€โ”€ Application.Contracts # Interfaces, DTOs, Validation +โ”œโ”€โ”€ Domain # Entities, Value Objects, Events +โ”œโ”€โ”€ Infrastructure # Event Handlers, RabbitMQ +โ”œโ”€โ”€ Consumer # Background service that syncs to MongoDB +โ”œโ”€โ”€ ReadPersistence # MongoDB Read Models +โ”œโ”€โ”€ Persistence # EF Core +โ””โ”€โ”€ docker-compose.yml # Services for RabbitMQ, SQL Server, MongoDB ``` -### ๐Ÿ“ฆ `OrderTrackingApp.Blazor.Server` +--- -```bash -# Build -docker build -f OrderTrackingApp.Blazor.Server/Dockerfile -t ordertrackingapp-blazor-server . +## ๐Ÿš€ Getting Started -# Run - docker run -it --rm -v "$(Get-Location):/app" -w /app/OrderTrackingApp.Blazor.Server mcr.microsoft.com/dotnet/sdk:8.0 dotnet watch run +### Prerequisites + +- [.NET 8 SDK](https://dotnet.microsoft.com/) +- [Docker](https://www.docker.com/) +- [MongoDB Compass](https://www.mongodb.com/products/compass) (optional for viewing MongoDB) +- [RabbitMQ Management UI](http://localhost:15672) (user: `guest`, password: `guest`) + +### Run Locally + +```bash +git clone https://github.com/ParagNaikade/order-tracking-app.git +cd order-tracking-app +docker-compose up --build ``` + +### Test API + +- `POST /api/orders` โ†’ Creates an order +- `GET /api/orders/{id}` โ†’ Retrieves an order +- `GET /api/orders` โ†’ Retrieves paginated list + +--- + +## ๐Ÿงช Features + +- โœ… Clean Architecture (Separation of Concerns) +- โœ… CQRS with MediatR +- โœ… Domain Events and Messaging +- โœ… Async Communication via RabbitMQ +- โœ… SQL Write DB & MongoDB Read DB (eventual consistency) +- โœ… Dockerized Microservices + +--- + +## ๐Ÿ“ฌ Contact + +Created with โค๏ธ by [Parag Naikade](https://paragnaikade.com/)