# saayam-for-all/webapp architecture

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

- Interactive diagram: https://gitdiagram.com/saayam-for-all/webapp
- Repository: https://github.com/saayam-for-all/webapp

## Overview

##### Project type and purpose
- This is a single‐page web application (“Saayam Web Application”) implemented entirely in ReactJS/Vite with Redux Toolkit for state management.
- It provides user authentication, help‐request submission, volunteer registration, donation flows, multilingual support (i18n), and communicates with backend REST endpoints (hosted externally or via AWS).

##### File structure
- Top-level config files (.babelrc, vite.config.js, netlify.toml, tailwind.config.js, etc.) indicate a Vite+Tailwind+Netlify deployment.
- “src/pages” organizes each route’s UI.
- “src/common/components” holds shared UI widgets (DataTable, Loader, Modal, Navbar, etc.).
- “src/Layout” contains layout scaffolding.
- “src/hooks”, “src/utils”, “src/services” encapsulate custom hooks, utility functions, and HTTP clients/endpoints definitions.
- “src/redux” holds all Redux Toolkit slices and async thunks by feature (authentication, requests, volunteer, admin, etc.).
- “src/routes” contains route definitions and protected‐route logic.
- “src/assets” includes static images.

A. Client Browser
B. React Application (“Saayam Web App”)
1. UI Layer
– Page modules (src/pages/*)
– Common shared components (src/common/components)
– Layout (src/Layout)
2. State Layer
– Redux store (src/redux/store.js)
– Feature slices & async thunks (src/redux/features/**)
3. Service Layer
– HTTP client (src/services/api.js)
– Endpoint definitions (src/services/endpoints.json)
– Feature‐specific service modules (requestServices, volunteerServices, etc.)
4. Utility & Config
– i18n configuration & locale data (src/common/i18n)
– AWS export config (src/utils/config/aws-exports.js)
– Custom hooks (useFetch, usePlacesSearchBox)
– Validation and helpers (src/utils/*.js)
5. Routing
– Route definitions (src/routes/routes.jsx)
– ProtectedRoute wrapper (src/routes/ProtectedRoute.jsx)
C. External Backend/API
– Auth service (Cognito, custom OAuth, etc.)
– Help-request service
– Volunteer service
– Donation/payment gateway
D. Deployment & Hosting
– Netlify (netlify.toml) or other static hosting
– CI/CD pipeline (.github/workflows/CICDPipeline.yaml)

##### Relationships and interactions
- Browser ←→ React App: user actions trigger UI events.
- UI Layer dispatches Redux actions → handled by async thunks → Service Layer.
- Service Layer uses HTTP client → sends requests to External Backend/API → receives JSON responses.
- Data flows back into Redux store → UI re-renders.
- i18n module intercepts UI rendering with locale strings.
- ProtectedRoute guards certain pages by reading auth state from Redux.

##### Architectural patterns and design principles
- Component-based UI (React) with separation of pages vs. shared components.
- Unidirectional data flow (Flux pattern via Redux Toolkit).
- Layered architecture: UI → State → Service → External API.
- Feature-based separation in Redux slices.
- Hook-based abstraction for side effects (e.g., network fetch, map/place search).
- Configuration-driven endpoints (endpoints.json) for easy environment switching.
- Internationalization (i18n) organized under a dedicated folder.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["Client Browser"]:::external

    subgraph "Saayam Web App"
        Main["Entry Point"]:::app
        subgraph "UI Layer"
            Pages["Pages"]:::ui
            Components["Shared Components"]:::ui
            Layout["Layout Scaffold"]:::ui
        end
        subgraph "State Layer"
            Store["Redux Store"]:::state
            AuthSlice["Auth Slice & Thunks"]:::state
            HelpReqSlice["Help Request Slice & Thunks"]:::state
            RequestsSlice["Requests Slice & Thunks"]:::state
            VolunteerSlice["Volunteer Slice & Thunks"]:::state
            AdminSlice["Admin Slice & Thunks"]:::state
            UserSlice["User Slice & Thunks"]:::state
        end
        subgraph "Service Layer"
            HTTPClient["HTTP Client"]:::service
            Endpoints["Endpoint Config"]:::service
            HelpService["Help Request Service"]:::service
            VolunteerService["Volunteer Service"]:::service
        end
        subgraph "Utility & Config"
            I18n["i18n Config & Data"]:::util
            AWSConfig["AWS Export Config"]:::util
            Hooks["Custom Hooks"]:::util
            Helpers["Validation & Helpers"]:::util
        end
        subgraph "Routing"
            Routes["Route Definitions"]:::route
            Protected["ProtectedRoute Wrapper"]:::route
        end
    end

    subgraph "External Backend/API"
        AuthService["Auth Service"]:::external
        HelpServiceAPI["Help Request Service"]:::external
        VolunteerAPI["Volunteer Service"]:::external
        PaymentGateway["Payment Gateway"]:::external
    end

    Netlify["Netlify Hosting"]:::deploy
    CICD["CI/CD Pipeline"]:::deploy

    User -->|"interacts with"| Pages
    Pages -->|"dispatch UI events"| Store
    Components -->|"dispatch UI events"| Store
    Layout -->|"dispatch UI events"| Store

    Store -->|"dispatch AUTH actions"| AuthSlice
    Store -->|"dispatch HELP_REQUEST actions"| HelpReqSlice
    Store -->|"dispatch REQUESTS actions"| RequestsSlice
    Store -->|"dispatch VOLUNTEER actions"| VolunteerSlice
    Store -->|"dispatch ADMIN actions"| AdminSlice
    Store -->|"dispatch USER actions"| UserSlice

    AuthSlice --> HTTPClient
    HelpReqSlice --> HTTPClient
    RequestsSlice --> HTTPClient
    VolunteerSlice --> HTTPClient
    AdminSlice --> HTTPClient
    UserSlice --> HTTPClient

    HTTPClient -->|"uses endpoints"| Endpoints
    HTTPClient -->|"GET/POST requests"| AuthService
    HTTPClient -->|"GET /help"| HelpServiceAPI
    HTTPClient -->|"GET /volunteer"| VolunteerAPI
    HTTPClient -->|"POST /donate"| PaymentGateway
    HTTPClient -->|"receives responses"| Store
    Store -->|"updates UI"| Pages

    I18n -->|"provides locale strings"| Pages

    Routes -->|"define navigation"| Pages
    Protected -->|"guards routes"| Pages

    CICD -->|"build & deploy"| Netlify

    click Main "https://github.com/saayam-for-all/webapp/blob/main/src/main.jsx"
    click Pages "https://github.com/saayam-for-all/webapp/tree/main/src/pages/"
    click Components "https://github.com/saayam-for-all/webapp/tree/main/src/common/components/"
    click Layout "https://github.com/saayam-for-all/webapp/blob/main/src/Layout/Layout.jsx"
    click Store "https://github.com/saayam-for-all/webapp/blob/main/src/redux/store.js"
    click AuthSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/authentication/authSlice.js"
    click AuthSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/authentication/authActions.js"
    click AuthSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/authentication/signupSlice.js"
    click HelpReqSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/help_request/requestSlice.js"
    click HelpReqSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/help_request/requestActions.js"
    click RequestsSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/requests/requestsSlice.js"
    click RequestsSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/requests/requestsAction.js"
    click VolunteerSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/volunteer/volunteerSlice.js"
    click VolunteerSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/volunteer/volunteerActions.js"
    click AdminSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/admin/adminSlice.js"
    click AdminSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/admin/adminActions.js"
    click UserSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/user/userSlice.js"
    click UserSlice "https://github.com/saayam-for-all/webapp/blob/main/src/redux/features/user/userActions.js"
    click HTTPClient "https://github.com/saayam-for-all/webapp/blob/main/src/services/api.js"
    click Endpoints "https://github.com/saayam-for-all/webapp/blob/main/src/services/endpoints.json"
    click HelpService "https://github.com/saayam-for-all/webapp/blob/main/src/services/requestServices.js"
    click HelpService "https://github.com/saayam-for-all/webapp/blob/main/src/services/requestApi.js"
    click VolunteerService "https://github.com/saayam-for-all/webapp/blob/main/src/services/volunteerServices.js"
    click I18n "https://github.com/saayam-for-all/webapp/blob/main/src/common/i18n/i18n.js"
    click I18n "https://github.com/saayam-for-all/webapp/tree/main/src/common/i18n/"
    click AWSConfig "https://github.com/saayam-for-all/webapp/blob/main/src/utils/config/aws-exports.js"
    click Hooks "https://github.com/saayam-for-all/webapp/blob/main/src/hooks/useFetch.jsx"
    click Hooks "https://github.com/saayam-for-all/webapp/blob/main/src/pages/HelpRequest/location/usePlacesSearchBox.jsx"
    click Helpers "https://github.com/saayam-for-all/webapp/blob/main/src/utils/validators.js"
    click Helpers "https://github.com/saayam-for-all/webapp/blob/main/src/utils/utils.js"
    click Routes "https://github.com/saayam-for-all/webapp/blob/main/src/routes/routes.jsx"
    click Protected "https://github.com/saayam-for-all/webapp/blob/main/src/routes/ProtectedRoute.jsx"
    click Netlify "https://github.com/saayam-for-all/webapp/blob/main/netlify.toml"
    click CICD "https://github.com/saayam-for-all/webapp/blob/main/.github/workflows/CICDPipeline.yaml"

    classDef ui fill:#d0e6f7,stroke:#333,stroke-width:1px
    classDef state fill:#d4f7d0,stroke:#333,stroke-width:1px
    classDef service fill:#f7d1a0,stroke:#333,stroke-width:1px
    classDef util fill:#e2d0f7,stroke:#333,stroke-width:1px
    classDef route fill:#f7d0d0,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
    classDef deploy fill:#f0c0e0,stroke:#333,stroke-width:1px
    classDef app fill:#e0e0e0,stroke:#333,stroke-width:2px
```
