# odoead/webuser architecture

> Architecture diagram of the GitHub repository odoead/webuser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/odoead/webuser
- Repository: https://github.com/odoead/webuser

## Overview

##### Project Type Analysis
This is a full-stack e-commerce application built with ASP.NET, following a modular architecture with clear separation of concerns. The project implements complex business logic for product management, user interactions, and promotional systems.

##### Main Components

A. Core Layers:
- API Layer (Controllers)
- Service Layer (Business Logic)
- Data Layer (EF Core + MSSQL)
- Domain Layer (Entities)

B. Feature Modules:
- Product Management
- User Management
- Cart & Order Processing
- Promotion System
- Category Management
- Review System
- Image Management
- Pricing System

C. Cross-Cutting Concerns:
- Global Exception Handling
- Logging System
- Email Service
- Authentication/Authorization
- Request/Response Pipeline

##### Use a Layered Architecture Representation
**[Client Applications]**
- ↓
**[API Controllers Layer]**
- ↓
**[Service Layer (Features)]**
- ↓
**[Data Access Layer]**
- ↓
**[Database]**

##### Feature Module Organization
**[Core Features]**
- Products
- Categories
- Users
- Orders
- Promotions

##### Service Interactions
- How PricingService interacts with Orders, Products, and Promotions
- How the PromotionBuilder system connects with various conditions and actions
- Demonstrate the relationship between Products, Categories, and Attributes

##### Key Relationships to Highlight

- Product → Category (Many-to-One)
- Product ↔ AttributeValue (Many-to-Many)
- User → Cart → CartItem → Product
- Order → OrderProduct → Product
- Promotion → Various Conditions and Actions

##### Special Architectural Elements

a) MediatR Pattern Implementation:
**[Controller] → [MediatR] → [Handler] → [Service]**

b) Service Wrapper Pattern:
**[Controller] → [ServiceWrapper] → [Individual Services]**

Top Section:
- Client-facing APIs
- Authentication
- Request Processing

Middle Section:
- Core Business Logic
- Feature Services
- MediatR Handlers

Bottom Section:
- Data Access
- External Services
- Infrastructure

Remember to:
- Notes for complex interactions
- Both synchronous and asynchronous operations
- Security boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        Client[Client Applications]
    end

    subgraph "API Layer"
        API[API Controllers]:::api
        Auth["Authentication/Token"]:::api
        click Auth "https://github.com/odoead/WebUser/blob/master/WebUser/features/User/TokenController.cs"
    end

    subgraph "Cross-Cutting Concerns"
        GEH["Global Exception Handler"]:::cross
        Logger["Logging System"]:::cross
        Email["Email Service"]:::cross
        SW["Service Wrapper"]:::cross
        VP["Validation Pipeline"]:::cross
        
        click GEH "https://github.com/odoead/WebUser/blob/master/WebUser/shared/extentions/GlobalExceptionHandler.cs"
        click Logger "https://github.com/odoead/WebUser/tree/master/WebUser/shared/Logger/"
        click Email "https://github.com/odoead/WebUser/blob/master/WebUser/shared/Email/EmailService.cs"
        click SW "https://github.com/odoead/WebUser/tree/master/WebUser/shared/ServiceWrapper/"
        click VP "https://github.com/odoead/WebUser/blob/master/WebUser/shared/Action filter/ValidationFilterAttribute.cs"
    end

    subgraph "Service Layer"
        direction TB
        subgraph "Core Features"
            PM["Product Management"]:::service
            UM["User Management"]:::service
            CP["Cart Processing"]:::service
            OP["Order Processing"]:::service
            PS["Promotion System"]:::service
            CM["Category Management"]:::service
            RS["Review System"]:::service
            IM["Image Management"]:::service
            PRS["Pricing System"]:::service
            
            click PM "https://github.com/odoead/WebUser/tree/master/WebUser/features/Product/"
            click UM "https://github.com/odoead/WebUser/tree/master/WebUser/features/User/"
            click CP "https://github.com/odoead/WebUser/tree/master/WebUser/features/Cart/"
            click OP "https://github.com/odoead/WebUser/tree/master/WebUser/features/Order/"
            click PS "https://github.com/odoead/WebUser/tree/master/WebUser/features/Promotion/"
            click CM "https://github.com/odoead/WebUser/tree/master/WebUser/features/Category/"
            click RS "https://github.com/odoead/WebUser/tree/master/WebUser/features/Review/"
            click IM "https://github.com/odoead/WebUser/tree/master/WebUser/features/Image/"
            click PRS "https://github.com/odoead/WebUser/tree/master/WebUser/PricingService/"
        end

        subgraph "Promotion Builder"
            PA["Promotion Actions"]:::promo
            PC["Promotion Conditions"]:::promo
            
            click PA "https://github.com/odoead/WebUser/tree/master/WebUser/features/Promotion/PromoBuilder/Actions/"
            click PC "https://github.com/odoead/WebUser/tree/master/WebUser/features/Promotion/PromoBuilder/Condition/"
        end
    end

    subgraph "Data Layer"
        DAL["Data Access Layer"]:::data
        DB[(Database)]:::db
        Domain["Domain Entities"]:::domain
        
        click DAL "https://github.com/odoead/WebUser/blob/master/WebUser/Data/DB_Context.cs"
        click Domain "https://github.com/odoead/WebUser/tree/master/WebUser/Domain/entities/"
    end

    %% Connections
    Client --> API
    API --> Auth
    API --> SW

    SW --> PM & UM & CP & OP & PS & CM & RS & IM & PRS
    PS --> PA & PC
    
    PM & UM & CP & OP & PS & CM & RS & IM & PRS --> DAL
    DAL --> Domain
    DAL --> DB

    %% Cross-cutting concerns connections
    API --> GEH
    API --> VP
    SW --> Logger
    SW --> Email

    %% Styles
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#388E3C,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef cross fill:#F44336,stroke:#D32F2F,color:white
    classDef promo fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef db fill:#607D8B,stroke:#455A64,color:white
    classDef domain fill:#FF9800,stroke:#F57C00,color:white

    %% Legend
    subgraph Legend
        API_L["API Layer"]:::api
        Service_L["Service Layer"]:::service
        Data_L["Data Layer"]:::data
        Cross_L["Cross-Cutting"]:::cross
        Promo_L["Promotion System"]:::promo
        DB_L["Database"]:::db
        Domain_L["Domain"]:::domain
    end
```
