# ahmedzena/e-commerce-angular architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedzena/e-commerce-angular
- Repository: https://github.com/ahmedzena/e-commerce-angular

## Overview

##### Project Type and Purpose
- This is a full-stack style prototype comprised of:
- A client-side Angular SPA (single-page application) under `src/`
- A mock JSON server backend under `server/` (using `db.json` and Node.js/json-server)
- Purpose: demo an e-commerce front end with products, categories, user auth, forms, pipes, directives, and a fake REST API.

##### File Structure Analysis
- Top-level:
- `.editorconfig`, `.gitignore`, TS config, Angular CLI config (`angular.json`)
- `server/` directory containing its own `package.json` and `db.json` → mock API
- `src/` directory → all Angular code
- `src/app/` follows Angular Style Guide:
- `Directives/`, `Pipes/`, `Gaurds/`, `Model/`, `services/`, `component/`, plus `app.config.ts`, `app.routes.ts`
- Feature organization under `component/` (e.g., `/auth`, `/admin/products-dashboard`, `/user/*`, `/contact-us`, etc.)
- Configuration: `environments/` for dev/prod, `manifest.webmanifest`, `ngsw-config.json` for PWA support.

##### README Insights
- Standard Angular CLI project (v17.1.0)
- No custom architectural docs; the code structure is the sole source of truth.

