# miusuario-steven/e-commerce-eagle-tech architecture

> Architecture diagram of the GitHub repository miusuario-steven/e-commerce-eagle-tech, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miusuario-steven/e-commerce-eagle-tech
- Repository: https://github.com/miusuario-steven/e-commerce-eagle-tech

## Overview

##### Project Type & Purpose
- This is a full-stack E-Commerce system built with Angular (frontend) and Spring Boot (backend).
- It follows a Hexagonal (Ports & Adapters) architecture on the backend, and a modular component-service pattern on the frontend.
- Key business capabilities: user registration/authentication (JWT + roles), product browsing & cart management, PayPal checkout, order history, admin CRUD for products/categories.

##### File Structure Analysis
- Top-level:
- backend/ → Java/Spring Boot service with pom.xml, src/main/java, src/main/resources, src/test
- frontend/ → Angular application with src/app components, services, interceptors, routing
- Backend layers under src/main/java/com/eagletech/ecommerce/backend:
- domain/port & model → core business interfaces and entities
- application/ → service classes implementing use cases (CategoryService, OrderService, etc.)
- infrastructure/ → adapters (Spring Data JPA repos), REST controllers, DTOs, mappers (MapStruct), security (JWT filters & configs), PayPal integration
- frontend/src/app:
- components/ – UI components (authentication, product list, cart, orders, admin panels)
- services/ – HTTP services wrapping REST API calls
- common/ – shared model interfaces & types
- guards & interceptors – JWT auth guard, HTTP interceptor

##### Extracted Architectural Insights from README
- Hexagonal architecture with clear separation:
- Domain (entities & ports)
- Application (business logic)
- Infrastructure (adapters, controllers, persistence)
- Angular standalone components for fast load, Tailwind CSS for styling
- Spring Security + JWT for auth, PayPal SDK for payments, PostgreSQL for persistence

##### Main Components
a. Frontend Layer (Angular App)
- UI Components & Routes
- HTTP Services (CategoryService, ProductService, AuthService, etc.)
- Auth Interceptor & Auth Guard
b. Backend Layer (Spring Boot API)
- REST Controllers (CategoryController, ProductController, OrderController, PaypalController, Auth Controllers)
- Application Services (use-case orchestrators)
- Domain Ports (ICategoryRepository, IOrderRepository, etc.) & Models (Product, Order, User, etc.)
- Infrastructure Adapters:
– JPA Repositories (CategoryCrudRepositoryImpl, etc.) → PostgreSQL
– MapStruct Mappers
– JWT Generator, Validator, Filters → Spring Security
– PayPal SDK Integration Service
c. Database
- PostgreSQL schema reflecting entities: users, products, categories, orders, order_products
d. External Services
- PayPal API

##### Component Relationships & Data Flow
- User Browser → Angular UI → HTTP Request (with JWT) → REST Controllers
- Controller → maps DTO → calls Application Service → invokes Domain Port
- Domain Port → Infrastructure Adapter → JPA Repository → PostgreSQL
- For payments: Application Service → PayPalService → PayPal API → returns payment URL/confirmation
- JWT Generation on login/registration → issued to client → sent on subsequent requests → validated by JWTFilter → security context

##### Architectural Patterns & Design Principles
- Hexagonal Architecture (Ports & Adapters) on backend for testability and separation of concerns
- Layered MVC within the hexagon: Controllers (inbound), Services (use-cases), Domain (business rules), Adapters (outbound)
- Dependency Inversion: business logic depends on interfaces (ports), implemented by infrastructure
- Angular Modular Components + Services + Interceptors for clear UI-to-API separation

