# mohamedelareeg/domaindrivenerp architecture

> Architecture diagram of the GitHub repository mohamedelareeg/domaindrivenerp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamedelareeg/domaindrivenerp
- Repository: https://github.com/mohamedelareeg/domaindrivenerp

## Overview

This is a Clean Architecture ERP Web API. Its user workflow begins with an HTTP request, passes through presentation controllers into CQRS-style application use cases, and returns a standardized result; application handlers use domain repository abstractions for business data. Major capabilities include product and category management, customers, orders and invoices, accounting, and identity/roles. The tree and README support these subsystem boundaries, but most implementation wiring was not sampled, so uncertain runtime links are dashed and marked unverified.

Main entry points: [`src/DomainDrivenERP.Presentation/Controllers`](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Presentation/Controllers) (HTTP controllers), [`src/DomainDrivenERP.Domain/Abstractions/Persistence/Repositories`](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Domain/Abstractions/Persistence/Repositories) (Repository contracts), [`src/DomainDrivenERP.Application/Features/Products`](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Products) (Products and categories), [`src/DomainDrivenERP.Persistence/Repositories`](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Persistence/Repositories) (SQL repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and presentation"]
  node_presentation["HTTP controllers<br/>[Controllers]"]
  node_response["Result formatting"]
  node_errors["Exception handling"]
end

subgraph group_business["ERP workflows"]
  node_products["Products and categories<br/>[Products]"]
  node_customers["Customers<br/>[Customers]"]
  node_orders["Orders<br/>[Orders]"]
  node_invoices["Invoices<br/>[Invoices]"]
  node_accounting["COA and journals<br/>[Coas]"]
  node_journalqueries["Journal queries<br/>[Journals]"]
  node_messaging["CQRS messaging<br/>[Messaging]"]
end

subgraph group_domaindata["Domain and persistence"]
  node_domain["Domain model<br/>[Entities]"]
  node_repositories["Repository contracts<br/>[Repositories]"]
  node_persistence["SQL repositories<br/>[Repositories]"]
  node_cache[("Distributed cache<br/>[CacheService.cs]")]
end

subgraph group_identity["Identity and services"]
  node_identityapi["Authentication and roles<br/>[Authentication]"]
  node_authservice["JWT identity service<br/>[AuthService.cs]"]
  node_identitydata[("Identity database")]
  node_email["Email service<br/>[EmailService.cs]"]
end

node_user(("API client"))
node_sql[("SQL Server")]
node_redis[("Redis")]

node_user -->|"sends request"| node_presentation
node_presentation -->|"sends request"| node_messaging
node_presentation -->|"formats result"| node_response
node_presentation -->|"dispatches use case"| node_products
node_presentation -->|"dispatches use case"| node_identityapi
node_products -->|"uses contracts"| node_repositories
node_customers -->|"uses contracts"| node_repositories
node_accounting -->|"uses contracts"| node_repositories
node_journalqueries -->|"uses contracts"| node_repositories
node_repositories -.->|"implemented by"| node_persistence
node_persistence -.->|"reads and writes"| node_sql
node_persistence -.->|"may cache"| node_cache
node_cache -.->|"stores cache"| node_redis
node_products -.->|"uses entities"| node_domain
node_customers -->|"uses entities"| node_domain
node_identityapi -.->|"delegates identity"| node_authservice
node_authservice -->|"uses identity store"| node_identitydata
node_authservice -->|"sends reset email"| node_email
node_identitydata -.->|"persists identity"| node_sql
node_errors -.->|"handles request errors"| node_presentation

click node_presentation "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Presentation/Controllers"
click node_response "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Presentation/Base/AppControllerBase.cs"
click node_errors "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.API/MiddleWares/GlobalExceptionHandlerMiddleWare.cs"
click node_products "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Products"
click node_customers "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Customers"
click node_orders "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Orders"
click node_invoices "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Invoices"
click node_accounting "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Coas"
click node_journalqueries "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Journals"
click node_messaging "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Abstractions/Messaging"
click node_domain "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Domain/Entities"
click node_repositories "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Domain/Abstractions/Persistence/Repositories"
click node_persistence "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Persistence/Repositories"
click node_cache "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Persistence/Caching/CacheService.cs"
click node_identityapi "https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Authentication"
click node_authservice "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Identity/Services/AuthService.cs"
click node_identitydata "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Identity/Data/IdentityDbContext.cs"
click node_email "https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Infrastructure/Services/EmailService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_presentation,node_response,node_errors,node_user toneBlue
class node_products,node_customers,node_orders,node_invoices,node_accounting,node_journalqueries,node_messaging,node_sql,node_redis toneAmber
class node_domain,node_repositories,node_persistence,node_cache toneMint
class node_identityapi,node_authservice,node_identitydata,node_email toneRose
```

## Components

### API and presentation

- [HTTP controllers](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Presentation/Controllers): `src/DomainDrivenERP.Presentation/Controllers`
- [Result formatting](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Presentation/Base/AppControllerBase.cs): `src/DomainDrivenERP.Presentation/Base/AppControllerBase.cs`
- [Exception handling](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.API/MiddleWares/GlobalExceptionHandlerMiddleWare.cs): `src/DomainDrivenERP.API/MiddleWares/GlobalExceptionHandlerMiddleWare.cs`

### ERP workflows

- [Products and categories](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Products): `src/DomainDrivenERP.Application/Features/Products`
- [Customers](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Customers): `src/DomainDrivenERP.Application/Features/Customers`
- [Orders](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Orders): `src/DomainDrivenERP.Application/Features/Orders`
- [Invoices](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Invoices): `src/DomainDrivenERP.Application/Features/Invoices`
- [COA and journals](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Coas): `src/DomainDrivenERP.Application/Features/Coas`
- [Journal queries](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Journals): `src/DomainDrivenERP.Application/Features/Journals`
- [CQRS messaging](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Abstractions/Messaging): `src/DomainDrivenERP.Application/Abstractions/Messaging`

### Domain and persistence

- [Domain model](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Domain/Entities): `src/DomainDrivenERP.Domain/Entities`
- [Repository contracts](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Domain/Abstractions/Persistence/Repositories): `src/DomainDrivenERP.Domain/Abstractions/Persistence/Repositories`
- [SQL repositories](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Persistence/Repositories): `src/DomainDrivenERP.Persistence/Repositories`
- [Distributed cache](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Persistence/Caching/CacheService.cs): `src/DomainDrivenERP.Persistence/Caching/CacheService.cs`

### Identity and services

- [Authentication and roles](https://github.com/mohamedelareeg/domaindrivenerp/tree/master/src/DomainDrivenERP.Application/Features/Authentication): `src/DomainDrivenERP.Application/Features/Authentication`
- [JWT identity service](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Identity/Services/AuthService.cs): `src/DomainDrivenERP.Identity/Services/AuthService.cs`
- [Identity database](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Identity/Data/IdentityDbContext.cs): `src/DomainDrivenERP.Identity/Data/IdentityDbContext.cs`
- [Email service](https://github.com/mohamedelareeg/domaindrivenerp/blob/master/src/DomainDrivenERP.Infrastructure/Services/EmailService.cs): `src/DomainDrivenERP.Infrastructure/Services/EmailService.cs`

### Other components

- **API client**
- **SQL Server**
- **Redis**

## Connections

- API client → HTTP controllers: sends request
- HTTP controllers → CQRS messaging: sends request (evidence: `src/DomainDrivenERP.Presentation/Controllers/ProductsController.cs`)
- HTTP controllers → Result formatting: formats result (evidence: `src/DomainDrivenERP.Presentation/Controllers/ProductsController.cs`)
- HTTP controllers → Products and categories: dispatches use case (evidence: `src/DomainDrivenERP.Presentation/Controllers/ProductsController.cs`)
- HTTP controllers → Authentication and roles: dispatches use case (evidence: `src/DomainDrivenERP.Presentation/Controllers/RolesController.cs`)
- Products and categories → Repository contracts: uses contracts (evidence: `src/DomainDrivenERP.Application/Features/Products/Queries/GetProductBySku/GetProductBySkuQueryHandler.cs`)
- Customers → Repository contracts: uses contracts (evidence: `src/DomainDrivenERP.Application/Features/Customers/Queries/RetriveCustomer/RetriveCustomerQueryHandler.cs`)
- COA and journals → Repository contracts: uses contracts (evidence: `src/DomainDrivenERP.Application/Features/Coas/Queries/GetCoaWithChildrens/GetCoaWithChildrensQueryHandler.cs`)
- Journal queries → Repository contracts: uses contracts (evidence: `src/DomainDrivenERP.Application/Features/Journals/Queries/GetJournalById/GetJournalByIdQueryHandler.cs`)
- Repository contracts → SQL repositories: implemented by (evidence: `src/DomainDrivenERP.Persistence/Repositories/Customers/CustomerSqlRepository.cs`)
- SQL repositories → SQL Server: reads and writes
- SQL repositories → Distributed cache: may cache
- Distributed cache → Redis: stores cache
- Products and categories → Domain model: uses entities (evidence: `src/DomainDrivenERP.Application/Features/Products/Queries/GetProductBySku/GetProductBySkuQueryHandler.cs`)
- Customers → Domain model: uses entities (evidence: `src/DomainDrivenERP.Application/Features/Customers/Queries/RetriveCustomer/RetriveCustomerQueryHandler.cs`)
- Authentication and roles → JWT identity service: delegates identity (evidence: `src/DomainDrivenERP.Identity/Services/AuthService.cs`)
- JWT identity service → Identity database: uses identity store (evidence: `src/DomainDrivenERP.Identity/Services/AuthService.cs`)
- JWT identity service → Email service: sends reset email (evidence: `src/DomainDrivenERP.Identity/Services/AuthService.cs`)
- Identity database → SQL Server: persists identity
- Exception handling → HTTP controllers: handles request errors
