# mahadi-hasan16/ebasket architecture

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

- Interactive diagram: https://gitdiagram.com/mahadi-hasan16/ebasket
- Repository: https://github.com/mahadi-hasan16/ebasket

## Overview

##### Project type and purpose
- This is a full-stack e-commerce “eBasket” application.
– Backend: .NET 6 (or higher) Web API using a layered architecture (API, Core, Infrastructure).
– Frontend: Angular single-page application.
– Persistence: Entity Framework Core talking to a relational database, seeded via JSON.

##### File structure
A. Root
– eBasket.sln, global .gitignore
B. api/Ebasket
– Ebasket.Core
- Domain entities (Product, BaseEntity)
- Repository and specification interfaces
- Core business logic abstractions (Specification pattern)
– Ebasket.Infrastructure
- EF Core DbContext (StoreContext), data seed (StoreContextSeed)
- Repositories (GenericRepository, ProductRepository)
- Fluent API configurations (ProductConfiguration)
- Migrations folder
– Ebasket.API
- Controllers (ProductsController, WeatherForecastController, BuggyController)
- DTOs for input/output contracts
- Middleware (ExceptionMiddleware)
- RequestHelpers (e.g., Pagination)
- appsettings.json (configuration) and Program.cs (host setup)
C. web/ebasket.web
– Angular project (package.json, angular.json)
– src/app
- Core services (shop-service)
- Feature modules (shop listing, filters dialog, product-item)
- Shared models (pagination, product)
- Layout components (header)
– Environments folder, main.ts, index.html, styles

##### README

a. Main components
1. Angular Frontend
– UI modules & components
– ShopService (HTTP client)
2. .NET Web API
– Controllers
– Exception handling middleware
3. Core Business Layer
– Entities, Specifications, Repository interfaces
4. Infrastructure Data Layer
– EF Core DbContext, Migrations, Data seeding
– Concrete repositories, Configuration classes
5. Relational Database (e.g., SQL Server)
b. Relationships & data flow
– Frontend → HTTP calls → API Controllers
– Controllers → Core interfaces → Infrastructure implementations
– Infrastructure → EF Core → Database
– Database → EF Core → Infrastructure → Core → API → Frontend (for read)
c. Architectural patterns & principles
– Layered (Clean) Architecture: separation between API, Core, Infrastructure
– Repository + Specification patterns for query encapsulation
– Middleware pipeline for cross-cutting concerns (exceptions)
– DTOs to decouple API contract from domain entities
d. Key technologies & frameworks
– Angular (TypeScript) for UI
– .NET Web API, ASP.NET Core middleware
– Entity Framework Core for ORM
– Specification pattern (custom)
– JSON data seeding