##### Diagramming Conventions
– Angular modules, components, services
– External services (JSON-Server)
– Directional, labeled with HTTP verbs (GET, POST, PUT, DELETE)
– Blue for UI components
– Green for services / business logic
– Orange for external systems / backend
– Grey for shared/pure utilities (Directives, Pipes)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser and Client
    Browser["Browser"]:::ui
    subgraph "Angular Client (src/app)"
        direction TB
        AppModule["AppModule"]:::service

        subgraph "Presentation Layer (Components)" 
            direction TB
            Login["LoginComponent"]:::ui
            Logout["LogoutComponent"]:::ui
            ProductsList["ProductsListComponent"]:::ui
            ProductsParent["ProductsParentComponent"]:::ui
            ProductDetails["ProductDetailsComponent"]:::ui
            AddProduct["AddProductComponent"]:::ui
            ProductsDashboard["ProductsDashboardComponent"]:::ui
            UserReactiveForm["UserReactiveFormComponent"]:::ui
            UserTemplateForm["UserTemplateFormComponent"]:::ui
            AboutUs["AboutUsComponent"]:::ui
            ContactUs["ContactUsComponent"]:::ui
            Navbar["NavbarComponent"]:::ui
            Footer["FooterComponent"]:::ui
            SideMenu["SideMenuComponent"]:::ui
            MainHome["MainComponent"]:::ui
            NotFound["NotFoundComponent"]:::ui
            GroupRoutes["GroupRoutesComponent"]:::ui
        end

        subgraph "Services Layer" 
            direction TB
            ProductsApiService["ProductsApiService"]:::service
            ProductsService["ProductsService"]:::service
            CategoriesApiService["CategoriesApiService"]:::service
            MaterialsApiService["MaterialsApiService"]:::service
            UsersApiService["UsersApiService"]:::service
            UserAuthService["UserAuthService"]:::service
            ToastService["ToastBootstrapService"]:::service
        end

        subgraph "Shared Utilities" 
            direction TB
            ImgStyleDir["ImgStyleDirective"]:::util
            CalcDiscountPipe["CalcDiscountPipe"]:::util
            DashNumbersPipe["DashFourNumbersPipe"]:::util
            ValidationSvc["ValidationService"]:::util
        end

        subgraph "Guards & Config"
            direction TB
            LogedInGuard["LogedInGuard"]:::service
            AppConfig["app.config.ts"]:::service
            AppRoutes["app.routes.ts"]:::service
        end

        subgraph "Environments"
            direction TB
            EnvDefault["environment.ts"]:::service
            EnvDev["environment.development.ts"]:::service
        end

    end

    subgraph "Mock Backend (JSON-Server)"
        direction TB
        JsonServer["json-server"]:::backend
        DB["db.json"]:::db
    end

    %% Relationships
    Browser -->|"renders"| Login
    Browser -->|"renders"| MainHome

    Login -->|"calls"| UserAuthService
    Logout -->|"calls"| UserAuthService

    ProductsList -->|"calls"| ProductsApiService
    ProductsParent -->|"calls"| ProductsService
    ProductDetails -->|"calls"| ProductsApiService
    AddProduct -->|"calls POST"| ProductsApiService
    ProductsDashboard -->|"calls"| ProductsApiService

    UserReactiveForm -->|"uses"| ValidationSvc
    UserTemplateForm -->|"uses"| ValidationSvc

    AboutUs -->|"renders"| Navbar
    ContactUs -->|"renders"| Footer

    Navbar -->|"uses"| SideMenu
    GroupRoutes -->|"protected by"| LogedInGuard

    ProductsApiService -->|"HTTP GET/POST"| JsonServer
    CategoriesApiService -->|"HTTP GET"| JsonServer
    MaterialsApiService -->|"HTTP GET"| JsonServer
    UsersApiService -->|"HTTP GET/POST"| JsonServer
    UserAuthService -->|"HTTP POST"| JsonServer
    ToastService -->|"notifies via"| Browser

    JsonServer -->|"reads/writes"| DB
    JsonServer -->|"returns JSON"| ProductsApiService
    JsonServer -->|"returns JSON"| CategoriesApiService
    JsonServer -->|"returns JSON"| UsersApiService

    ProductsService -->|"caches"| ProductsApiService

    AppModule -->|imports| AppRoutes
    AppRoutes -->|guards| LogedInGuard

    AppModule -->|provides| ProductsApiService
    AppModule -->|provides| UserAuthService

    %% Click Events
    click Login "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/auth/login/login.component.ts"
    click Logout "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/auth/logout/logout.component.ts"
    click ProductsList "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/products-list/products-list.component.ts"
    click ProductsParent "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/products-parent/products-parent.component.ts"
    click ProductDetails "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/product-details/product-details.component.ts"
    click AddProduct "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/add-product/add-product.component.ts"
    click ProductsDashboard "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/admin/products-dashboard/products-dashboard.component.ts"
    click UserReactiveForm "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/user/user-reactive-form/user-reactive-form.component.ts"
    click UserTemplateForm "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/user/user-template-form/user-template-form/user-template-form.component.ts"
    click AboutUs "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/about-us/about-us.component.ts"
    click ContactUs "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/contact-us/contact-us.component.ts"
    click Navbar "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/navbar/navbar.component.ts"
    click Footer "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/footer/footer.component.ts"
    click SideMenu "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/side-menu/side-menu.component.ts"
    click MainHome "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/main/main.component.ts"
    click NotFound "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/not-found/not-found.component.ts"
    click GroupRoutes "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/component/group-routes/group-routes.component.ts"
    click ProductsApiService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/products-api.service.ts"
    click ProductsService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/products.service.ts"
    click CategoriesApiService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/categories-api.service.ts"
    click MaterialsApiService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/materials-api.service.ts"
    click UsersApiService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/users-api.service.ts"
    click UserAuthService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/user-auth.service.ts"
    click ToastService "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/services/toast-bootstrap.service.ts"
    click ImgStyleDir "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/Directives/img-style.directive.ts"
    click CalcDiscountPipe "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/Pipes/calc-discount-pipe.pipe.ts"
    click DashNumbersPipe "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/Pipes/dash-four-numbers.pipe.ts"
    click ValidationSvc "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/util/ValidationService.ts"
    click LogedInGuard "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/Gaurds/loged-in.guard.ts"
    click AppConfig "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/app.config.ts"
    click AppRoutes "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/app/app.routes.ts"
    click EnvDefault "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/environments/environment.ts"
    click EnvDev "https://github.com/ahmedzena/e-commerce-angular/blob/main/src/environments/environment.development.ts"
    click JsonServer "https://github.com/ahmedzena/e-commerce-angular/blob/main/server/package.json"
    click DB "https://github.com/ahmedzena/e-commerce-angular/blob/main/server/db.json"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#000,stroke-width:1px
    classDef service fill:#D0FFD6,stroke:#000,stroke-width:1px
    classDef backend fill:#FFD8A8,stroke:#000,stroke-width:1px
    classDef util fill:#E0E0E0,stroke:#000,stroke-width:1px
    classDef db fill:#FFFFFF,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
