# laihuyha/angularnetcorewebapp architecture

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

- Interactive diagram: https://gitdiagram.com/laihuyha/angularnetcorewebapp
- Repository: https://github.com/laihuyha/angularnetcorewebapp

## Overview

##### Project Type and Purpose
- This is a full-stack e-commerce web application.
- Frontend: Angular single-page app under the **client/** folder.
- Backend API: ASP.NET Core Web API in the **API/** project, serving both JSON endpoints and static Angular files from **wwwroot/**.
- Domain & Business Logic: Defined in **Core/** (entities, DTOs, service interfaces, specifications).
- Data & Infrastructure: In **Infrastructure/** (EF Core DbContexts, repositories, Unit of Work, migrations, seed data).
- Supporting services via Docker Compose: Redis (caching), Redis-Commander (UI), and likely PostgreSQL for Identity.

##### File-Structure & Architectural Patterns
- Top-level layers correspond to a Clean/Onion Architecture:
- **client/** (Presentation/UI)
- **API/** (API Gateway / Presentation + Middleware + Authentication)
- **Core/** (Domain & Application Service Interfaces)
- **Infrastructure/** (Data Access, EF Core configurations, UnitOfWork, external integrations)
- The README emphasizes the Unit of Work pattern for transactional consistency across multiple repositories.
- Configuration/build scripts include Docker Compose for local dev, GitHub Actions workflows for CI (.NET, Node.js), and Angular CLI config.

##### Key Insights from README
- All database operations are orchestrated via a UnitOfWork that aggregates multiple generic repositories to enforce single‐transaction commits/rollbacks.
- HTTPS is enforced for the Angular dev server via mkcert.
- Redis is used for caching via **ResponseCacheServices**.
- Stripe is the primary payment provider, with plans to add PayPal/Braintree/MoMo in the future.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Angular["Angular Client"]:::blue
    end

    subgraph "API Layer"
        Startup["Startup.cs"]:::green
        Program["Program.cs"]:::green
        subgraph "Controllers"
            Account["AccountController.cs"]:::green
            Products["ProductsController.cs"]:::green
            CartCtrl["CartController.cs"]:::green
            OrderCtrl["OrderController.cs"]:::green
            PaymentCtrl["PaymentController.cs"]:::green
            ErrorCtrl["ErrorController.cs"]:::green
            Buggy["BuggyController.cs"]:::green
            FallBack["FallBackController.cs"]:::green
        end
        WWW["wwwroot"]:::green
    end

    subgraph "Core Layer"
        Interfaces["Interfaces"]:::yellow
        Models["Models/Entities"]:::yellow
        RequestParams["RequestParams"]:::yellow
        Specs["Specifications"]:::yellow
    end

    subgraph "Infrastructure Layer"
        Data["Data"]:::orange
        Identity["Identity"]:::orange
        Config["Config"]:::orange
        Services["Services"]:::orange
    end

    subgraph "Persistence & External"
        ShopDb[(ShopContext DB)]:::gray
        IdentityDb[(AppIdentityDbContext DB)]:::gray
        RedisCache[(Redis Cache)]:::gray
        Postgres[(PostgreSQL)]:::gray
        RedisCommander[(Redis-Commander UI)]:::gray
        Stripe[(Stripe API)]:::gray
    end

    Angular -->|"HTTPS/API Calls"| Program
    Program --> Startup
    Startup -->|"Configure Controllers"| Account
    Startup --> Products
    Startup --> CartCtrl
    Startup --> OrderCtrl
    Startup --> PaymentCtrl
    Startup --> ErrorCtrl
    Startup --> Buggy
    Startup --> FallBack
    Startup --> WWW

    Account -->|"uses"| Interfaces
    Products --> Interfaces
    CartCtrl --> Interfaces
    OrderCtrl --> Interfaces
    PaymentCtrl --> Interfaces
    ErrorCtrl --> Interfaces

    Interfaces --> RequestParams
    Interfaces --> Specs
    Interfaces --> Models

    Interfaces --> Services
    Services --> Data
    Services --> Identity
    Services --> Config

    Data --> ShopDb
    Identity --> IdentityDb

    Account -->|"cache"| RedisCache
    Products --> RedisCache
    CartCtrl --> RedisCache
    OrderCtrl --> RedisCache

    PaymentCtrl -->|"REST"| Stripe
    RedisCache --> RedisCommander

    classDef blue fill:#cce5ff,stroke:#004085,color:#004085;
    classDef green fill:#d4edda,stroke:#155724,color:#155724;
    classDef yellow fill:#fff3cd,stroke:#856404,color:#856404;
    classDef orange fill:#ffe5b4,stroke:#cc8400,color:#cc8400;
    classDef gray fill:#e2e3e5,stroke:#6c757d,color:#6c757d;

    click Angular "https://github.com/laihuyha/angularnetcorewebapp/tree/master/client/"
    click Startup "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Startup.cs"
    click Program "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Program.cs"
    click Account "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/AccountController.cs"
    click Products "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/ProductsController.cs"
    click CartCtrl "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/CartController.cs"
    click OrderCtrl "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/OrderController.cs"
    click PaymentCtrl "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/PaymentController.cs"
    click ErrorCtrl "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/ErrorController.cs"
    click Buggy "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/BuggyController.cs"
    click FallBack "https://github.com/laihuyha/angularnetcorewebapp/blob/master/API/Controllers/FallBackController.cs"
    click WWW "https://github.com/laihuyha/angularnetcorewebapp/tree/master/API/wwwroot/"
    click Interfaces "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Core/Interfaces/"
    click Models "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Core/Models/Entities/"
    click RequestParams "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Core/RequestParams/"
    click Specs "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Core/Specifications/"
    click Data "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Infrastructure/Data/"
    click Identity "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Infrastructure/Identity/"
    click Config "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Infrastructure/Config/"
    click Services "https://github.com/laihuyha/angularnetcorewebapp/tree/master/Infrastructure/Services/"
```