##### Detailing essentials
– Don’t just show folders—capture logical layers and their interactions
– Annotate the specification pattern: show Specification → GenericRepository → DbSet
– Show middleware pipeline in API (incoming request → ExceptionMiddleware → Controller)
– Indicate data seeding at application startup

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Angular)" 
        direction TB
        AngularApp["Angular Frontend Application"]:::frontend
        ShopService["ShopService (HTTP client)"]:::frontend
        ShopModule["Shop Feature Module"]:::frontend
        FiltersDialog["Filters Dialog Component"]:::frontend
        ProductItem["Product-Item Component"]:::frontend
        Header["Header Layout Component"]:::frontend
        ProductModel["Shared Product Model"]:::frontend
        PaginationModel["Shared Pagination Model"]:::frontend
        AppConfig["App Routes & Main Configuration"]:::frontend
    end

    %% API Layer
    subgraph "Backend (ASP.NET Core Web API)"
        direction TB
        ExceptionMiddleware["Exception Handling Middleware"]:::api
        Controllers["API Controllers"]:::api
        ProductsController["ProductsController"]:::api
        BuggyController["BuggyController"]:::api
        WeatherController["WeatherForecastController"]:::api
        DTOs["API DTOs"]:::api
        PaginationHelper["API Request Pagination Helper"]:::api
    end

    %% Core Layer
    subgraph "Core Business Layer"
        direction TB
        Entities["Core Domain Entities"]:::core
        Interfaces["Repository & Specification Interfaces"]:::core
        Specifications["Specification Implementations"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Data Layer"
        direction TB
        StoreContext["EF Core DbContext"]:::infra
        StoreContextSeed["Data Seeding"]:::infra
        GenericRepo["GenericRepository"]:::infra
        ProductRepo["ProductRepository"]:::infra
        ProductConfig["EF Core Model Configurations"]:::infra
        Migrations["Database Migrations"]:::infra
    end

    %% Database
    Database(("Relational Database")):::db

    %% Connections
    AngularApp -->|HTTP GET /api/products| ExceptionMiddleware
    ExceptionMiddleware --> ProductsController
    ProductsController -->|uses DTOs| DTOs
    ProductsController -->|calls| Interfaces
    BuggyController --> Interfaces
    WeatherController --> Interfaces
    PaginationHelper --> ProductsController

    Interfaces -->|implemented by| GenericRepo
    Interfaces -->|implemented by| ProductRepo
    Specifications --> GenericRepo
    Specifications --> ProductRepo

    GenericRepo -->|EF Core LINQ query| StoreContext
    ProductRepo -->|EF Core LINQ query| StoreContext
    StoreContext -->|database operations| Database
    StoreContextSeed -->|seeds on startup| StoreContext
    ProductConfig --> StoreContext
    Migrations --> StoreContext

    %% Frontend internal
    AngularApp --> ShopService
    ShopService --> ShopModule
    ShopModule --> FiltersDialog
    ShopModule --> ProductItem
    ShopModule --> Header
    ShopModule --> ProductModel
    ShopModule --> PaginationModel
    AngularApp --> AppConfig

    %% Click Events
    click AngularApp "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web"
    click ShopService "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/core/services/shop-service.ts"
    click ShopModule "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/features/shop/shop.ts"
    click FiltersDialog "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/features/shop/filters-dialog/filters-dialog.ts"
    click ProductItem "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/features/shop/product-item/product-item.ts"
    click Header "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/layout/header/header.ts"
    click ProductModel "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/shared/models/product.ts"
    click PaginationModel "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/shared/models/pagination.ts"
    click AppConfig "https://github.com/mahadi-hasan16/ebasket/blob/main/web/ebasket.web/src/app/app.routes.ts"
    click ProductsController "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/Controllers/ProductsController.cs"
    click BuggyController "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/Controllers/BuggyController.cs"
    click WeatherController "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/Controllers/WeatherForecastController.cs"
    click ExceptionMiddleware "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/Middleware/ExceptionMiddleware.cs"
    click DTOs "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/DTOs/CreateProductDto.cs"
    click PaginationHelper "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.API/RequestHelpers/Pagination.cs"
    click Entities "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Entities/Product.cs"
    click Entities "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Entities/BaseEntity.cs"
    click Interfaces "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Interfaces/IGenericRepository.cs"
    click Interfaces "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Interfaces/IProductRepository.cs"
    click Interfaces "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Interfaces/ISpecification.cs"
    click Specifications "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Specifications/BaseSpecification.cs"
    click Specifications "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Specifications/ProductSpecification.cs"
    click Specifications "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Specifications/BrandListSpecification.cs"
    click Specifications "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Specifications/TypeListSpecification.cs"
    click Specifications "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Core/Specifications/ProductSpecParam.cs"
    click StoreContext "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Infrastructure/Data/StoreContext.cs"
    click StoreContextSeed "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Infrastructure/Data/StoreContextSeed.cs"
    click GenericRepo "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Infrastructure/Data/GenericRepository.cs"
    click ProductRepo "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Infrastructure/Data/ProductRepository.cs"
    click ProductConfig "https://github.com/mahadi-hasan16/ebasket/blob/main/api/Ebasket/Ebasket.Infrastructure/Config/ProductConfiguration.cs"
    click Migrations "https://github.com/mahadi-hasan16/ebasket/tree/main/api/Ebasket/Ebasket.Infrastructure/Migrations"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef api fill:#90EE90,stroke:#000,stroke-width:1px
    classDef core fill:#FFFF99,stroke:#000,stroke-width:1px
    classDef infra fill:#FFD580,stroke:#000,stroke-width:1px
    classDef db fill:#FFB6C1,stroke:#000,stroke-width:1px
```
