# abdulhamidshahade/blueberry24 architecture

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

- Interactive diagram: https://gitdiagram.com/abdulhamidshahade/blueberry24
- Repository: https://github.com/abdulhamidshahade/blueberry24

## Overview

##### Project type and purpose
- BlueBerry24 is a modern, full-stack e-commerce platform.
- Backend: .NET 9 Web API following Clean Architecture.
- Frontend: Next.js 15 with React, TypeScript, Bootstrap.

##### File structure
- Top-level solution contains five main projects:
- BlueBerry24.API – ASP.NET Core Minimal Web API (Controllers, Program.cs, appsettings).
- BlueBerry24.Application – Application/use-case layer (DTOs, services, AutoMapper, authorization).
- BlueBerry24.Domain – Core business entities, validations, repository interfaces, constants.
- BlueBerry24.Infrastructure – EF Core DbContext, repository implementations, Redis and Identity stores.
- BlueBerry24.Web – Next.js frontend (app router pages, components, client-side services, API routes).
- Tests folder reserved for xUnit/Playwright in future.
- Dockerfiles at API and Web roots signal containerized deployment.
- Endpoints.md and Swagger integration suggest documented API surface.

##### README for architecture insights
- Clean Architecture with strict layer dependencies:
Domain → Application → Infrastructure → API
- Frontend organizes pages under src/app, reusable components under src/components, client services under src/lib/services, server actions under src/lib/actions.
- External concerns: SQL Server (via EF Core), Redis caching, Gmail SMTP, JWT/ASP.NET Identity.
- Key features: products, categories, inventory, cart, checkout, orders, coupons, wishlists, role-based auth, admin dashboard.

- User’s Browser / Mobile App (HTTP client)
- Next.js Frontend (BlueBerry24.Web)
- API Gateway / Reverse Proxy (optional, e.g., Nginx or Vercel)
- ASP.NET Core Web API (BlueBerry24.API – Controllers)
- Application Layer (BlueBerry24.Application – services & use-cases)
- Domain Layer (BlueBerry24.Domain – entities, repository interfaces)
- Infrastructure Layer (BlueBerry24.Infrastructure – DbContext, repo implementations, Redis, Identity store)
- Data Stores: SQL Server database, Redis cache
- External Services: SMTP/Gmail, Identity Provider (JWT issuance), optional CDN or blob storage (for uploads under Web/public).
1. Browser → Next.js pages/components → calls client-side services (fetch/axios) → API endpoint
2. BlueBerry24.API Controllers → inject Application services → orchestrate business logic
3. Application services → reference Domain entities & repository interfaces → apply use-case rules
4. Repository implementations in Infrastructure → EF Core → SQL Server
5. Application may call Infrastructure Redis cache or external SMTP for email
6. Authentication flow: API issues JWT via Identity stores, returned to frontend → stored and used in Authorization header for subsequent calls
c. Architectural patterns & design principles:
- Clean Architecture / Hexagonal: clear concentric layers, dependency inversion (inward).
- Repository + Unit of Work patterns for data access.
- DTOs & AutoMapper for boundary mapping.
- Attribute-based authorization and policy handlers.
- Server actions vs client services in Next.js for data mutations.
d. Key technologies & frameworks (annotate near each component):
- Next.js 15 + React 19 + TypeScript + Bootstrap 5
- ASP.NET Core 9 Minimal APIs, Swashbuckle/Swagger
- EF Core 9, SQL Server
- Redis distributed cache
- ASP.NET Identity + JWT Bearer
- FluentValidation, AutoMapper

