# scvapp/scvappfrontend architecture

> Architecture diagram of the GitHub repository scvapp/scvappfrontend, 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/scvapp/scvappfrontend
- Repository: https://github.com/scvapp/scvappfrontend

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) built with Create React App.
- It uses React Router for client-side routing and Redux Toolkit for state management.
- It provides user-facing pages (login, meals, schedule, settings, about), plus an admin panel (door-passes, schedule editing, logs).
- It calls out to external REST APIs (e.g. adminDoorPassAPI, settingsAPI, meals Web API, user data API) and integrates with Microsoft authentication for login.

##### File structure
- “src/index.js” bootstraps the React app and Redux store at “src/app/store/store.js.”
- “src/Route” defines route wrappers (LoginRoute, MealsRoute, AdminRoute, etc.) that enforce authentication or feature flags.
- “src/app/store” holds the Redux slices under “src/features” (alert, apps, doorPasses, mealUser, sideMenu, theme, user, etc.).
- “src/pages” holds page-level containers grouped by feature: homePage, loginPage, mealsPage, settingsPage, aboutPage, adminPanel (with nested components and utilities like adminDoorPassAPI.js), etc.
- Utilities and hooks (useDoorPasses, useAlert, useSideMenu, userHook) encapsulate side-effect logic and API calls.

##### README
- No custom architecture docs—just default CRA scripts.
- We infer front-end only; back end is external.

