# anmolsukki/rex-crm architecture

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

- Interactive diagram: https://gitdiagram.com/anmolsukki/rex-crm
- Repository: https://github.com/anmolsukki/rex-crm

## Overview

##### Project Type & Purpose
– This is a front-end React single-page application (SPA) focused on Role Management. It doesn’t include its own backend code; instead it consumes external RESTful APIs for authentication and data (departments, HR candidacy, performance, sales, time logs, user profiles).
– State management is handled via Redux. Styling and assets live under public and src/assets. Routing and private-route guards enforce role-based access.

##### Main Components
A. Browser / Client
- Hosts the compiled bundle and service worker (PWA).
B. Presentation Layer (React)
- src/App.js, src/views/**, src/UserRoles/**, src/containers/**
- nav.js, userRoutes.js, routes.js define routing and role-based routes.
C. State Management (Redux)
- Actions: src/Redux/Actions/** (CalculationAction, LoginAction, etc.)
- Reducers: src/Redux/Reducers/**
- Store: src/Redux/Store/store.js
- ActionConstants & ActionTypes hold constants/enums.
D. API Layer
- src/Config/APIurl/connection.js defines base URLs and axios/fetch wrappers.
- AuthHeader.js injects JWT or tokens into every request.
E. Static Assets & Themes
- public/themes (CSS, JS, fonts, images)
- src/assets (CSS modules, SCSS, images)
F. Service Worker
- src/serviceWorker.js for PWA offline caching.

##### Component Relationships & Data Flow
– User interacts with React components → dispatches Redux Action
– Action creator calls API via connection.js, attaching AuthHeader
– External REST API responds → action dispatches SUCCESS/FAILURE
– Reducers update Redux Store → connected React components re-render
– Service worker caches assets/responses for offline use

##### Key Architectural Patterns
– Flux/Redux for unidirectional data flow
– Container/Presentational split (DefaultLayout container vs. view components)
– Role-based routing (PrivateRoute, userRoutes.js)
– Theming via static assets under public/themes
– Progressive Web App (service worker integration)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser/Client
    subgraph "Browser/Client"
        BC_Public["public\n(index.html, manifest.json, robots.txt)"]:::ui
        BC_Index["src/index.js\n(Entry Point)"]:::ui
        BC_ServiceWorker["src/serviceWorker.js\n(PWA Caching)"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer (React)" 
        PL_App["src/App.js\n(React Entry)"]:::ui
        PL_Views["src/views/**\n(View Components)"]:::ui
        PL_UserRoles["src/UserRoles/**\n(Role Components)"]:::ui
        subgraph "Containers"
            PL_DefaultLayout["src/containers/DefaultLayout/**\n(Layout Container)"]:::ui
            PL_PrivateRoute["src/containers/PrivateRoute.js\n(Role Guard)"]:::ui
        end
        PL_Nav["src/nav.js\n(Navigation)"]:::ui
        PL_UserRoutes["src/userRoutes.js\n(Role Routes)"]:::ui
        PL_Routes["src/routes.js\n(App Routes)"]:::ui
    end

    %% State Management (Redux)
    subgraph "State Management (Redux)"
        subgraph Actions
            SM_Actions["src/Redux/Actions/**\n(CalculationAction, LoginAction, etc.)"]:::redux
            SM_ActionConstants["src/Redux/Actions/ActionConstant/ActionConstants.js"]:::redux
            SM_ActionTypes["src/Redux/Actions/ActionTypes/ActionTypes.js"]:::redux
        end
        subgraph Reducers
            SM_Reducers["src/Redux/Reducers/**\n(CalculationReducer, LoginReducer, etc.)"]:::redux
        end
        SM_Store["src/Redux/Store/store.js\n(Redux Store)"]:::redux
    end

    %% API Layer
    subgraph "API Layer"
        API_Connection["src/Config/APIurl/connection.js\n(Axios Wrapper)"]:::api
        API_AuthHeader["src/Redux/Actions/Header/AuthHeader.js\n(JWT Injection)"]:::api
    end

    %% Static Assets & Themes
    subgraph "Static Assets & Themes"
        AS_PublicThemes["public/themes/**\n(CSS, JS, Fonts, Images)"]:::assets
        AS_CSS["src/assets/css/**\n(CSS Modules, SCSS)"]:::assets
        AS_Images["src/assets/img/**\n(Images)"]:::assets
    end

    %% External Services
    subgraph "External Services"
        ES_AuthAPI["Auth API"]:::external
        ES_DataAPI["Data APIs\n(Departments, HR, Performance,\nSales, Time Logs, Profiles)"]:::external
    end

    %% Data Flow
    BC_Index -->|"loads bundle"| PL_App
    BC_ServiceWorker -->|"caches assets"| AS_PublicThemes
    PL_App -->|"renders Routes"| PL_Routes
    PL_Routes -->|"guards via"| PL_PrivateRoute
    PL_PrivateRoute -->|"uses roles from"| PL_UserRoles
    PL_Routes -->|"navigates to"| PL_Views
    PL_App -->|"dispatches"| SM_Actions
    SM_Actions -->|"calls"| API_Connection
    API_Connection -->|"attaches token via"| API_AuthHeader
    API_Connection -->|"requests"| ES_AuthAPI
    API_Connection -->|"requests"| ES_DataAPI
    ES_AuthAPI -->|"response"| API_Connection
    ES_DataAPI -->|"response"| API_Connection
    API_AuthHeader -->|"provides header"| API_Connection
    API_Connection -->|"dispatches success/failure"| SM_Reducers
    SM_Reducers -->|"updates"| SM_Store
    SM_Store -->|"provides state"| PL_Views
    SM_Store -->|"provides state"| PL_UserRoles

    %% Click Events - Browser/Client
    click BC_Public "https://github.com/anmolsukki/rex-crm/tree/master/public"
    click BC_Index "https://github.com/anmolsukki/rex-crm/blob/master/src/index.js"
    click BC_ServiceWorker "https://github.com/anmolsukki/rex-crm/blob/master/src/serviceWorker.js"

    %% Click Events - Presentation
    click PL_App "https://github.com/anmolsukki/rex-crm/blob/master/src/App.js"
    click PL_Views "https://github.com/anmolsukki/rex-crm/tree/master/src/views"
    click PL_UserRoles "https://github.com/anmolsukki/rex-crm/tree/master/src/UserRoles"
    click PL_DefaultLayout "https://github.com/anmolsukki/rex-crm/tree/master/src/containers/DefaultLayout"
    click PL_PrivateRoute "https://github.com/anmolsukki/rex-crm/blob/master/src/containers/PrivateRoute.js"
    click PL_Nav "https://github.com/anmolsukki/rex-crm/blob/master/src/nav.js"
    click PL_UserRoutes "https://github.com/anmolsukki/rex-crm/blob/master/src/userRoutes.js"
    click PL_Routes "https://github.com/anmolsukki/rex-crm/blob/master/src/routes.js"

    %% Click Events - State Management
    click SM_Actions "https://github.com/anmolsukki/rex-crm/tree/master/src/Redux/Actions"
    click SM_ActionConstants "https://github.com/anmolsukki/rex-crm/blob/master/src/Redux/Actions/ActionConstant/ActionConstants.js"
    click SM_ActionTypes "https://github.com/anmolsukki/rex-crm/blob/master/src/Redux/Actions/ActionTypes/ActionTypes.js"
    click SM_Reducers "https://github.com/anmolsukki/rex-crm/tree/master/src/Redux/Reducers"
    click SM_Store "https://github.com/anmolsukki/rex-crm/blob/master/src/Redux/Store/store.js"

    %% Click Events - API Layer
    click API_Connection "https://github.com/anmolsukki/rex-crm/blob/master/src/Config/APIurl/connection.js"
    click API_AuthHeader "https://github.com/anmolsukki/rex-crm/blob/master/src/Redux/Actions/Header/AuthHeader.js"

    %% Click Events - Static Assets
    click AS_PublicThemes "https://github.com/anmolsukki/rex-crm/tree/master/public/themes"
    click AS_CSS "https://github.com/anmolsukki/rex-crm/tree/master/src/assets/css"
    click AS_Images "https://github.com/anmolsukki/rex-crm/tree/master/src/assets/img"

    %% Styles
    classDef ui fill:#DCEBF7,stroke:#0366d6,color:#000;
    classDef redux fill:#E2F0D9,stroke:#2E7D32,color:#000;
    classDef api fill:#FFEBCC,stroke:#FF8C00,color:#000;
    classDef external fill:#E0E0E0,stroke:#616161,color:#000;
    classDef assets fill:#FFF4CC,stroke:#FFCC00,color:#000;
```
