# bobert13gomez/cybersecurity_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/bobert13gomez/cybersecurity_frontend
- Repository: https://github.com/bobert13gomez/cybersecurity_frontend

## Overview

##### Project Type and Purpose
- This is a React-based frontend application for cybersecurity user management.
- It handles user CRUD operations, permission control, protected routing, and activity logging.
- It communicates with a backend API via Axios interceptors.

##### File Structure
- Top-level:
- public/index.html – host page
- src/main.jsx – React entry point
- src/App.jsx – root component
- src/routes/route.jsx – React Router setup
- src/components – shared UI components (Layout, Loader, LoginPage)
- src/Pages – page-level components (Dashboard, Staffmanagement)
- src/Interceptor/axios.jsx – configured Axios instance with interceptors
- src/services – API service modules (StaffServices, loginServices)
- src/reduxStore – Redux Toolkit store and permissionSlice
- src/utils – helper components (ProtectedRoute, Unauthorized, ActivityLogs)

##### README for Additional Insights
- Uses Redux Toolkit for global state (permissionSlice)
- Uses React Router DOM for protected routes
- Axios interceptors handle tokens and error workflows
- Services encapsulate all API calls: user, permissions, activities

##### Main Components & Relationships
a. Client Layer
- Browser loads public/index.html → main.jsx
- React App (App.jsx) orchestrates routing and layout
b. UI Layer
- Pages (Dashboard, Staffmanagement, LoginPage)
- Shared Components (Layout, Loader)
c. Routing Layer
- route.jsx defines routes, wraps pages with ProtectedRoute
- Unauthorized page for access denied
d. State Management
- Redux store (store.js)
- permissionSlice manages permission state
e. API Layer
- Axios interceptor (axios.jsx) adds tokens, handles errors
- Services modules call HTTP endpoints
f. External Backend API
- Endpoints for /user, /user/activity, /user/individualPermission

##### Architectural Patterns & Design Principles
- Component-based UI (React)
- Unidirectional data flow (Redux state)
- Separation of concerns: UI ↔ Routing ↔ State ↔ Services
- Interceptor pattern for cross-cutting concerns in HTTP
- Protected routes for access control

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser"]:::external
        Main["main.jsx"]:::client
        AppComp["App.jsx"]:::client
    end

    Browser -->|"loads index.html"| Main
    click Browser "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/public/index.html"
    Main -->|"renders App"| AppComp
    click Main "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/main.jsx"
    click AppComp "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/App.jsx"

    %% Routing Layer
    subgraph "Routing Layer"
        Routes["route.jsx"]:::routing
        Protected["ProtectedRoute.jsx"]:::routing
        Unauthorized["Unauthorized.jsx"]:::routing
    end

    AppComp -->|"uses Router"| Routes
    click Routes "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/routes/route.jsx"
    Routes -->|"wraps protected pages"| Protected
    click Protected "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/utils/ProtectedRoute.jsx"
    Protected -.->|"on denial"| Unauthorized
    click Unauthorized "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/utils/Unauthorized.jsx"

    %% UI Layer
    subgraph "UI Layer"
        subgraph "Pages" 
            Dashboard["Dashboard.jsx"]:::ui
            StaffMgmt["Staffmanagement.jsx"]:::ui
            LoginPg["LoginPage.jsx"]:::ui
        end
        subgraph "Shared Components"
            Layout["Layout.jsx"]:::ui
            Loader["Loader.jsx"]:::ui
        end
    end

    Protected -->|"renders"| Dashboard
    Protected -->|"renders"| StaffMgmt
    Routes -->|"renders"| LoginPg
    click Dashboard "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/Pages/Dashboard.jsx"
    click StaffMgmt "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/Pages/Staffmanagement.jsx"
    click LoginPg "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/components/LoginPage.jsx"
    Dashboard --> Layout
    StaffMgmt --> Layout
    LoginPg --> Layout
    Dashboard --> Loader
    StaffMgmt --> Loader

    %% State Management
    subgraph "State Management"
        Store["store.js"]:::state
        PermSlice["permissionSlice.js"]:::state
    end

    click Store "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/reduxStore/store.js"
    click PermSlice "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/reduxStore/permissionSlice.js"
    Dashboard -->|"dispatch(setPermission)"| Store
    StaffMgmt -->|"dispatch(setPermission)"| Store
    Store --> PermSlice
    PermSlice -->|"provides state"| Dashboard
    PermSlice -->|"provides state"| StaffMgmt

    %% API Layer
    subgraph "API Layer"
        AxiosInt["axios.jsx"]:::service
        StaffSvc["StaffServices.jsx"]:::service
        LoginSvc["loginServices.jsx"]:::service
        ActLogUtil["ActivityLogs.jsx"]:::service
    end

    click AxiosInt "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/Interceptor/axios.jsx"
    click StaffSvc "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/servives/StaffServices.jsx"
    click LoginSvc "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/servives/loginServices.jsx"
    click ActLogUtil "https://github.com/bobert13gomez/cybersecurity_frontend/blob/main/src/utils/ActivityLogs.jsx"

    Dashboard -->|"calls log activity"| ActLogUtil
    StaffMgmt -->|"calls log activity"| ActLogUtil
    LoginPg -->|"calls login API"| LoginSvc
    Dashboard -->|"calls user API"| StaffSvc
    StaffMgmt -->|"calls user API"| StaffSvc
    ActLogUtil --> StaffSvc
    ActLogUtil --> LoginSvc
    StaffSvc --> AxiosInt
    LoginSvc --> AxiosInt
    AxiosInt -->|"HTTP requests"| ExternalAPI

    %% External API
    subgraph "External Backend API"
        ExternalAPI["Backend API"]:::external
    end

    %% Legend / Styles
    classDef client fill:#D6E9FF,stroke:#4D9AFF,color:#000;
    classDef routing fill:#DFFFE0,stroke:#3FCF00,color:#000;
    classDef ui fill:#E0F7FF,stroke:#00AACC,color:#000;
    classDef state fill:#FFF9C4,stroke:#FFEB3B,color:#000;
    classDef service fill:#FFD8A8,stroke:#FF9800,color:#000;
    classDef external fill:#E0E0E0,stroke:#9E9E9E,color:#000;
```
