# anishbhandarkar/angular-ngrx-crud architecture

> Architecture diagram of the GitHub repository anishbhandarkar/angular-ngrx-crud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anishbhandarkar/angular-ngrx-crud
- Repository: https://github.com/anishbhandarkar/angular-ngrx-crud

## Overview

##### What this project is (type + purpose)
This is a **client-only Angular SPA** demonstrating **CRUD for “courses” using NgRx Store**. Per README: **no backend, no NgRx Effects, no HTTP layer**. All data lives in the in-memory client state managed by NgRx.

- **Angular component tree + routing**
- **NgRx data flow loop**: Component → dispatch(Action) → Reducer → Store(state) → Selector → Component
- Optional UI library (Angular Material) only as a “UI dependency,” not a system component

##### File tree to architectural building blocks
From the tree, the core architecture is:

##### Runtime entry + composition
- `src/main.ts` — bootstraps Angular
- `src/index.html` — SPA host page
- `src/app/app.module.ts` — root module; place where Store is typically configured
- `src/app/app-routing.module.ts` — routes (navigation boundaries)
- `src/app/app.component.*` — shell/root layout component

##### Feature UI components (courses domain)
- `src/app/course/` — likely list / container component for courses
- `src/app/course-card/` — presentational component for a single course
- `src/app/course-edit/` — create/edit form component

##### NgRx Store (the “backend replacement” inside the client)
- `src/app/store/app.reducer.ts` — root reducer composition
- `src/app/store/index.ts` — re-exports / wiring
- `src/app/store/courses/`
- `course.model.ts` — course entity type
- `course.action.ts` — CRUD actions (Add/Update/Delete/etc.)
- `course.reducer.ts` — how actions mutate state
- `course.selector.ts` — read-model selectors for components

- `angular.json`, `package.json` — Angular CLI build + dependencies

##### User → Angular Components
- User clicks Add/Update/Delete, types in form fields, navigates routes.

##### Components → Store via Actions
- `CourseComponent` / `CourseEditComponent` **dispatch** actions from `course.action.ts`

##### Store → Reducers → New State
- The Store routes the action to `course.reducer.ts` (and via `app.reducer.ts` if composed)

##### Components ← Store via Selectors (observable streams)
- Components **select** data using `course.selector.ts`

##### Presentational vs container component flow
- `CourseComponent` passes course data down to `CourseCardComponent` via `@Input()`
- `CourseCardComponent` emits UI events up via `@Output()` (edit/delete)

##### Routing navigation
- `Router` sends user between list and edit views

##### Architectural patterns to highlight (specific to this codebase)

- **Unidirectional data flow** (NgRx)
- **State as a single source of truth** (client-only)
- **Feature slice** (`courses`) with:
- `actions` (commands)
- `reducers` (state transitions)
- `selectors` (queries)
- **Smart/container vs dumb/presentational split**
- CourseComponent (smart) vs CourseCardComponent (presentational) is a common learning goal

