# nguyendaithanh2805/coffee-shop-website architecture

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

- Interactive diagram: https://gitdiagram.com/nguyendaithanh2805/coffee-shop-website
- Repository: https://github.com/nguyendaithanh2805/coffee-shop-website

## Overview

##### Main Components
- Presentation Layer: This consists of the controllers (HomeController, ProductController, CartController, etc.) found in the "controller" package and the front-end resources (the static assets under “src/main/resources/static” and the HTML templates under “src/main/resources/templates” for both admin and user). These components handle incoming HTTP requests and serve the user interface.
- Business Logic Layer: The "service" package contains service interfaces and their implementations (e.g., ProductServiceImpl, OrderServiceImpl, etc.) that encompass the business logic.
- Data Access Layer: The "repository" package is split into standard JPA repository interfaces and their "Jdbc" counterparts (for Admin, Article, Cart, etc.). These components are responsible for interacting with the database.
- Domain/Model Layer: The "model" package captures the domain entities (Product, Order, Customer, etc.).
- Configuration & Security: The "config" package contains security configuration (SecurityConfig), custom authentication handlers and resource configurations. These are critical for managing access, authentication, and resource handling in an application that involves both admin and user modules.
- Build & Deployment Infrastructure: Files like pom.xml, Maven wrapper scripts (mvnw, mvnw.cmd) and related directories (.mvn/) indicate that Maven is used for dependency management and build processes.

##### Relationships and Interactions
- Controller to Service: Show that each controller delegates to its corresponding service (e.g., ProductController calls ProductService methods).
- Service to Repository: Indicate that business logic in the service layer communicates with the repository layer to interact with the underlying database.
- Views/Resources Interaction: On the presentation side, show how the controller interacts with HTML templates and static assets to render responses.

##### Architectural Patterns
- MVC Pattern: Emphasize the separation into Model, View, and Controller components, where the controllers orchestrate between the UI and business logic.
- Layered Architecture: Illustrate the separation of concerns between presentation, business logic, and data access layers.
- Dependency Injection & Service Layer: Note that Spring’s dependency injection plays a key role in connecting the layers, which is reflected in service implementations and controllers.
- Security Framework Integration: Call out the use of Spring Security components (CustomAuthenticationSuccessHandler, SecurityConfig) along with resource configuration.

##### Relevant Technologies and Frameworks
- Spring Boot: For overall application configuration, dependency injection, and web MVC framework.
- Spring Security: For implementing authentication and authorization mechanisms.
- Maven: For build and dependency management.
- Thymeleaf or similar templating engines: Implied from the templates directory.
- JDBC (and likely JPA): Indicated by the presence of “Jdbc*Repository” classes which suggest a direct Data Access implementation in parts of the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        A("Controllers"):::controllers
        B("Static Resources & Templates"):::resources
    end

    subgraph "Business Logic Layer"
        C("Services"):::services
    end

    subgraph "Data Access & Domain Layer"
        D("Repositories"):::repositories
        E("Domain/Models"):::models
    end

    subgraph "Configuration & Security"
        F("Security & Config"):::config
    end

    subgraph "Build & Deployment"
        G("pom.xml"):::build
        H("mvnw & mvnw.cmd"):::build
        I(".mvn Directory"):::build
    end

    subgraph "External Systems"
        J("Database"):::database
    end

    Client("User/Admin Browser"):::client

    Client -->|"HTTP_Request"| A
    A -->|"Calls_Service"| C
    C -->|"Uses_Repository"| D
    D -->|"CRUD_Operations"| J
    A -->|"Renders_View"| B
    A -->|"Secured_By"| F
    C -->|"Uses_Model"| E
    F -->|"Configures_Controller"| A

    %% Click Events
    click A "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/java/org/example/coffeeshopwebsite/controller"
    click B "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/resources/static and src/main/resources/templates"
    click C "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/java/org/example/coffeeshopwebsite/service"
    click D "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/java/org/example/coffeeshopwebsite/repository"
    click E "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/java/org/example/coffeeshopwebsite/model"
    click F "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/src/main/java/org/example/coffeeshopwebsite/config"
    click G "https://github.com/nguyendaithanh2805/coffee-shop-website/blob/main/pom.xml"
    click H "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/mvnw"
    click I "https://github.com/nguyendaithanh2805/coffee-shop-website/tree/main/.mvn/"

    %% Styles
    classDef controllers fill:#CAE7FF,stroke:#1F78C1,stroke-width:2px;
    classDef resources fill:#FFECC1,stroke:#FF9800,stroke-width:2px;
    classDef services fill:#D3F9D8,stroke:#2E7D32,stroke-width:2px;
    classDef repositories fill:#F8D7DA,stroke:#C82333,stroke-width:2px;
    classDef models fill:#E2E3E5,stroke:#6C757D,stroke-width:2px;
    classDef config fill:#FFF3CD,stroke:#FFC107,stroke-width:2px;
    classDef build fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;
    classDef database fill:#FFD1DC,stroke:#C2185B,stroke-width:2px;
    classDef client fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
```
