# moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari architecture

> Architecture diagram of the GitHub repository moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari
- Repository: https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari

## Overview

##### Main components
- Angular Frontend
– Location: root/ (angular.json, src/)
– Modules & components under src/app (catalogue, cart, checkout, admin panels, auth, i18n, theming, etc.)
– Static assets under src/assets (CSS, fonts, images, mail form)
- Node.js API Server (Development helper / proxy)
– Location: api-server/index.js
– Exposes REST endpoints, may proxy to Spring Boot or mock data
- Spring Boot Backend (Primary business logic & data access)
– Location: backend-springBoot/src/main/java & resources
– Exposes REST API secured by Spring Security; uses Spring Data JPA + Hibernate for DB access
- Relational Database
– MySQL or PostgreSQL (configured via application.properties)
- External Services
– SMTP/mail (assets/mail/mail.php) for contact or order confirmation
– Possible third-party APIs (e.g., payment gateway—if added later)

##### Relationships and data flows
- Browser → Angular (HTTP/HTTPS)
– User interacts with UI components, which talk to Angular services (cartService, productService, authService, etc.)
- Angular → Node.js API Server (HTTP REST)
– server.ts or api-server/index.js handles front → back requests; may perform SSR or proxy to Spring Boot
- Node.js → Spring Boot (HTTP REST)
– Business logic resides here: user authentication, roles, catalogue, cart operations, orders, stock, promotions
- Spring Boot → Database (JDBC via JPA/Hibernate)
– CRUD operations on Products, Users, Orders, Stock, Promotions
- Spring Boot → External Mail Service (SMTP or PHP mail script)
– Sends order confirmations or admin notifications

##### Architectural patterns & design principles
- Frontend:
– Component-based MVVM (Angular Modules/Components plus Services)
– Angular Router for navigation, RxJS for reactive data streams, ngx-translate for i18n
- Backend:
– Layered architecture (Controller → Service → Repository)
– Security at entrypoint (Spring Security filters JWT/sessions)
– Data access abstraction via Spring Data JPA + Hibernate
- Separation of concerns: UI vs API vs Data
- Stateless REST API design

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Tier
    subgraph "Frontend: Angular 17 + TypeScript"
        direction TB
        Browser["Browser"]:::browser
        AngularApp["Angular App"]:::frontend
        Browser -->|"HTTP/HTTPS"| AngularApp

        subgraph "Components & Modules"
            direction TB
            Catalogue["CatalogueComponent"]:::frontend
            CartComp["CartComponent"]:::frontend
            Checkout["CheckoutComponent"]:::frontend
            AdminPanel["AdminComponent"]:::frontend
            AdminProd["AdminProductComponent"]:::frontend
            AdminOrder["AdminOrderComponent"]:::frontend
            Login["LoginComponent"]:::frontend
        end

        subgraph "Services"
            direction TB
            ProdSvc["ProductService"]:::frontend
            CartSvc["CartService"]:::frontend
            CmdSvc["CommandeService"]:::frontend
            PromoSvc["PromotionService"]:::frontend
            UserSvc["UserService"]:::frontend
            ThemeSvc["ThemeService"]:::frontend
        end

        subgraph "Localization & Assets"
            direction TB
            I18n["i18n (XLF)"]:::frontend
            Assets["Static Assets"]:::frontend
        end

        AngularApp --> Catalogue
        AngularApp --> CartComp
        AngularApp --> Checkout
        AngularApp --> AdminPanel
        AngularApp --> AdminProd
        AngularApp --> AdminOrder
        AngularApp --> Login
        AngularApp --> ProdSvc
        AngularApp --> CartSvc
        AngularApp --> CmdSvc
        AngularApp --> PromoSvc
        AngularApp --> UserSvc
        AngularApp --> ThemeSvc
        AngularApp --> I18n
        AngularApp --> Assets

    end

    %% API Tier
    subgraph "Dev Proxy: Node v18 + Express"
        direction TB
        NodeAPI["Node.js API Server"]:::node
        SSR["SSR / server.ts"]:::node
        AngularApp -->|"HTTP REST"| NodeAPI
        AngularApp --> SSR
    end

    %% Backend Tier
    subgraph "Backend: Spring Boot 3, Security, JPA"
        direction TB
        SpringBoot["Spring Boot Service"]:::spring
        NodeAPI -->|"HTTP REST"| SpringBoot
        subgraph "Layers"
            Controllers["Controllers"]:::spring
            Services["Services"]:::spring
            Repos["Repositories"]:::spring
        end
        SpringBoot --> Controllers
        Controllers --> Services
        Services --> Repos
    end

    %% Data & External
    subgraph "Data & External"
        direction TB
        DB["Relational DB (MySQL/PostgreSQL)"]:::db
        Mail["Mail Service (PHP Script)"]:::external
        SpringBoot -->|"JDBC (JPA/Hibernate)"| DB
        SpringBoot -->|"SMTP/HTTP"| Mail
    end

    %% Click Events
    click Browser "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/angular.json"
    click AngularApp "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/main.ts"
    click AngularApp "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/index.html"
    click Catalogue "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/catalog-component/catalog-component.component.ts"
    click CartComp "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/cart/cart.component.ts"
    click CartSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/cart.service.ts"
    click Checkout "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/checkout/checkout.component.ts"
    click AdminPanel "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/admin/admin.component.ts"
    click AdminProd "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/admin-product/admin-product.component.ts"
    click AdminOrder "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/admin-commande/admin-commande.component.ts"
    click Login "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/login/login.component.ts"
    click UserSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/user.service.ts"
    click ProdSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/product.service.ts"
    click CmdSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/commande.service.ts"
    click PromoSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/promotion.service.ts"
    click ThemeSvc "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/app/servises/theme.service.ts"
    click I18n "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/locale/messages.xlf"
    click I18n "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/locale/messages.fr.xlf"
    click Assets "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/assets/css/main.css"
    click Assets "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/tree/master/src/assets/fonts"
    click Assets "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/tree/master/src/assets/images"
    click Assets "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/src/assets/mail/mail.php"
    click NodeAPI "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/api-server/index.js"
    click SSR "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/server.ts"
    click SpringBoot "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/tree/master/backend-springBoot/src/main/java"
    click SpringBoot "https://github.com/moahmmed-el-khaiari/tp_angular_mohammed_elkhaiari/blob/master/backend-springBoot/src/main/resources/application.properties"

    %% Styles
    classDef browser fill:#a8d0e6,stroke:#3896ba,color:#000;
    classDef frontend fill:#ffb347,stroke:#ff8c00,color:#000;
    classDef node fill:#b4e197,stroke:#38a349,color:#000;
    classDef spring fill:#6c757d,stroke:#344a45,color:#fff;
    classDef db fill:#c39bd3,stroke:#7d3c98,color:#000;
    classDef external fill:#d5d8dc,stroke:#99a3a4,color:#000;
```