##### Checklist to ensure you captured “all essential architectural elements”
- `app.module.ts` as the composition point (wires Store + root components)
- routing boundary (`app-routing.module.ts`)
- all three course UI components (course/course-card/course-edit)
- the full NgRx path (actions + reducer + selectors + state + model)
- explicit “no effects / no backend” callout (otherwise reviewers will assume it’s incomplete)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Diagram 1: System / Container Context
  %% =========================
  subgraph "Diagram 1 — System Context (Client-only Angular SPA)"
    direction TB

    User["User"]:::actor
    Browser["Browser (SPA runtime)"]:::runtime

    subgraph "Angular SPA (built bundle runs in Browser)"
      direction TB
      Index["Host Page: index.html"]:::runtime
      Main["Bootstrap: main.ts"]:::runtime

      subgraph "App Composition"
        direction TB
        AppModule["Root Module: AppModule"]:::angular
        AppShell["App Shell: AppComponent"]:::angular
        Router["Angular Router"]:::angular
      end

      subgraph "State Management (in-memory)"
        direction TB
        Store["NgRx Store<AppState> (single source of truth)"]:::ngrx
      end
    end

    NoBackend["No Backend API\nNo HTTP Layer\nNo NgRx Effects\n(No DB)"]:::absent

    User -->|"uses"| Browser
    Browser -->|"loads"| Index
    Index -->|"bootstraps"| Main
    Main -->|"initializes"| AppModule
    AppModule -->|"renders"| AppShell
    AppModule -->|"configures"| Router
    AppModule -->|"provides"| Store

    Store -.->|"in-memory_only"| NoBackend
  end

  %% =========================
  %% Diagram 2: Component + NgRx CRUD Flow
  %% =========================
  subgraph "Diagram 2 — Component Tree + NgRx Unidirectional Data Flow (CRUD)"
    direction TB

    subgraph "Routing + Shell"
      direction TB
      Router2["Router (routes: list/edit)"]:::angular
      AppShell2["AppComponent (shell/layout)"]:::angular
    end

    subgraph "Courses Feature UI"
      direction TB
      CourseCmp["Container: CourseComponent (list/smart)"]:::angular
      CourseEditCmp["Form: CourseEditComponent (create/edit)"]:::angular
      CourseCardCmp["Presentational: CourseCardComponent (item)"]:::angular
    end

    subgraph "NgRx Store Layer"
      direction TB

      subgraph "Root Store Wiring"
        direction TB
        AppState["AppState (root state shape)"]:::ngrx
        AppReducer["app.reducer (root reducer composition)"]:::ngrx
        StoreIndex["store/index (barrel + exports)"]:::ngrx
        Store2["Store<AppState> (in-memory state)"]:::ngrx
      end

      subgraph "Courses Slice (feature state)"
        direction TB
        CourseModel["course.model (Course type)"]:::ngrx
        CourseState["course.state (CoursesState shape)"]:::ngrx
        CourseActions["course.action (CRUD Actions)"]:::ngrx
        CourseReducer["course.reducer (pure transitions)"]:::ngrx
        CourseSelectors["course.selector (Selectors)"]:::ngrx
      end
    end

    %% Navigation
    User2["User interactions\n(clicks, typing, navigation)"]:::actor
    User2 -->|"navigate"| Router2
    Router2 -->|"route_outlet"| AppShell2
    AppShell2 -->|"shows_list_view"| CourseCmp
    AppShell2 -->|"shows_edit_view"| CourseEditCmp

    %% Presentational vs container flow
    CourseCmp -->|"@Input(): course"| CourseCardCmp
    CourseCardCmp -->|"@Output(): edit/delete"| CourseCmp

    %% Dispatch loop (Components -> Actions -> Reducer -> Store -> State)
    CourseCmp -->|"dispatch(Add/Update/Delete)"| CourseActions
    CourseEditCmp -->|"dispatch(Save/Cancel)"| CourseActions

    CourseActions -->|"handled_by"| CourseReducer
    AppReducer -->|"composes"| CourseReducer

    CourseReducer -->|"immutable_update"| CourseState
    CourseState -->|"part_of"| AppState
    AppState -->|"held_in"| Store2

    %% Select loop (Store -> Selectors -> Components)
    Store2 -->|"select(state)"| CourseSelectors
    CourseSelectors -->|"allCourses$ / selectedCourse$"| CourseCmp
    CourseSelectors -->|"selectedCourse$"| CourseEditCmp

    %% Wiring / exports (clarifies composition point)
    StoreIndex -->|"exports"| AppState
    StoreIndex -->|"exports"| AppReducer
    StoreIndex -->|"exports"| CourseActions
    StoreIndex -->|"exports"| CourseSelectors
    StoreIndex -->|"used_by"| AppModule2["AppModule (Store setup)"]:::angular
    AppModule2 -->|"provides"| Store2
    AppModule2 -->|"configures_routes"| Router2

    %% Explicit absence callout
    Absent2["Intentionally absent:\nEffects / HttpClient / API / DB"]:::absent
    CourseActions -.->|"no_effects"| Absent2
    Store2 -.->|"no_persistence"| Absent2
  end

  %% =========================
  %% Click Events (paths only)
  %% =========================
  click Main "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/main.ts"
  click Index "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/index.html"

  click AppModule "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.module.ts"
  click AppModule2 "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.module.ts"
  click Router "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app-routing.module.ts"
  click Router2 "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app-routing.module.ts"

  click AppShell "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.component.ts"
  click AppShell2 "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.component.ts"

  click CourseCmp "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course/course.component.ts"
  click CourseCardCmp "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-card/course-card.component.ts"
  click CourseEditCmp "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-edit/course-edit.component.ts"

  click AppState "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/app.state.ts"
  click AppReducer "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/app.reducer.ts"
  click StoreIndex "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/index.ts"

  click CourseModel "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/courses/course.model.ts"
  click CourseState "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/courses/course.state.ts"
  click CourseActions "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/courses/course.action.ts"
  click CourseReducer "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/courses/course.reducer.ts"
  click CourseSelectors "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/store/courses/course.selector.ts"

  click CourseFolder "https://github.com/anishbhandarkar/angular-ngrx-crud/tree/main/courses-crud/src/app/store/courses/"

  %% Extra mapped templates/styles
  click AppShellTpl "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.component.html"
  click AppShellCss "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/app.component.css"
  click CourseTpl "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course/course.component.html"
  click CourseCss "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course/course.component.css"
  click CardTpl "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-card/course-card.component.html"
  click CardCss "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-card/course-card.component.css"
  click EditTpl "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-edit/course-edit.component.html"
  click EditCss "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/src/app/course-edit/course-edit.component.css"

  click AngularJson "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/angular.json"
  click PackageJson "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/package.json"
  click PackageLock "https://github.com/anishbhandarkar/angular-ngrx-crud/blob/main/courses-crud/package-lock.json"

  %% Hidden nodes for template/style click targets (not shown prominently)
  AppShellTpl["AppComponent Template"]:::hidden
  AppShellCss["AppComponent Styles"]:::hidden
  CourseTpl["CourseComponent Template"]:::hidden
  CourseCss["CourseComponent Styles"]:::hidden
  CardTpl["CourseCard Template"]:::hidden
  CardCss["CourseCard Styles"]:::hidden
  EditTpl["CourseEdit Template"]:::hidden
  EditCss["CourseEdit Styles"]:::hidden
  AngularJson["angular.json"]:::hidden
  PackageJson["package.json"]:::hidden
  PackageLock["package-lock.json"]:::hidden
  CourseFolder["store/courses/ (folder)"]:::hidden

  %% =========================
  %% Styles
  %% =========================
  classDef actor fill:#ffffff,stroke:#111827,stroke-width:1.5px,color:#111827
  classDef runtime fill:#f3f4f6,stroke:#6b7280,stroke-width:1.5px,color:#111827
  classDef angular fill:#dbeafe,stroke:#1d4ed8,stroke-width:1.5px,color:#0b1220
  classDef ngrx fill:#ede9fe,stroke:#6d28d9,stroke-width:1.5px,color:#0b1220
  classDef absent fill:#fee2e2,stroke:#b91c1c,stroke-width:1.5px,color:#7f1d1d,stroke-dasharray: 6 4
  classDef hidden fill:#ffffff,stroke:#e5e7eb,stroke-width:1px,color:#9ca3af,opacity:0.0

  %% keep hidden nodes out of layout by not connecting them
```