a. Main components (group into four layers):
1) Client-side Browser / PWA Shell
- index.html + service worker + manifest (public/)
2) Presentation Layer (React)
- React Router (src/Route)
- Page containers (src/pages)
- Presentational components (src/components & nested admin/components, meals/components, settings/components)
3) State & Logic Layer
- Redux store (src/app/store)
- Feature slices (src/features)
- Custom hooks (useDoorPasses, userHook, themeHook)
4) Data / API Layer
- REST calls: adminDoorPassAPI, settingsAPI, getMealUser, userGetData
- External Auth (Microsoft OAuth)
- Backend services: Authentication Service, eAsistent API, Meals API, Logging Service
b. Relationships & interactions
- Router renders the appropriate Page container → inside it, Presentation components dispatch actions to Redux.
- Redux middleware / thunks call REST APIs → update feature slices → store changes propagate back to components.
- Components subscribe to store via useSelector or hooks.
- Admin pages call adminDoorPassAPI for CRUD door-pass operations.
- Theme selection persists (e.g. localStorage) via themeSlice.
- SideMenu logic (useSideMenu) toggles navigation panels based on user permissions.
c. Architectural patterns & principles
- Layered separation (Presentation, State, Data)
- Container vs. Presentational components
- Redux Toolkit: slice pattern, centralized store
- React Router guards (Route wrappers) for auth and feature gating
d. Key technologies & libraries
- React, React DOM, React Router v6
- Redux Toolkit, React-Redux hooks
- CSS modules / plain CSS for styling
- CRA build toolchain (Webpack, Babel)
- PWA features via manifest.json, service worker (default CRA)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Browser / PWA Shell Layer
    subgraph "Browser / PWA Shell"
        direction TB
        PWA_HTML["index.html"]:::ui
        PWA_Manifest["manifest.json"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer (React)" 
        direction TB

        subgraph "Router & Guards"
            direction TB
            Router["Route.js"]:::ui
            LoginGuard["LoginRoute.js"]:::ui
            MealsGuard["MealsRoute.js"]:::ui
            AdminGuard["AdminRoute.js"]:::ui
            AdminDoorPassGuard["AdminDoorPassRoute.js"]:::ui
        end

        subgraph "Page Containers"
            direction TB

            subgraph "Public Pages"
                direction TB
                LoginPage["loginPage.js"]:::ui
                HomePage["homePage.jsx"]:::ui
                MealsPage["mealsMain.jsx"]:::ui
                SettingsPage["settingsPage.jsx"]:::ui
                AboutPage["aboutPage.jsx"]:::ui
                NotFoundPage["404page.js"]:::ui
            end

            subgraph "Admin Panel"
                direction TB
                AdminDashboard["adminDashboard.jsx"]:::ui
                AdminScheduleEdit["adminScheduleEdit.jsx"]:::ui
                subgraph "Door-Pass CRUD"
                    direction TB
                    AdminDoorPassAPI["adminDoorPassAPI.js"]:::api
                    DoorPassCreate["create.jsx"]:::ui
                    DoorPassDashboard["dashboard.jsx"]:::ui
                    DoorPassShow["show.jsx"]:::ui
                end
                AdminComponents["components/…"]:::ui
            end
        end

        subgraph "Presentational Components"
            direction TB
            ProfileImg["profileImg.jsx"]:::ui
            SideMenuComp["sideMenu.jsx"]:::ui
            ScheduleItem["scheduleItem.jsx"]:::ui
            StatusIcon["StatusIcon.jsx"]:::ui
            StyledTextField["StyledTextField.jsx"]:::ui
        end
    end

    %% State & Logic Layer
    subgraph "State & Logic Layer"
        direction TB
        Store["store.js"]:::state

        subgraph "Feature Slices"
            direction TB
            AlertSlice["useAlert.js"]:::state
            AppsSlice["appsSlice.js"]:::state
            DoorPassesSlice["doorPassesSlice.js"]:::state
            MealUserSlice["mealUserSlice.js"]:::state
            SideMenuSlice["sideMenuSlice.js"]:::state
            ThemeSlice["themeSlice.js"]:::state
            UserSlice["userSlice.js"]:::state
        end

        subgraph "Custom Hooks & Thunks"
            direction TB
            GetMealUser["getMealUser.js"]:::api
            UserGetData["userGetData.js"]:::api
            UseDoorPasses["useDoorPasses.js"]:::state
            UseSideMenu["useSideMenu.js"]:::state
            UserHook["userHook.js"]:::state
            ThemeHook["themeHook.js"]:::state
            WindowDim["useWindowDimensions.js"]:::state
        end
    end

    %% Data / API Layer
    subgraph "Data / API Layer"
        direction TB
        AdminDoorPassAPI_Module["adminDoorPassAPI.js"]:::api
        SettingsAPI["settingsAPI.js"]:::api
        MealsAPI["Meals API"]:::ext
        UserAPI["User Data API"]:::ext
        AuthAPI["Microsoft OAuth"]:::ext
        AuthService["Authentication Service"]:::ext
        LoggingService["Logging Service"]:::ext
        EAsistentAPI["eAsistent API"]:::ext
    end

    %% Connections
    PWA_HTML -->|"loads"| Router
    PWA_Manifest -->|"provides PWA"| Router

    Router -->|"/login"| LoginGuard
    Router -->|"/meals"| MealsGuard
    Router -->|"/admin"| AdminGuard
    AdminGuard -->|"/doorpasses"| AdminDoorPassGuard

    LoginGuard --> LoginPage
    MealsGuard --> MealsPage
    Router --> HomePage
    Router --> SettingsPage
    Router --> AboutPage
    Router --> NotFoundPage

    AdminDoorPassGuard --> AdminDashboard
    AdminDoorPassGuard --> AdminScheduleEdit
    AdminDoorPassGuard --> AdminDoorPassAPI

    AdminDoorPassAPI --> DoorPassCreate
    AdminDoorPassAPI --> DoorPassDashboard
    AdminDoorPassAPI --> DoorPassShow

    %% Component interactions
    LoginPage -->|"dispatch action"| Store
    HomePage --> Store
    MealsPage --> Store
    SettingsPage --> Store
    AboutPage --> Store
    AdminDashboard --> Store
    AdminScheduleEdit --> Store
    DoorPassDashboard --> Store

    Store -->|"state slice update"| AlertSlice
    Store --> AppsSlice
    Store --> DoorPassesSlice
    Store --> MealUserSlice
    Store --> SideMenuSlice
    Store --> ThemeSlice
    Store --> UserSlice

    Store -->|"subscribe"| ProfileImg
    Store --> SideMenuComp
    Store --> ScheduleItem
    Store --> StatusIcon
    Store --> StyledTextField

    %% Hooks & API calls
    UseDoorPasses --> AdminDoorPassAPI_Module
    GetMealUser --> MealsAPI
    UserGetData --> UserAPI
    SettingsPage --> SettingsAPI
    ThemeHook --> ThemeSlice
    UserHook --> AuthAPI
    UseSideMenu --> SideMenuSlice
    WindowDim -.-> StyledTextField

    AdminDoorPassAPI_Module --> LoggingService
    SettingsAPI --> EAsistentAPI

    %% Styles and classes
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#D6FFD0,stroke:#228B22,color:#228B22
    classDef api fill:#FFE1B3,stroke:#FF8C00,color:#FF8C00
    classDef ext fill:#E0E0E0,stroke:#808080,color:#555555

    %% Click Events
    click PWA_HTML "https://github.com/scvapp/scvappfrontend/blob/master/public/index.html"
    click PWA_Manifest "https://github.com/scvapp/scvappfrontend/blob/master/public/manifest.json"
    click Router "https://github.com/scvapp/scvappfrontend/blob/master/src/Route/Route.js"
    click LoginGuard "https://github.com/scvapp/scvappfrontend/blob/master/src/Route/LoginRoute.js"
    click MealsGuard "https://github.com/scvapp/scvappfrontend/blob/master/src/Route/MealsRoute.js"
    click AdminGuard "https://github.com/scvapp/scvappfrontend/blob/master/src/Route/admin/AdminRoute.js"
    click AdminDoorPassGuard "https://github.com/scvapp/scvappfrontend/blob/master/src/Route/admin/AdminDoorPassRoute.js"
    click Store "https://github.com/scvapp/scvappfrontend/blob/master/src/app/store/store.js"
    click AlertSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/alert/useAlert.js"
    click AppsSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/apps/appsSlice.js"
    click DoorPassesSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/doorPasses/doorPassesSlice.js"
    click MealUserSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/mealUser/mealUserSlice.js"
    click SideMenuSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/sideMenu/sideMenuSlice.js"
    click ThemeSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/theme/themeSlice.js"
    click UserSlice "https://github.com/scvapp/scvappfrontend/blob/master/src/features/user/userSlice.js"
    click GetMealUser "https://github.com/scvapp/scvappfrontend/blob/master/src/features/mealUser/getMealUser.js"
    click UserGetData "https://github.com/scvapp/scvappfrontend/blob/master/src/features/user/userGetData.js"
    click UseDoorPasses "https://github.com/scvapp/scvappfrontend/blob/master/src/features/doorPasses/useDoorPasses.js"
    click UseSideMenu "https://github.com/scvapp/scvappfrontend/blob/master/src/features/sideMenu/useSideMenu.js"
    click UserHook "https://github.com/scvapp/scvappfrontend/blob/master/src/features/user/userHook.js"
    click ThemeHook "https://github.com/scvapp/scvappfrontend/blob/master/src/features/theme/themeHook.js"
    click WindowDim "https://github.com/scvapp/scvappfrontend/blob/master/src/features/useWindowDimensions.js"
    click ProfileImg "https://github.com/scvapp/scvappfrontend/blob/master/src/components/ProfileImg/profileImg.jsx"
    click SideMenuComp "https://github.com/scvapp/scvappfrontend/blob/master/src/components/SideMenu/sideMenu.jsx"
    click ScheduleItem "https://github.com/scvapp/scvappfrontend/blob/master/src/components/ScheduleItem/scheduleItem.jsx"
    click StatusIcon "https://github.com/scvapp/scvappfrontend/blob/master/src/components/StatusIcon.jsx"
    click StyledTextField "https://github.com/scvapp/scvappfrontend/blob/master/src/components/StyledTextField.jsx"
    click LoginPage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/loginPage/loginPage.js"
    click HomePage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/homePage/homePage.jsx"
    click MealsPage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/mealsPage/mealsMain.jsx"
    click SettingsPage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/settingsPage/settingsPage.jsx"
    click AboutPage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/aboutPage/aboutPage.jsx"
    click NotFoundPage "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/404page/404page.js"
    click AdminDashboard "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminDashboard/adminDashboard.jsx"
    click AdminScheduleEdit "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminScheduleEdit/adminScheduleEdit.jsx"
    click AdminDoorPassAPI "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminDoorPass/adminDoorPassAPI.js"
    click DoorPassCreate "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminDoorPass/create/create.jsx"
    click DoorPassDashboard "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminDoorPass/dashboard/dashboard.jsx"
    click DoorPassShow "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/adminPanel/adminDoorPass/show/show.jsx"
    click SettingsAPI "https://github.com/scvapp/scvappfrontend/blob/master/src/pages/settingsPage/settingsAPI.js"
```
