# tructran91/litecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/tructran91/litecommerce
- Repository: https://github.com/tructran91/litecommerce

## Overview

##### Project type and purpose
- This is a .NET-based, learning‐focused e-commerce system built with a microservice architecture.
- It consists of:
- A Blazor SPA (“LiteCommerce.Admin”) as the frontend
- An Ocelot API Gateway
- A set of backend microservices (Catalog implemented; User, Inventory, Order, Payment, Shipping, Notification, Promotion planned)
- A shared library for cross‐cutting concerns

##### File structure
- Top-level:
- ApiGateways/Ocelot.ApiGateway → API Gateway
- Services/Catalog → the Catalog microservice, further broken down into:
– Catalog.API (ASP.NET controllers, middleware, DI extensions)
– Catalog.Application (CQRS/MediatR behaviors, commands/queries, handlers, validators, services)
– Catalog.Core (domain entities, enums, exceptions, repository interfaces)
– Catalog.Infrastructure (EF Core DbContext, migrations, repository implementations, data seed)
- Shared/LiteCommerce.Shared → shared constants, models, logging
- Web/LiteCommerce.Admin → Blazor client (pages, components, API clients)
- Notice the layered pattern inside each service and the separation of concerns between layers.

##### README for additional insights
- Confirms microservice goals: modularity, scalability, maintainability.
- Technology stack: .NET 8, SQL Server per service, REST APIs + (future) message broker.

##### Detail
- Drill down only on implemented flow (Blazor → Gateway → Catalog → CatalogDb).
- Shared components (Shared library) that span multiple services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["User's Browser"]:::external
        SPA["LiteCommerce.Admin"]:::frontend
    end
    Browser -->|HTTP| SPA

    %% Gateway Layer
    subgraph "Gateway Layer"
        Gateway["Ocelot API Gateway"]:::gateway
    end
    SPA -->|HTTP| Gateway

    %% Service Layer
    subgraph "Service Layer"
        subgraph "Catalog Service"
            CSA["Catalog.API"]:::service
            CSApp["Catalog.Application"]:::service
            CSCore["Catalog.Core"]:::service
            CSInf["Catalog.Infrastructure"]:::service
        end
        FutureUser["User Service (Future)"]:::service
        FutureInventory["Inventory Service (Future)"]:::service
        FutureOrder["Order Service (Future)"]:::service
        FuturePayment["Payment Service (Future)"]:::service
        FutureShipping["Shipping Service (Future)"]:::service
        FutureNotification["Notification Service (Future)"]:::service
        FuturePromotion["Promotion Service (Future)"]:::service
    end
    Gateway -->|REST| CSA

    %% Service Internal Flow
    CSA -->|Calls| CSApp
    CSApp -->|Uses Domain| CSCore
    CSCore -->|Persists via| CSInf

    %% Data Layer
    subgraph "Data Layer"
        CDB["CatalogDb"]:::database
        UDB["UserDb (Future)"]:::database
        IDB["InventoryDb (Future)"]:::database
        ODB["OrderDb (Future)"]:::database
        PDB["PaymentDb (Future)"]:::database
        SDB["ShippingDb (Future)"]:::database
        NDB["NotificationDb (Future)"]:::database
        PRDB["PromotionDb (Future)"]:::database
    end
    CSInf -->|EF Core| CDB

    %% Shared Library
    Shared["LiteCommerce.Shared"]:::shared
    CSApp -. compile-time .-> Shared
    SPA -. compile-time .-> Shared

    %% Click Events
    click SPA "https://github.com/tructran91/litecommerce/blob/main/Web/LiteCommerce.Admin"
    click Gateway "https://github.com/tructran91/litecommerce/blob/main/ApiGateways/Ocelot.ApiGateway"
    click CSA "https://github.com/tructran91/litecommerce/blob/main/Services/Catalog/Catalog.API"
    click CSApp "https://github.com/tructran91/litecommerce/blob/main/Services/Catalog/Catalog.Application"
    click CSCore "https://github.com/tructran91/litecommerce/blob/main/Services/Catalog/Catalog.Core"
    click CSInf "https://github.com/tructran91/litecommerce/blob/main/Services/Catalog/Catalog.Infrastructure"
    click Shared "https://github.com/tructran91/litecommerce/blob/main/Shared/LiteCommerce.Shared"

    %% Styles
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef gateway fill:#9370DB,stroke:#333,stroke-width:1px
    classDef service fill:#1E90FF,stroke:#333,stroke-width:1px
    classDef database fill:#32CD32,stroke:#333,stroke-width:1px
    classDef external fill:#A9A9A9,stroke:#333,stroke-width:1px
    classDef shared fill:#D3D3D3,stroke:#333,stroke-width:1px
```
