# arifshn/dotnetstore architecture

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

- Interactive diagram: https://gitdiagram.com/arifshn/dotnetstore
- Repository: https://github.com/arifshn/dotnetstore

## Overview

##### Project Type and Purpose
- DotnetStore is a monolithic, ASP.NET Core 9.0 MVC e-commerce web application with an admin panel and built-in authentication/authorization.
- Users browse products, add to cart, checkout, and review; admins manage products, categories, orders, and reviews.
- A future Angular-based SPA front end and a REST API (DotnetStoreApi) are in progress.

##### File Structure
- Controllers (AccountController, CartController, OrderController, AdminController, etc.) implement HTTP endpoints.
- Views & ViewComponents render Razor pages.
- Services (CartService, FavoriteService, SmtpEmailService) contain business logic.
- Data folder has EF Core entities, ApplicationDbContext, Entities (Urun, Kategori, Cart, Order, Review), ASP.NET Identity models (AppUser, AppRole), and migrations.
- Models folder holds request/response DTOs.
- wwwroot serves static assets (CSS, JS, Bootstrap, jQuery).
- Program.cs / appsettings*.json configure DI, middleware, EF Core, Identity, SMTP.

##### Key Insights from README
- ASP.NET Core MVC layered architecture (Presentation → Business → Data).
- SQL Server 2019 as the relational store.
- External SMTP email service for notifications and password resets.
- Upcoming Angular 19 front end with REST API endpoints.

##### Main Components
a. Presentation Layer
– Client browsers (desktop/mobile) with HTTP/TLS requests.
– (Future) Angular SPA calling REST API endpoints.
– Current Razor Views + ViewComponents served from ASP.NET MVC.
b. Web Application
– Controllers (Account, Home, Urun, Cart, Order, Admin, etc.).
– Services (business logic): CartService, FavoriteService, SmtpEmailService, etc.
– Dependency Injection container (configured in Program.cs).
c. Data Layer
– EF Core DbContext (DataContext) → SQL Server database.
– Migrations manage schema.
d. Authentication/Authorization
– ASP.NET Core Identity (AppUser, AppRole).
e. External Services
– SMTP Email server.
– (Optional) Payment gateway if added later.
f. Static Asset Server
– wwwroot (CSS, JS, images, Bootstrap, jQuery).

##### Relationships & Data Flow
1. Client → HTTP GET/POST → ASP.NET Core MVC middleware (Program.cs).
2. Middleware → Router → Controller Action.
3. Controller uses injected Services for business operations.
4. Services call DataContext (EF Core) → SQL Server (CRUD).
5. Controller returns a ViewModel → Razor View / JSON (for REST API).
6. (Optional) SmtpEmailService uses SMTP to send emails.
7. Static files served directly from wwwroot.

##### Architectural Patterns & Principles
- Layered Architecture (Separation of Concerns: Presentation, Business, Data).
- MVC pattern in the web layer.
- Dependency Injection for loose coupling.
- Repository-style data access via EF Core DbContext.
- DTOs/ViewModels isolate domain entities from views/API.

