# akram777077/store-management architecture

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

- Interactive diagram: https://gitdiagram.com/akram777077/store-management
- Repository: https://github.com/akram777077/store-management

## Overview

##### Main Components

A. Layered Architecture (from outside to inside):
- API Layer (Entry point)
- Service Layer
- Core Layer (Application/Business Logic)
- Infrastructure Layer
- Data Layer (Database)

B. Key Domain Entities:
- Products & Product Details
- Categories
- Inventory & Inventory Details
- Sales & Sale Types
- Users
- Brands
- Pricing
- Payment Methods
- Discount Rules

##### Architectural Patterns to Highlight

a. Clean Architecture:
- Dependency flow inward
- Separation of concerns

b. CQRS Pattern (Command Query Responsibility Segregation):
- Commands (Write operations)
- Queries (Read operations)
- Separate command and query paths

##### Specific Components

Frontend Integration Points:
- API Layer
- Controllers
- CategoriesController
- UnitTypesController

Core Business Logic:
- Core Layer
- Features
- Categories
- UnitTypes
- Commands
- Queries

Data Access:
- Infrastructure Layer
- Repositories
- Database Context
- Entity Configurations

##### Key Relationships

a. Request Flow:
API Controller → Service → Core (Commands/Queries) → Infrastructure → Database

b. Cross-cutting Concerns:
- Validation Behavior
- Error Handling Middleware
- Localization
- Mapping Profiles

c. Repository Pattern:
Relationship between:
- Generic Repository
- Specific Repositories
- Database Context

##### Additional Elements

- Notes for important architectural decisions
- Validation flow
- Error handling paths
- Authentication/authorization flow

##### Implementation Notes

- Document all external dependencies

- Clear separation of concerns
- Unidirectional dependency flow
- Business logic isolation
- Data access abstraction
- Service layer orchestration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph API["API Layer"]
        CTRL["Controllers"]:::api
        BASE["Base Controller"]:::api
    end

    subgraph SVC["Service Layer"]
        SVCIF["Service Interfaces"]:::service
        SVCIM["Service Implementations"]:::service
        GSVC["Generic Service"]:::service
    end

    subgraph CORE["Core Layer"]
        FEAT["Features"]:::core
        CMD["CQRS Commands"]:::core
        QRY["CQRS Queries"]:::core
        VAL["Validation"]:::core
    end

    subgraph INFRA["Infrastructure Layer"]
        DBCTX["Database Context"]:::infra
        GREP["Generic Repository"]:::infra
        ECONF["Entity Configurations"]:::infra
    end

    subgraph DATA["Data Layer"]
        ENT["Entities"]:::data
        META["Metadata"]:::data
        ROUTE["Routing"]:::data
    end

    subgraph CROSS["Cross-cutting Concerns"]
        ERR["Error Handling"]:::cross
        LOC["Localization"]:::cross
        MAP["Mapping Profiles"]:::cross
    end

    subgraph DOMAIN["Domain Entities"]
        PROD["Products"]:::domain
        CAT["Categories"]:::domain
        INV["Inventory"]:::domain
        SALE["Sales"]:::domain
        USER["Users"]:::domain
        BRAND["Brands"]:::domain
        PRICE["Pricing"]:::domain
        PAY["Payment Methods"]:::domain
        DISC["Discount Rules"]:::domain
    end

    %% Relationships
    CTRL --> SVCIF
    SVCIF --> SVCIM
    SVCIM --> GSVC
    GSVC --> FEAT
    FEAT --> CMD
    FEAT --> QRY
    CMD --> GREP
    QRY --> GREP
    GREP --> DBCTX
    DBCTX --> ENT
    VAL --> CMD
    ERR --> CTRL
    LOC --> CTRL
    MAP --> SVCIM

    %% Click events
    click CTRL "https://github.com/akram777077/store-management/tree/main/backend/API/Controllers"
    click BASE "https://github.com/akram777077/store-management/blob/main/backend/API/Base/AppBaseController.cs"
    click SVCIF "https://github.com/akram777077/store-management/tree/main/backend/Service/Interfaces"
    click SVCIM "https://github.com/akram777077/store-management/tree/main/backend/Service/ServiceImplementaions"
    click GSVC "https://github.com/akram777077/store-management/blob/main/backend/Service/ServiceBase/GenericServices.cs"
    click FEAT "https://github.com/akram777077/store-management/tree/main/backend/Core/Featurs"
    click CMD "https://github.com/akram777077/store-management/tree/main/backend/Core/Featurs/Categories/Commands"
    click QRY "https://github.com/akram777077/store-management/tree/main/backend/Core/Featurs/Categories/Queries"
    click VAL "https://github.com/akram777077/store-management/blob/main/backend/Core/Behavior/ValidationBehavior.cs"
    click DBCTX "https://github.com/akram777077/store-management/blob/main/backend/Infrastracture/Data/AppDbContext.cs"
    click GREP "https://github.com/akram777077/store-management/blob/main/backend/Infrastracture/Base/GenericRepository.cs"
    click ECONF "https://github.com/akram777077/store-management/tree/main/backend/Infrastracture/Configurations"
    click ENT "https://github.com/akram777077/store-management/tree/main/backend/Data/Entities"
    click META "https://github.com/akram777077/store-management/tree/main/backend/Data/AppMetaData"
    click ROUTE "https://github.com/akram777077/store-management/blob/main/backend/Data/AppMetaData/Router.cs"
    click ERR "https://github.com/akram777077/store-management/blob/main/backend/Core/MiddleWare/ErrorHandlerMiddleware.cs"
    click LOC "https://github.com/akram777077/store-management/tree/main/backend/Core/Localization"
    click MAP "https://github.com/akram777077/store-management/tree/main/backend/Core/Mapping"
    click PROD "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Product.cs"
    click CAT "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Category.cs"
    click INV "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Inventory.cs"
    click SALE "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Sale.cs"
    click USER "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Identity/User.cs"
    click BRAND "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Brand.cs"
    click PRICE "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/Pricing.cs"
    click PAY "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/PaymentMethod.cs"
    click DISC "https://github.com/akram777077/store-management/blob/main/backend/Data/Entities/DiscountRule.cs"

    %% Styles
    classDef api fill:#2196F3,stroke:#000,color:#fff
    classDef service fill:#4CAF50,stroke:#000,color:#fff
    classDef core fill:#FFC107,stroke:#000,color:#000
    classDef infra fill:#FF9800,stroke:#000,color:#fff
    classDef data fill:#9E9E9E,stroke:#000,color:#fff
    classDef cross fill:#9C27B0,stroke:#000,color:#fff
    classDef domain fill:#607D8B,stroke:#000,color:#fff
```
