# teransarathchandra/ordermanagementsystem architecture

> Architecture diagram of the GitHub repository teransarathchandra/ordermanagementsystem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teransarathchandra/ordermanagementsystem
- Repository: https://github.com/teransarathchandra/ordermanagementsystem

## Overview

##### Project Type and Purpose
- This is a microservices‐based Order Management System implemented in .NET (C#) with three independent services—Catalog, Customer, and Order—each exposing a Web API, managing its own database via Entity Framework Core, and composed via Docker Compose. There’s also a shared library for common cross‐cutting concerns (logging, telemetry, Swagger, middleware).

##### Main Components
a. Catalog Microservice
- Layers:
- CatalogWebApi (ASP.NET Core HTTP endpoints)
- Application (CQRS commands/queries and handlers for inventory and product retrieval)
- Domain (Product and Category domain models)
- Infrastructure (EF Core DbContext, migrations, configurations, seed data)
- Database: CatalogDB
b. Customer Microservice
- Layers:
- CustomerWebApi (HTTP endpoints for register, update, delete, retrieve)
- Application (commands/queries for CRUD logic, validators, DTOs)
- Domain (Customer model)
- Infrastructure (EF Core setup, migrations, seed data)
- Database: CustomerDB
c. Order Microservice
- Layers:
- OrderWebApi (endpoints to create, cancel, update status, list orders)
- Application (command/query handlers, validation, DTOs)
- Domain (Order, OrderItem, OrderStatus, Product)
- Infrastructure (EF Core DbContext, migrations, configurations, plus HTTP clients for CatalogService and PaymentService)
- Database: OrderDB
d. Shared Library
- Cross‐cutting concerns: SerilogExtensions, SwaggerExtensions, TelemetryExtensions, ExceptionMiddleware, ValidationMiddleware
e. External Services
- PaymentService (invoked by Order microservice; represented as an external HTTP/REST API)
f. Docker Compose
- Defines containers for each microservice and their databases; centralizes environment orchestration

##### Relationships and Interactions
- Clients → HTTP calls → CatalogWebApi / CustomerWebApi / OrderWebApi
- OrderMicroservice uses synchronous HTTP calls to:
- CatalogServiceClient (to check availability and reduce inventory)
- PaymentServiceClient (to process payments; external)
- Each service reads/writes its own database; no shared database.
- Docker Compose ensures all containers (three APIs, three databases) run together in a single network.

##### Architectural Patterns and Principles
- Microservices with bounded contexts: Catalog, Customer, Order
- Layered architecture within each service: Presentation (WebApi), Application (CQRS), Domain, Infrastructure
- CQRS for separating read/write logic
- Dependency Injection and Middleware for cross‐cutting concerns
- Database per service to enforce data ownership and decoupling
- Containerization for isolated deployments

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Client["Client"]:::external

    %% Docker Compose Boundary
    subgraph "Docker Compose network"
        direction TB

        %% Catalog Service
        subgraph "Catalog Service"
            direction TB
            CWAPI["CatalogWebApi"]:::catalog
            CAPP["Application"]:::catalog
            CDOM["Domain"]:::catalog
            CINF["Infrastructure"]:::catalog
        end
        CatalogDB[(CatalogDB)]:::catalog

        %% Customer Service
        subgraph "Customer Service"
            direction TB
            CuWAPI["CustomerWebApi"]:::customer
            CuAPP["Application"]:::customer
            CuDOM["Domain"]:::customer
            CuINF["Infrastructure"]:::customer
        end
        CustomerDB[(CustomerDB)]:::customer

        %% Order Service
        subgraph "Order Service"
            direction TB
            OWAPI["OrderWebApi"]:::order
            OAPP["Application"]:::order
            ODOM["Domain"]:::order
            OINF["Infrastructure"]:::order
            CSC["CatalogServiceClient"]:::order
            PSC["PaymentServiceClient"]:::order
        end
        OrderDB[(OrderDB)]:::order
    end

    %% External Services
    PaymentService[(PaymentService)]:::external

    %% Shared Library
    Shared["Shared Library"]:::shared

    %% Interactions
    Client -->|"HTTP/REST"| CWAPI
    Client -->|"HTTP/REST"| CuWAPI
    Client -->|"HTTP/REST"| OWAPI

    CWAPI -->|"calls"| CAPP
    CAPP -->|"uses"| CDOM
    CAPP -->|"uses"| CINF
    CINF -->|"EF Core"| CatalogDB

    CuWAPI -->|"calls"| CuAPP
    CuAPP -->|"uses"| CuDOM
    CuAPP -->|"uses"| CuINF
    CuINF -->|"EF Core"| CustomerDB

    OWAPI -->|"calls"| OAPP
    OAPP -->|"uses"| ODOM
    OAPP -->|"uses"| OINF
    OAPP -->|"sync HTTP"| CSC
    OAPP -->|"sync HTTP"| PSC
    CSC -->|"HTTP/REST"| CWAPI
    PSC -->|"HTTP/REST"| PaymentService
    OINF -->|"EF Core"| OrderDB

    Shared --> CWAPI
    Shared --> CuWAPI
    Shared --> OWAPI

    %% Click Events
    click CWAPI "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/catalog/src/CatalogWebApi"
    click CAPP "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/catalog/src/Application"
    click CDOM "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/catalog/src/Domain"
    click CINF "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/catalog/src/Infrastructure"
    click CuWAPI "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/customer/src/CustomerWebApi"
    click CuAPP "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/customer/src/Application"
    click CuDOM "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/customer/src/Domain"
    click CuINF "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/customer/src/Infrastructure"
    click OWAPI "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/order/src/OrderWebApi"
    click OAPP "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/order/src/Application"
    click ODOM "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/order/src/Domain"
    click OINF "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/order/src/Infrastructure"
    click CSC "https://github.com/teransarathchandra/ordermanagementsystem/blob/main/services/order/src/Infrastructure/Services/CatalogServiceClient.cs"
    click PSC "https://github.com/teransarathchandra/ordermanagementsystem/blob/main/services/order/src/Infrastructure/Services/PaymentServiceClient.cs"
    click Shared "https://github.com/teransarathchandra/ordermanagementsystem/tree/main/services/shared"
    click DockerCompose "https://github.com/teransarathchandra/ordermanagementsystem/blob/main/services/docker-compose.yml"
    click Solution "https://github.com/teransarathchandra/ordermanagementsystem/blob/main/services/OrderManagementSystem.sln"

    %% Styles
    classDef catalog fill:#ADD8E6,stroke:#000
    classDef customer fill:#90EE90,stroke:#000
    classDef order fill:#FFA500,stroke:#000
    classDef shared fill:#D3D3D3,stroke:#000
    classDef external fill:#F0E68C,stroke:#000
    class DockerCompose,Solution external
    style DockerCompose stroke-dasharray: 5 5
    style Solution stroke-dasharray: 5 5
```