##### Final recommendations
- Critical components: UI pages, client services, API controllers, services, repositories, entities, DB, cache, external SMTP.
- Iterate with the team to ensure all edge cases (e.g., admin vs user flows, caching, email) are visually represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User Browser / Mobile App"]:::frontend
        Pages["Next.js Pages (src/app)"]:::frontend
        Components["UI Components (src/components)"]:::frontend
        ClientServices["Client-side Services (src/lib/services)"]:::frontend
        ServerActions["Server Actions (src/app/api)"]:::frontend
    end

    %% API Gateway
    APIGateway["API Gateway / Reverse Proxy (Nginx/Vercel)"]:::api

    %% API Layer
    subgraph "API Layer"
        direction TB
        Controllers["API Controllers"]:::api
        Program["Program.cs"]:::api
        AppSettings["appsettings.example.json"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        AppDI["DI Registration (ApplicationLayerRegistration.cs)"]:::application
        Authorization["Authorization Handlers (Authorization)"]:::application
        DTOs["DTOs (Dtos)"]:::application
        Mapping["AutoMapper Profiles (Mapping)"]:::application
        Services["Business Services (Services)"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Entities["Core Entities & Validation (Entities)"]:::domain
        Constants["Constants (Constants)"]:::domain
        RepoInterfaces["Repository Interfaces (Repositories)"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        InfraDI["DI Registration (InfrastructureLayerRegistration.cs)"]:::infra
        DbContext["ApplicationDbContext.cs"]:::infra
        HealthCheck["DatabaseHealthCheck.cs"]:::infra
        RepoImpl["Repository Implementations (Repositories)"]:::infra
    end

    %% Data Stores
    subgraph "Data Stores & External"
        direction TB
        SQLServer["SQL Server Database"]:::datastore
        RedisCache["Redis Cache"]:::datastore
        SMTP["SMTP / Gmail"]:::external
        IdentityProvider["Identity Provider (JWT/ASP.NET Identity)"]:::external
    end

    %% Relationships
    Browser --> Pages
    Pages --> Components
    Components --> ClientServices
    ClientServices --> ServerActions
    ServerActions --> APIGateway
    APIGateway --> Controllers
    Controllers --> Program
    Program --> AppSettings
    Controllers --> Services
    Services --> RepoInterfaces
    RepoInterfaces --> RepoImpl
    RepoImpl --> DbContext
    DbContext --> SQLServer
    Services --> RedisCache
    Services --> SMTP
    Controllers --> IdentityProvider
    InfraDI --> DbContext
    AppDI --> Services
    Authorization --> Services
    Mapping --> Services
    DTOs --> Services

    %% Click Events
    click Controllers "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.API/Controllers"
    click Program "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.API/Program.cs"
    click AppSettings "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.API/appsettings.example.json"
    click AppDI "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.Application/DI/ApplicationLayerRegistration.cs"
    click Authorization "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Application/Authorization"
    click DTOs "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Application/Dtos"
    click Mapping "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Application/Mapping"
    click Services "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Application/Services"
    click Entities "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Domain/Entities"
    click Constants "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Domain/Constants"
    click RepoInterfaces "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Domain/Repositories"
    click DbContext "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.Infrastructure/Data/ApplicationDbContext.cs"
    click HealthCheck "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.Infrastructure/Data/DatabaseHealthCheck.cs"
    click RepoImpl "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Infrastructure/Repositories"
    click InfraDI "https://github.com/abdulhamidshahade/blueberry24/blob/master/BlueBerry24.Infrastructure/DI/InfrastructureLayerRegistration.cs"
    click Pages "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Web/src/app"
    click Components "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Web/src/components"
    click ClientServices "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Web/src/lib/services"
    click ServerActions "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Web/src/app/api"
    click DockerAPI "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.API/Dockerfile"
    click DockerWeb "https://github.com/abdulhamidshahade/blueberry24/tree/master/BlueBerry24.Web/Dockerfile"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0B69A3,color:#0B69A3;
    classDef api fill:#DFF7DF,stroke:#2E7D32,color:#2E7D32;
    classDef application fill:#FFF4C2,stroke:#FFB300,color:#BF360C;
    classDef domain fill:#FFECB3,stroke:#FFA000,color:#BF360C;
    classDef infra fill:#FFE0B2,stroke:#E65100,color:#BF360C;
    classDef datastore fill:#ECEFF1,stroke:#607D8B,color:#37474F;
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#616161;
```
