# jain-arihant-2002/hms_client architecture

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

- Interactive diagram: https://gitdiagram.com/jain-arihant-2002/hms_client
- Repository: https://github.com/jain-arihant-2002/hms_client

## Overview

##### Project Identification
- This is a modern React-based single-page application built with Vite.
- The application supports multiple user roles (admin, doctor, patient) and primarily manages hospital-related functionalities such as scheduling appointments, managing doctor/patient records, handling prescriptions, and registration.
- The README indicates role-based access which suggests that authentication and authorization are integral parts of the system.

##### Analyzing the File Structure
- Top-Level Files and Folders:
- index.html: The main HTML document.
- package.json & vite.config.js: Build/configuration files for Vite and dependency management.
- public folder: Contains static assets and a _redirects file likely used for proper routing on Netlify.
- src folder: Contains the bulk of the application logic.
- Key Folders in src:
- app: Houses application-wide configurations such as store.js (likely setting up the Redux store) and API slice files (e.g., apiSlice.js) which suggest the use of Redux Toolkit Query (RTK Query) for data fetching.
- components: Contains reusable UI components (Navbar, Layout, etc.).
- features: Segregated by domain (appointment, auth, doctor, patient, prescription, register). Each of these folders contains React components for different CRUD operations (Register, Update, Delete, View) as well as API slice definitions for state management and server interactions.
- hooks: Contains custom hooks such as useAuth.js which likely handle authentication logic.

##### Key Components and Their Interactions
- Frontend UI Components:
- General UI Elements: Located in /src/components – these include layout components, navigation bars, and common UI components.
- Feature-Specific Views: Found under /src/features (appointment, doctor, etc.), each feature folder encapsulates the view logic for its specific domain.
- State Management and API Integration:
- Redux Store: Configured in src/app/store.js; this central state management system likely integrates with various feature reducers and API slices.
- API Slices: Each feature (appointmentApiSlice, authApiSlice, etc.) encapsulates interactions with backend APIs.
- Authentication & Authorization:
- Components and hooks under /src/features/auth and /src/hooks (useAuth.js) indicate role-based authentication and protection of routes/components.
- Build/Deployment:
- Use of Vite (vite.config.js) implies modern tooling for fast development builds.
- The _redirects file in public hints at deployment configurations (e.g., routing rules on Netlify).

- Inset details for each module (appointment, auth, doctor, etc.) showing their internal CRUD components and associated API slice interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user

    ReactApp["React Application"]:::frontend

    subgraph "Frontend Application Files"
        indexFile["index.html"]:::frontendFile
        mainFile["main.jsx"]:::frontendFile
        appFile["App.jsx"]:::frontendFile
    end

    UI["UI Components"]:::ui

    subgraph "Feature Modules"
        subgraph "Appointment Module"
            A_View["Appointment Views"]:::feature
            A_API["Appointment API"]:::api
        end
        subgraph "Authentication Module"
            Auth_Comp["Auth Components"]:::feature
            Auth_API["Auth API"]:::api
        end
        subgraph "Doctor Module"
            D_View["Doctor Views"]:::feature
            D_API["Doctor API"]:::api
        end
        subgraph "Patient Module"
            P_View["Patient Views"]:::feature
            P_API["Patient API"]:::api
        end
        subgraph "Prescription Module"
            PR_View["Prescription Views"]:::feature
            PR_API["Prescription API"]:::api
        end
        subgraph "Registration Module"
            R_View["Registration View"]:::feature
            R_API["Registration API"]:::api
        end
    end

    subgraph "State Management & Hooks"
        Redux["Redux Store"]:::state
        SharedAPI["Shared API Slice"]:::state
        AuthHook["useAuth Hook"]:::state
    end

    subgraph "Build & Deployment"
        ViteConfig["Vite Config"]:::build
        StaticAssets["Static Assets"]:::build
        PackageMgmt["Package Management"]:::build
    end

    External["External API"]:::external

    %% Connections
    User --> ReactApp
    ReactApp --> indexFile
    ReactApp --> mainFile
    ReactApp --> appFile
    ReactApp --> UI
    ReactApp --> Redux
    ReactApp --> SharedAPI
    ReactApp --> AuthHook
    ReactApp --> ViteConfig
    ReactApp --> StaticAssets
    ReactApp --> PackageMgmt

    UI --> A_View
    UI --> Auth_Comp
    UI --> D_View
    UI --> P_View
    UI --> PR_View
    UI --> R_View

    A_View --> A_API
    Auth_Comp --> Auth_API
    D_View --> D_API
    P_View --> P_API
    PR_View --> PR_API
    R_View --> R_API

    A_API --> External
    Auth_API --> External
    D_API --> External
    P_API --> External
    PR_API --> External
    R_API --> External

    AuthHook --> Auth_Comp

    %% Click Events
    click indexFile "https://github.com/jain-arihant-2002/hms_client/blob/master/index.html"
    click mainFile "https://github.com/jain-arihant-2002/hms_client/blob/master/src/main.jsx"
    click appFile "https://github.com/jain-arihant-2002/hms_client/blob/master/src/App.jsx"
    click UI "https://github.com/jain-arihant-2002/hms_client/tree/master/src/components"
    click A_View "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/appointment/ViewAppointment.jsx"
    click A_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/appointment/appointmentApiSlice.js"
    click Auth_Comp "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/auth/Login.jsx"
    click Auth_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/auth/authApiSlice.js"
    click D_View "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/doctor/ViewDoctor.jsx"
    click D_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/doctor/doctorApiSlice.js"
    click P_View "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/patient/ViewPatient.jsx"
    click P_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/patient/patientApiSlice.js"
    click PR_View "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/prescription/ViewPrescription.jsx"
    click PR_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/prescription/prescriptionApiSlice.js"
    click R_View "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/register/Register.jsx"
    click R_API "https://github.com/jain-arihant-2002/hms_client/blob/master/src/features/register/registerApiSlice.js"
    click Redux "https://github.com/jain-arihant-2002/hms_client/blob/master/src/app/store.js"
    click SharedAPI "https://github.com/jain-arihant-2002/hms_client/blob/master/src/app/api/apiSlice.js"
    click AuthHook "https://github.com/jain-arihant-2002/hms_client/blob/master/src/hooks/useAuth.js"
    click ViteConfig "https://github.com/jain-arihant-2002/hms_client/blob/master/vite.config.js"
    click StaticAssets "https://github.com/jain-arihant-2002/hms_client/tree/master/public/_redirects"
    click PackageMgmt "https://github.com/jain-arihant-2002/hms_client/blob/master/package.json"

    %% Styles
    classDef user fill:#BBDEFB,stroke:#000,stroke-width:1px;
    classDef frontend fill:#D1C4E9,stroke:#000,stroke-width:1px;
    classDef frontendFile fill:#E1BEE7,stroke:#000,stroke-width:1px;
    classDef ui fill:#FFECB3,stroke:#000,stroke-width:1px;
    classDef feature fill:#C8E6C9,stroke:#000,stroke-width:1px;
    classDef api fill:#AED581,stroke:#000,stroke-width:1px;
    classDef state fill:#FFF9C4,stroke:#000,stroke-width:1px;
    classDef build fill:#FFCDD2,stroke:#000,stroke-width:1px;
    classDef external fill:#B39DDB,stroke:#000,stroke-width:1px;
```
