# truongthuyquangnhat/angular-erm architecture

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

- Interactive diagram: https://gitdiagram.com/truongthuyquangnhat/angular-erm
- Repository: https://github.com/truongthuyquangnhat/angular-erm

## Overview

##### Project type and purpose
- This is a frontend-only Single Page Application (SPA) built with Angular (v15), named “AngularERM”.
- Purpose: Manage “nhân viên” (employees)—display lists, pagination, CRUD via dialogs, using models, services, and routing.

##### File structure
- Top-level Angular CLI files: angular.json, package.json, tsconfig*.json.
- src/app: the root AppModule (app.module.ts), AppComponent, and AppRoutingModule.
- src/app/models: TypeScript model definitions (ChucDanhModel, ChucVuModel, PhongBanModel, TempModel).
- src/app/nhanvien: feature folder containing NhanVienComponent, a NhanVienModule, NhanVienService, and its interface.
- src/app/nhanvien/pagenhanvien: a nested feature module for pagination (PagenhanvienComponent, service, module).
- src/assets: static assets folder.
- No backend code present; services likely call an external REST API.

##### README
- Confirms Angular CLI scaffolding.
- No backend details—implies services target external endpoints.
- Standard build, serve, test commands.

##### Main components & interactions
a. Components/Modules
- Browser/Client
- AppModule
– AppComponent (root view)
– AppRoutingModule (defines routes to feature modules)
- NhanVienModule
– NhanVienComponent (CRUD UI + delete dialog)
– NhanVienService (HTTP calls for employees)
- PagenhanvienModule
– PagenhanvienComponent (pagination UI)
– PagenhanvienService (HTTP calls for paged data)
- Models (data contracts for HTTP payloads)
- Assets & Styles
b. External Services
- REST API server (external), serving employee data endpoints
c. Data flow
– User interacts with Component → calls corresponding Service → Service issues HTTP to API → API responds → Service returns Observable<Model> → Component renders data.
d. Architectural patterns
- Feature modules (NgModule) for separation of concerns
- Service-based data access (Dependency Injection)
- Router lazy-loading (if configured)
- Model classes as interfaces for strong typing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser/Client
    Browser["Browser/Client"]:::external
    click Browser "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/index.html"
    
    %% App Module
    subgraph "AppModule" 
        direction TB
        AppComponent(("AppComponent")):::component
        click AppComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/app.component.ts"
        click AppComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/app.component.html"
        click AppComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/app.component.css"
        
        AppRoutingModule["AppRoutingModule"]:::service
        click AppRoutingModule "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/app-routing.module.ts"
    end
    click AppModule "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/app.module.ts"
    AppModule["AppModule"]:::module
    
    Browser -->|loads| AppModule
    AppModule -->|declares & boots| AppComponent
    AppModule -->|imports| AppRoutingModule
    
    %% NhanVien Feature
    subgraph "NhanVienModule" 
        direction TB
        NhanVienComponent(("NhanVienComponent")):::component
        click NhanVienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.component.ts"
        click NhanVienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.component.html"
        click NhanVienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.component.css"
        click NhanVienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/dialog-delete.html"
        
        NhanVienService[(NhanVienService)]:::service
        click NhanVienService "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.service.ts"
        
        NhanVienInterface[/NhanVien Interface/]:::model
        click NhanVienInterface "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.interface.ts"
    end
    click NhanVienModule "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/nhanvien.module.ts"
    AppRoutingModule -->|"loadChildren"| NhanVienModule
    AppComponent -->|uses| NhanVienComponent
    NhanVienComponent -->|injects| NhanVienService
    NhanVienService -->|uses Model| NhanVienInterface
    
    %% Pagination Feature
    subgraph "PagenhanvienModule"
        direction TB
        PagenhanvienComponent(("PagenhanvienComponent")):::component
        click PagenhanvienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/pagenhanvien/pagenhanvien.component.ts"
        click PagenhanvienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/pagenhanvien/pagenhanvien.component.html"
        click PagenhanvienComponent "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/pagenhanvien/pagenhanvien.component.css"
        
        PagenhanvienService[(PagenhanvienService)]:::service
        click PagenhanvienService "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/pagenhanvien/pagenhanvien.service.ts"
    end
    click PagenhanvienModule "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/nhanvien/pagenhanvien/pagenhanvien.module.ts"
    AppRoutingModule -->|"loadChildren"| PagenhanvienModule
    AppComponent -->|uses| PagenhanvienComponent
    PagenhanvienComponent -->|injects| PagenhanvienService
    
    %% Models
    subgraph "Models" 
        direction TB
        ChucDanhModel[/ChucDanhModel/]:::model
        click ChucDanhModel "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/models/ChucDanhModel.ts"
        
        ChucVuModel[/ChucVuModel/]:::model
        click ChucVuModel "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/models/ChucVuModel.ts"
        
        PhongBanModel[/PhongBanModel/]:::model
        click PhongBanModel "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/models/PhongBanModel.ts"
        
        TempModel[/TempModel/]:::model
        click TempModel "https://github.com/truongthuyquangnhat/angular-erm/blob/main/src/app/models/TempModel.ts"
    end
    NhanVienService -->|uses| ChucDanhModel
    NhanVienService -->|uses| ChucVuModel
    NhanVienService -->|uses| PhongBanModel
    PagenhanvienService -->|uses| TempModel
    
    %% External API
    API[(External REST API)]:::external
    NhanVienService -->|HTTP| API
    PagenhanvienService -->|HTTP| API
    API -->|response| NhanVienService
    API -->|response| PagenhanvienService
    
    %% Assets
    Assets["Assets & Static Files"]:::external
    click Assets "https://github.com/truongthuyquangnhat/angular-erm/tree/main/src/assets/"
    AppComponent -->|loads| Assets

    %% Legend
    subgraph "Legend"
        direction LR
        L1["Module"]:::module
        L2(("Component")):::component
        L3[(Service)]:::service
        L4[/Model/]:::model
        L5(("DB")):::external
    end

    classDef module fill:#ade8f4,stroke:#0288d1;
    classDef component fill:#b2f7ef,stroke:#2e7d32;
    classDef service fill:#fff3bf,stroke:#f9a825;
    classDef model fill:#ffc9de,stroke:#ad1457;
    classDef external fill:#e0e0e0,stroke:#616161;
```
