# codewithpawangit/ngrx-emp-crud-project architecture

> Architecture diagram of the GitHub repository codewithpawangit/ngrx-emp-crud-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewithpawangit/ngrx-emp-crud-project
- Repository: https://github.com/codewithpawangit/ngrx-emp-crud-project

## Overview

##### Project type and purpose
- This is a single-page Angular application with NgRx for state management, demonstrating CRUD operations on employee records.
- It relies on a JSON Server (db.json) as a mock REST API backend.

##### File structure
- Top-level files: angular.json, package.json, db.json (mock API data), README.md
- src/app/
- app.module.ts & app-routing.module.ts
- employee/ – feature module containing Add, Edit, Home components, its own routing, service, and NgRx store files (actions, reducers, effects, selectors)
- shared/store/ – global app-level store (app.action.ts, app.reducer.ts, app.selector.ts, appstate.ts)
- src/environments – environment configs
- tests & specs alongside their components

##### README for insights
- The README confirms use of json-server (`db.json`) as the mock API.
- Angular CLI (`ng serve`) to launch the front end.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AddComp["AddComponent"]:::frontend
        EditComp["EditComponent"]:::frontend
        HomeComp["HomeComponent"]:::frontend
    end

    %% Angular Core Modules
    subgraph "Angular Core"
        direction TB
        AppMod["AppModule"]:::core
        AppRouting["AppRoutingModule"]:::core
        EmpMod["EmployeeModule"]:::core
        EmpRouting["EmployeeRoutingModule"]:::core
    end

    %% Feature State Management
    subgraph "Employee Feature State (NgRx)"
        direction TB
        EmpActions["Employee Actions"]:::state
        EmpEffects["Employee Effects"]:::effect
        EmpReducer["Employee Reducer"]:::state
        EmpSelectors["Employee Selectors"]:::state
        EmpModel["Employee Store Model"]:::state
    end

    %% Global App Store
    subgraph "Global App Store"
        direction TB
        AppActions["Global App Actions"]:::state
        AppReducer["Global App Reducer"]:::state
        AppSelectors["Global App Selectors"]:::state
        AppState["AppState Interface"]:::state
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        EmpService["EmployeeService"]:::service
    end

    %% Mock Backend
    subgraph "Mock Backend"
        direction TB
        JSONDB["JSON Server (db.json)"]:::backend
    end

    %% Data Flow
    AddComp -->|"dispatch AddEmployee"| EmpActions
    EditComp -->|"dispatch EditEmployee"| EmpActions
    HomeComp -->|"dispatch LoadEmployees"| EmpActions

    EmpActions -->|"trigger"| EmpEffects
    EmpEffects -->|"call HTTP"| EmpService
    EmpService -->|"HTTP request"| JSONDB
    JSONDB -->|"response JSON"| EmpEffects
    EmpEffects -->|"dispatch Success/Failure"| EmpReducer
    EmpReducer -->|"update"| EmpModel
    EmpModel -->|"state"| EmpSelectors
    EmpSelectors -->|"select data"| HomeComp
    EmpSelectors -->|"select data"| AddComp
    EmpSelectors -->|"select data"| EditComp

    %% Module Connections
    AppMod --> EmpMod
    AppMod --> AppRouting
    EmpMod --> EmpRouting

    %% Click Events
    click AddComp "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/add/add.component.ts"
    click EditComp "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/edit/edit.component.ts"
    click HomeComp "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/home/home.component.ts"
    click AppMod "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/app.module.ts"
    click AppRouting "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/app-routing.module.ts"
    click EmpMod "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/employee.module.ts"
    click EmpRouting "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/employee-routing.module.ts"
    click EmpService "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/employee.service.ts"
    click EmpActions "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/store/employee.action.ts"
    click EmpReducer "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/store/employee.reducer.ts"
    click EmpEffects "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/store/employee.effect.ts"
    click EmpSelectors "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/store/employee.selector.ts"
    click EmpModel "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/employee/store/employee.ts"
    click AppActions "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/shared/store/app.action.ts"
    click AppReducer "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/shared/store/app.reducer.ts"
    click AppSelectors "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/shared/store/app.selector.ts"
    click AppState "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/src/app/shared/store/appstate.ts"
    click JSONDB "https://github.com/codewithpawangit/ngrx-emp-crud-project/blob/main/db.json"

    %% Styling
    classDef frontend fill:#D6E9FE,stroke:#4A90E2,stroke-width:1px
    classDef core fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
    classDef state fill:#FFF3CD,stroke:#FFEE58,stroke-width:1px
    classDef effect fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
    classDef service fill:#C8E6C9,stroke:#43A047,stroke-width:1px
    classDef backend fill:#E0E0E0,stroke:#9E9E9E,stroke-width:1px
```
