# harryho/ng-crm architecture

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

- Interactive diagram: https://gitdiagram.com/harryho/ng-crm
- Repository: https://github.com/harryho/ng-crm

## Overview

##### Main Components
- Browser/Client: Represents the user’s browser where the Angular app runs.
- Angular Application: This central block should be subdivided into several key areas:
- Layout/Structural Components: Include the header, sidebar (navigation), top-strip, and overall layout components.
- Feature Modules: Show the different pages like Dashboard, Customer, Order, Product, and various UI components. Each feature module (e.g., “customer”, “order”, “product”) should be represented as separate nodes.
- Shared Components & Directives: Indicate the shared module that includes the dialog component, validators, and common utilities.
- Components: Represent reusable components like blog-card, monthly-earnings, product-performance, recent-transactions, and sales-overview.
- Services: Include authentication, backend service (for both fake API and any simulated REST calls), core service, and navigation service as separate nodes that manage business logic and data flow.
- Models: Represent data structures and interfaces such as user models.
- Pipes: Include custom pipes like the filter pipes used to transform data.
- Assets & Styling: Although not “functional” in terms of logic, include SCSS and other assets which are vital for the UI/UX.
- External Tools/Services:
- Docker & Nginx: Represent the Docker container setup and the Nginx server configuration (as seen in the Dockerfile, nginx.conf and docker build/run instructions in the README).
- Angular CLI & Build Tools: Show the build and deployment pipeline, including npm commands, testing, and serving the application through CLI and Docker.

##### Relationships and Interactions
- Component Interaction:
- Layout components (header, sidebar, top-strip) act as the container for other components.
- Feature pages utilize shared components and services.
- Guards (like auth.guard.service.ts, customer-guard.service.ts, order-guard.service.ts, and product-guard.service.ts) manage route protection. Show them as decision points between routes.
- Data Flow:
- Services handle business logic and data fetching. Indicate that these services (authentication service, backend service) communicate with external/fake APIs.
- Models serve as the data contracts used between components and services.
- Build/Deployment Pipeline:
- Paths for development (ng serve, npm start) and production (build commands, Docker image build and deployment via Nginx).

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Reflect how Angular organizes UI into reusable components.
- Service-Oriented Data Flow: Emphasize how services abstract business logic and handle interactions (even though currently connecting to a fake API).
- The use of CSS preprocessor (SCSS) and theming indicates a clear separation between logic and presentation, reinforcing modular design.

