# foxminchan/rookieshop architecture

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

- Interactive diagram: https://gitdiagram.com/foxminchan/rookieshop
- Repository: https://github.com/foxminchan/rookieshop

## Overview

##### Project Type and Purpose
- The project is an e-commerce web application built using .NET Core with Clean Architecture and Domain-Driven Design principles.
- It is structured to support both end-customer functionalities (storefront) and admin functionalities (back office), alongside supporting services such as identity management and API gateway/BFF.
- The README clearly states that RookieShop is part of a training assignment that demonstrates modern web development practices, including advanced patterns like Clean Architecture and DDD.

##### Project Structure
- The top-level directories clearly separate concerns:
- “src”: Contains multiple subprojects such as ApiService, Application, BackOffice, Bff, Domain, IdentityService, Infrastructure, Persistence, and StoreFront. Each of these corresponds to different layers or services in the overall architecture.
- “docs”: Contains design documentation and configuration for the documentation website (using VuePress).
- “tests”: Contains multiple test projects for architecture, functional tests, and unit tests, indicating that constraints like architecture testing (e.g., NetArchTest) have been applied.
- Build scripts, CI/CD pipelines (GitHub workflows, NUKE build files), and infrastructure manifests (aspirate-output with Kubernetes YAML files) reinforce that deployment and observability aspects are part of the design.

##### Understand the Key Components
- Back Office: Next.js-based admin website (located in src/RookieShop.BackOffice) – handles product, category, and customer management.
- Identity Server: A dedicated authentication service using Duende IdentityServer (located in src/RookieShop.IdentityService) – provides auth for the application.
- BFF (Backend For Frontend): Acts as an aggregator or proxy for the admin website, using Yarp (src/RookieShop.Bff).
- StoreFront: A customer-facing web application implemented using Razor Pages, htmx, Alpine.js, and ///_hyperscript (located in src/RookieShop.StoreFront) – displaying products and handling shopping interactions.
- Web API / ApiService: The service that exposes REST endpoints (src/RookieShop.ApiService) which are consumed by both storefront and back office.
- Application Layer: Contains business logic and commands/queries (src/RookieShop.Application) following use cases (e.g., operations for Baskets, Categories, Customers, Orders, Products, Reports, etc.).
- Domain Layer: Implements core entities, value objects, domain events and aggregation rules (src/RookieShop.Domain) – a central part of the DDD model.
- Infrastructure & Persistence: Handle cross-cutting concerns like caching (Redis), email (SMTP), storage (Azurite), distributed locks, logging, identity, swagger, and database mappings (src/RookieShop.Infrastructure and src/RookieShop.Persistence).
- Observability: OpenTelemetry and logging to Aspire Dashboard for monitoring (referenced in the README and supported by configuration files and assets in the project).
- AI Platform: Using OpenAI and Semantic Kernel (present via configuration in src/RookieShop.Infrastructure/Ai and references also in the README).

##### Determining Relationships and Interactions
- StoreFront and Back Office to the Web API (or via the BFF for admin).
- Identity Server providing authentication tokens to both clients.
- API Service calling the Application layer that, in turn, manipulates Domain Entities and uses Infrastructure/Persistence for data storage.
- Redis and Postgres (or Marten) as supporting services – the former for caching/session storage and the latter for persistent data.
- External integrations (Stripe webhook, OpenAI, and AI platforms) as external services connected by the Email, AI, and Infrastructure modules.
- That the BFF is using a reverse proxy (Yarp) and that the system supports both synchronous API calls and asynchronous messaging.
- Layered architecture (presentation layer, application layer, domain, and infrastructure) along with the clear boundaries enforced by the Clean Architecture.

##### Architectural Patterns and Technologies
- Clean Architecture and separation of concerns: presentation (BackOffice and StoreFront), API (Web API), business logic (Application), domain rules (Domain), and persistence/integration (Infrastructure/Persistence).
- Different patterns such as MVC (ASP.NET Core, Razor Pages, TagHelpers) for the web UI and microservices or modular monolith for separation between Identity, API, and BFF.
- That testing is applied at multiple levels and that deployment uses container orchestration (k3d, Docker) and aspirate manifests for Kubernetes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Applications"
        SF["StoreFront (Customer)"]:::client
        BO["Back Office (Admin)"]:::client
    end

    subgraph "Backend Services"
        BFF["BFF (Backend For Frontend)"]:::service
        API["Web API / ApiService"]:::service
    end

    subgraph "Core Layers"
        APP["Application Layer"]:::core
        DOM["Domain Layer"]:::core
        INF["Infrastructure"]:::core
        PST["Persistence"]:::storage
    end

    subgraph "Integration & Support"
        ID["Identity Server (Auth)"]:::auth
        OBS["Observability (Metrics)"]:::external
        AI["AI Platform"]:::external
    end

    SF -->|"HTTP"| API
    BO -->|"HTTP"| BFF
    BFF -->|"APIs"| API
    API -->|"Executes"| APP
    APP -->|"Processes"| DOM
    DOM -->|"Uses"| INF
    INF -->|"PersistsTo"| PST
    INF -->|"IntegratesWith"| AI
    INF -->|"Monitors"| OBS
    SF -->|"AuthVia"| ID
    BO -->|"AuthVia"| ID

    click SF "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.StoreFront"
    click BO "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.BackOffice"
    click BFF "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.Bff"
    click API "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.ApiService"
    click APP "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.Application"
    click DOM "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.Domain"
    click INF "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.Infrastructure"
    click PST "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.Persistence"
    click ID "https://github.com/foxminchan/rookieshop/blob/main/src/RookieShop.IdentityService"
    click OBS "https://github.com/foxminchan/rookieshop/tree/main/src/RookieShop.ServiceDefaults/OpenTelemetry"
    click AI "https://github.com/foxminchan/rookieshop/tree/main/src/RookieShop.Infrastructure/Ai"

    classDef client fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef service fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef core fill:#ffffcc,stroke:#000,stroke-width:1px;
    classDef storage fill:#ffdead,stroke:#000,stroke-width:1px;
    classDef auth fill:#ffa07a,stroke:#000,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