##### Essential Details to Capture
- Authentication flow (JWT issuance & validation)
- PayPal integration path
- Separation of concerns (which class lives in which hexagon segment)
- Angular routing & guard protecting admin vs. user paths
- Data transformation via DTOs & Mappers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    User["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend (Angular App)"
        UI["UI Components & Routes"]:::frontend
        HTTP["HTTP Services"]:::frontend
        Interceptor["Auth Interceptor"]:::frontend
        Guard["Auth Guard"]:::frontend
    end

    %% Backend Inbound Adapters
    subgraph "Backend Inbound Adapters (REST Controllers & JWT Filter)"
        CategoryController["CategoryController"]:::app
        ProductController["ProductController"]:::app
        OrderController["OrderController"]:::app
        PaypalController["PaypalController"]:::app
        LoginController["LoginController"]:::app
        RegistrationController["RegistrationController"]:::app
        UserController["UserController"]:::app
        HomeController["HomeController"]:::app
        JWTFilter["JWTAuthorizationFilter"]:::infra
    end

    %% Backend Application Layer
    subgraph "Application Layer (Use-Case Services)"
        CategoryService["CategoryService"]:::app
        ProductService["ProductService"]:::app
        OrderService["OrderService"]:::app
        RegistrationService["RegistrationService"]:::app
        UserService["UserService"]:::app
        UploadFile["UploadFile"]:::app
    end

    %% Backend Domain Layer
    subgraph "Domain Layer (Ports & Models)"
        IPorts["ICategoryRepo, IProductRepo, IOrderRepo, IUserRepo"]:::domain
        Models["Category, Product, Order, OrderProduct, OrderState, User, UserType, DataPayment, URLPaypalResponse"]:::domain
    end

    %% Backend Outbound Adapters
    subgraph "Outbound Adapters"
        JPA["JPA Repositories"]:::infra
        Mappers["MapStruct Mappers"]:::infra
        JWTUtils["JWTGenerator, JWTValidate, Constants"]:::infra
        SecurityConfig["SecurityConfig & CustomUserDetailService"]:::infra
        PaypalService["PaypalService & PaypalConfig"]:::infra
    end

    %% External Systems
    DB["PostgreSQL Database"]:::db
    PayPal["PayPal API"]:::external

    %% Connections
    User --> UI
    UI --> Guard
    UI --> HTTP
    HTTP -->|JWT| Interceptor
    Interceptor --> CategoryController
    Interceptor --> ProductController
    Interceptor --> OrderController
    Interceptor --> PaypalController
    Interceptor --> LoginController
    Interceptor --> RegistrationController
    Interceptor --> UserController
    Interceptor --> HomeController
    CategoryController -->|calls| CategoryService
    ProductController -->|calls| ProductService
    OrderController -->|calls| OrderService
    RegistrationController -->|calls| RegistrationService
    UserController -->|calls| UserService
    CategoryService -->|uses| IPorts
    ProductService -->|uses| IPorts
    OrderService -->|uses| IPorts
    UserService -->|uses| IPorts
    RegistrationService -->|uses| IPorts
    IPorts -->|implemented by| JPA
    Models -->|mapped by| Mappers
    CategoryService -->|handles payments via| PaypalService
    PaypalService -->|calls| PayPal
    JPA -->|reads/writes| DB
    JWTFilter -->|validates JWT| SecurityConfig

    %% Click Events
    click UI "https://github.com/miusuario-steven/e-commerce-eagle-tech/tree/master/frontend/src/app/components"
    click HTTP "https://github.com/miusuario-steven/e-commerce-eagle-tech/tree/master/frontend/src/app/services"
    click Interceptor "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/frontend/src/app/auth.interceptor.ts"
    click Guard "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/frontend/src/app/guards/auth.guard.ts"

    click CategoryController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/CategoryController.java"
    click ProductController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/ProductController.java"
    click OrderController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/OrderController.java"
    click PaypalController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/PaypalController.java"
    click LoginController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/LoginController.java"
    click RegistrationController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/RegistrationController.java"
    click UserController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/UserController.java"
    click HomeController "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/rest/HomeController.java"

    click CategoryService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/CategoryService.java"
    click ProductService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/ProductService.java"
    click OrderService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/OrderService.java"
    click RegistrationService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/RegistrationService.java"
    click UserService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/UserService.java"
    click UploadFile "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/application/UploadFile.java"

    click JPA "https://github.com/miusuario-steven/e-commerce-eagle-tech/tree/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/adapter"
    click Mappers "https://github.com/miusuario-steven/e-commerce-eagle-tech/tree/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/mapper"
    click JWTFilter "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/jwt/JWTAuthorizationFilter.java"
    click JWTUtils "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/jwt/JWTGenerator.java"
    click SecurityConfig "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/config/SecurityConfig.java"
    click PaypalService "https://github.com/miusuario-steven/e-commerce-eagle-tech/blob/master/backend/src/main/java/com/eagletech/ecommerce/backend/infrastructure/service/PaypalService.java"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef app fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef domain fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef infra fill:#FFEBEE,stroke:#C62828,color:#C62828
    classDef db fill:#EDE7F6,stroke:#3949AB,color:#3949AB
    classDef external fill:#ECEFF1,stroke:#546E7A,color:#546E7A
```