##### Technologies & Libraries
- Angular 19 & Angular CLI.
- Angular Material (for UI components and styling).
- RxJS (for reactive programming aspects, though not explicitly detailed, it's standard in Angular projects).
- Docker and Nginx for containerizing and serving the application, as indicated by the Dockerfile and nginx.conf.
- SCSS for structured and theme-based styling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Clients
    Browser["User's Browser / Client"]:::external

    %% Angular Application
    subgraph "Angular Application"
        direction TB
        App["Angular App"]:::app
        
        subgraph "Layout Components"
            Header["Header Layout"]:::layout
            Sidebar["Sidebar Navigation"]:::layout
            TopStrip["Top Strip Layout"]:::layout
        end

        subgraph "Feature Modules"
            Dashboard["Dashboard Module"]:::module
            Customer["Customer Module"]:::module
            Order["Order Module"]:::module
            Product["Product Module"]:::module
            UI["UI Components Module"]:::module
        end

        subgraph "Shared & Reusable Components"
            Shared["Shared Components & Directives"]:::shared
            subgraph "Reusable Components"
                Blog["Blog Card Component"]:::component
                Monthly["Monthly Earnings Component"]:::component
                ProductPerf["Product Performance Component"]:::component
                Transactions["Recent Transactions Component"]:::component
                Sales["Sales Overview Component"]:::component
                Yearly["Yearly Breakup Component"]:::component
            end
            subgraph "Services & Guards"
                AuthService["Authentication Service"]:::service
                BackendService["Backend Service"]:::service
                CoreService["Core Service"]:::service
                NavService["Navigation Service"]:::service
                AuthGuard["Auth Guard Service"]:::guard
                CustGuard["Customer Guard Service"]:::guard
                OrderGuard["Order Guard Service"]:::guard
                ProdGuard["Product Guard Service"]:::guard
            end
            Models["Models"]:::model
            Pipes["Custom Filter Pipe"]:::pipe
        end

        subgraph "Assets & Styling"
            SCSS["SCSS & Styling Assets"]:::asset
            GlobalStyles["Global Styles"]:::asset
        end
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        Docker["Docker Configuration"]:::external
        Nginx["Nginx Configuration"]:::external
        BuildTools["Angular CLI & Build Tools"]:::external
    end

    %% Connections - Data Flow and Interactions
    Browser -->|"loads"| App
    App -->|"contains"| Header
    App -->|"contains"| Sidebar
    App -->|"contains"| TopStrip
    App -->|"routes to"| Dashboard
    App -->|"routes to"| Customer
    App -->|"routes to"| Order
    App -->|"routes to"| Product
    App -->|"routes to"| UI

    %% Layout components container relationships
    Header --- Sidebar
    Header --- TopStrip

    %% Feature Modules interactions with Shared Components & Services
    Dashboard -->|"uses"| Shared
    Customer -->|"uses and guardedBy"| CustGuard
    Order -->|"uses and guardedBy"| OrderGuard
    Product -->|"uses and guardedBy"| ProdGuard
    UI -->|"displays"| Blog
    UI -->|"displays"| Monthly
    UI -->|"displays"| ProductPerf
    UI -->|"displays"| Transactions
    UI -->|"displays"| Sales
    UI -->|"displays"| Yearly

    %% Services interactions within Feature Modules
    Dashboard -->|"fetchesData"| BackendService
    Customer -->|"authenticatesVia"| AuthService
    Order -->|"coreLogic"| CoreService
    Product -->|"navigatesVia"| NavService

    %% Route Protection
    Dashboard -->|"protectedBy"| AuthGuard

    %% Shared Components using Models and Pipes
    Shared -->|"uses"| Models
    Shared -->|"transformsDataWith"| Pipes

    %% Styling Influence
    App --- SCSS
    App --- GlobalStyles

    %% Build & Deployment Interaction
    App -->|"buildsWith"| BuildTools
    BuildTools -->|"containerizesWith"| Docker
    Docker -->|"servedBy"| Nginx

    %% Click Events
    click App "https://github.com/harryho/ng-crm/tree/master/src/app"
    click Header "https://github.com/harryho/ng-crm/tree/master/src/app/layouts/header"
    click Sidebar "https://github.com/harryho/ng-crm/tree/master/src/app/layouts/sidebar"
    click TopStrip "https://github.com/harryho/ng-crm/tree/master/src/app/layouts/top-strip"
    click Dashboard "https://github.com/harryho/ng-crm/tree/master/src/app/pages/dashboard"
    click Customer "https://github.com/harryho/ng-crm/tree/master/src/app/pages/customer"
    click Order "https://github.com/harryho/ng-crm/tree/master/src/app/pages/order"
    click Product "https://github.com/harryho/ng-crm/tree/master/src/app/pages/product"
    click UI "https://github.com/harryho/ng-crm/tree/master/src/app/pages/ui-components"
    click Shared "https://github.com/harryho/ng-crm/tree/master/src/app/shared"
    click Blog "https://github.com/harryho/ng-crm/tree/master/src/app/components/blog-card"
    click Monthly "https://github.com/harryho/ng-crm/tree/master/src/app/components/monthly-earnings"
    click ProductPerf "https://github.com/harryho/ng-crm/tree/master/src/app/components/product-performance"
    click Transactions "https://github.com/harryho/ng-crm/tree/master/src/app/components/recent-transactions"
    click Sales "https://github.com/harryho/ng-crm/tree/master/src/app/components/sales-overview"
    click Yearly "https://github.com/harryho/ng-crm/tree/master/src/app/components/yearly-breakup"
    click AuthService "https://github.com/harryho/ng-crm/blob/master/src/app/services/authentication.service.ts"
    click BackendService "https://github.com/harryho/ng-crm/blob/master/src/app/services/backend.service.ts"
    click CoreService "https://github.com/harryho/ng-crm/blob/master/src/app/services/core.service.ts"
    click NavService "https://github.com/harryho/ng-crm/blob/master/src/app/services/nav.service.ts"
    click AuthGuard "https://github.com/harryho/ng-crm/blob/master/src/app/auth.guard.service.ts"
    click CustGuard "https://github.com/harryho/ng-crm/blob/master/src/app/pages/customer/customer-guard.service.ts"
    click OrderGuard "https://github.com/harryho/ng-crm/blob/master/src/app/pages/order/order-guard.service.ts"
    click ProdGuard "https://github.com/harryho/ng-crm/blob/master/src/app/pages/product/product-guard.service.ts"
    click Models "https://github.com/harryho/ng-crm/tree/master/src/app/models"
    click Pipes "https://github.com/harryho/ng-crm/blob/master/src/app/pipe/filter.pipe.ts"
    click SCSS "https://github.com/harryho/ng-crm/tree/master/src/assets/scss"
    click GlobalStyles "https://github.com/harryho/ng-crm/blob/master/src/styles.scss"
    click Docker "https://github.com/harryho/ng-crm/tree/master/Dockerfile"
    click Nginx "https://github.com/harryho/ng-crm/blob/master/config/nginx.conf"
    click BuildTools "https://github.com/harryho/ng-crm/blob/master/angular.json"
    click BuildTools "https://github.com/harryho/ng-crm/blob/master/package.json"

    %% Styles
    classDef external fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef app fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef layout fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef module fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef shared fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef component fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef guard fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef model fill:#FFFACD,stroke:#333,stroke-width:2px;
    classDef pipe fill:#E0FFFF,stroke:#333,stroke-width:2px;
    classDef asset fill:#FAFAD2,stroke:#333,stroke-width:2px;
```