##### Essential Elements to Capture
- Presentation: Razor Views / Angular SPA (future)
- Controllers & Routing
- Service Layer (business logic)
- Data Layer & Migrations
- Authentication/Authorization (ASP.NET Identity)
- Static Assets (wwwroot)
- External SMTP Email service

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Client Browser"]:::presentation
        AngularSPA["Angular SPA (future)"]:::presentation
        MVCViews["Razor Views"]:::presentation
        ViewComps["ViewComponents"]:::presentation
        StaticAssets["Static Assets (wwwroot)"]:::presentation
    end

    %% Business Layer
    subgraph "Web Application - Business Layer"
        direction TB
        Middleware["ASP.NET Core MVC Middleware"]:::business
        Controllers["Controllers"]:::business
        DI["Dependency Injection (Program.cs)"]:::business
        Config["Configuration (appsettings*.json)"]:::business
        ServiceCart["CartService"]:::business
        ServiceFav["FavoriteService"]:::business
        ServiceSMTP["SmtpEmailService"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DataContext["DataContext (EF Core)"]:::data
        Migrations["Migrations"]:::data
        SeedDB["SeedDatabase"]:::data
        subgraph "Entities"
            direction TB
            Urun["Urun"]:::data
            Kategori["Kategori"]:::data
            CartEnt["Cart"]:::data
            OrderEnt["Order"]:::data
            ReviewEnt["Review"]:::data
            Address["Address"]:::data
            Slider["Slider"]:::data
            Favori["Favori"]:::data
        end
        subgraph "Identity Models"
            direction TB
            AppUser["AppUser"]:::data
            AppRole["AppRole"]:::data
            ApplicationUser["ApplicationUser"]:::data
        end
        SQLServer["SQL Server"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP Email Server"]:::external
    end

    %% Relationships
    Browser -->|HTTP/TLS| Middleware
    AngularSPA -->|REST API Calls| Middleware
    Browser -->|Static File Requests| StaticAssets
    Middleware -->|Routing| Controllers
    Controllers -->|uses| ServiceCart
    Controllers -->|uses| ServiceFav
    Controllers -->|uses| ServiceSMTP
    Controllers -->|DI Configured by| DI
    Controllers -->|reads config from| Config
    ServiceCart -->|CRUD| DataContext
    ServiceFav -->|CRUD| DataContext
    ServiceSMTP -->|SMTP Calls| SMTP
    DataContext -->|Migrations| Migrations
    SeedDB -->|seeds| SQLServer
    DataContext -->|SQL Operations| SQLServer
    DataContext -->|manages| Urun
    DataContext -->|manages| Kategori
    DataContext -->|manages| CartEnt
    DataContext -->|manages| OrderEnt
    DataContext -->|manages| ReviewEnt
    DataContext -->|manages| Address
    DataContext -->|manages| Slider
    DataContext -->|manages| Favori
    DataContext -->|manages| AppUser
    DataContext -->|manages| AppRole
    DataContext -->|manages| ApplicationUser

    %% Click Events
    click MVCViews "https://github.com/arifshn/dotnetstore/tree/master/Views/"
    click ViewComps "https://github.com/arifshn/dotnetstore/tree/master/ViewComponents/"
    click Controllers "https://github.com/arifshn/dotnetstore/tree/master/Controllers/"
    click ServiceCart "https://github.com/arifshn/dotnetstore/blob/master/Services/CartService.cs"
    click ServiceFav "https://github.com/arifshn/dotnetstore/blob/master/Services/FavoriteService.cs"
    click ServiceSMTP "https://github.com/arifshn/dotnetstore/blob/master/Services/SmtpEmailService.cs"
    click DI "https://github.com/arifshn/dotnetstore/blob/master/Program.cs"
    click Config "https://github.com/arifshn/dotnetstore/blob/master/appsettings.json"
    click DataContext "https://github.com/arifshn/dotnetstore/blob/master/Data/DataContext.cs"
    click Migrations "https://github.com/arifshn/dotnetstore/tree/master/Migrations/"
    click SeedDB "https://github.com/arifshn/dotnetstore/blob/master/Data/SeedDatabase.cs"
    click Urun "https://github.com/arifshn/dotnetstore/blob/master/Data/Urun.cs"
    click Kategori "https://github.com/arifshn/dotnetstore/blob/master/Data/Kategori.cs"
    click CartEnt "https://github.com/arifshn/dotnetstore/blob/master/Data/Cart.cs"
    click OrderEnt "https://github.com/arifshn/dotnetstore/blob/master/Data/Order.cs"
    click ReviewEnt "https://github.com/arifshn/dotnetstore/blob/master/Data/Review.cs"
    click Address "https://github.com/arifshn/dotnetstore/blob/master/Data/Address.cs"
    click Slider "https://github.com/arifshn/dotnetstore/blob/master/Data/Slider.cs"
    click Favori "https://github.com/arifshn/dotnetstore/blob/master/Data/Favori.cs"
    click AppUser "https://github.com/arifshn/dotnetstore/blob/master/Data/AppUser.cs"
    click AppRole "https://github.com/arifshn/dotnetstore/blob/master/Data/AppRole.cs"
    click ApplicationUser "https://github.com/arifshn/dotnetstore/blob/master/Data/ApplicationUser.cs"
    click StaticAssets "https://github.com/arifshn/dotnetstore/tree/master/wwwroot/"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef business fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px;
    classDef external fill:#f8d7da,stroke:#333,stroke-width:1px;
```
