# syedharisshahdev/healthcare_management_system architecture

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

- Interactive diagram: https://gitdiagram.com/syedharisshahdev/healthcare_management_system
- Repository: https://github.com/syedharisshahdev/healthcare_management_system

## Overview

##### Main Components
- Frontend/UI Layer:
- Pages under the /app directory (homepage, admin panel, patient pages, API routes, and Sentry examples).
- Global layout components (layout.tsx, globals.css) and error handlers (global-error.tsx, loading.tsx).
- Reusable UI components in the /components directory — including modals (AppointmentModal, PasskeyModal), forms (RegisterForm, AppointmentForm, PatientForm), tables (DataTable), and UI primitives (button, input, alert-dialog, etc.).
- API and Backend Services:
- API endpoints in /app/api such as the sentry-example-api to handle server-side logic.
- Integration of external services like Sentry for error tracking (sentry.client.config.ts, sentry.edge.config.ts, sentry.server.config.ts) and likely Appwrite, based on the presence of an appwrite configuration file (lib/appwrite.config.ts).
- Domain Logic & Utilities:
- Business logic spread across the /lib directory with actions (for patient and appointment functionalities) and utility modules (lib/utils.ts, lib/validation.ts).
- Constants and types (in the constants and types directories) that facilitate structured communication between layers.
- Development & Configuration:
- Essential configuration files such as next.config.mjs, tailwind.config.ts, postcss.config.mjs, and ESLint configuration.
- Build and dependency management files like package.json and package-lock.json.

##### Relationships & Interactions
- The Frontend:
- Uses the Next.js “app” directory for routing. Pages interact with backend API routes and call business logic actions.
- UI components (in /components) are integrated into pages to handle user interactions (e.g., submission of a form triggers a process in lib/actions).
- API and Business Logic:
- The app routes under /app/api act as a middle layer, interfacing between the UI and business logic (i.e., lib/actions modules). They may also trigger Sentry events for error logging.
- External Integration & Monitoring:
- Sentry modules and Appwrite configuration indicate the use of external services for error monitoring and possibly third-party authentication or data services.

##### Architectural Patterns & Key Technologies
- The project uses a modular and component-based design (common in Next.js projects) to separate concerns:
- Presentation Layer (UI components and pages)
- Application Layer (API routes and business logic in lib/actions)
- Integration/External Services (Sentry, Appwrite)
- This design promotes scalability and maintainability by decoupling UI, application logic, and external integrations.
- Key frameworks and libraries include Next.js, Sentry (for error monitoring), and possibly Appwrite (for backend as a service).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend: Pages & Layout
    subgraph "Frontend (Pages & Layout)"
        hmp("Homepage"):::frontend
        admin("Admin Page"):::frontend
        reg("Patient Registration Page"):::frontend
        newAppt("New Appointment Page"):::frontend
        apptSuccess("Appointment Success Page"):::frontend
        sentryPg("Sentry Example Page"):::frontend
        layout("Layout"):::frontend
        globalError("Global Error"):::frontend
        loading("Loading"):::frontend
        globalStyles("Global Styles"):::frontend
    end

    %% UI Components
    subgraph "UI Components"
        appointModal("Appointment Modal"):::ui
        passkeyModal("Passkey Modal"):::ui
        appointForm("Appointment Form"):::ui
        patientForm("Patient Form"):::ui
        registerForm("Register Form"):::ui
        dataTable("Data Table"):::ui
        tableColumns("Table Columns"):::ui
        uiPrimitives("UI Primitives"):::ui
    end

    %% API Layer
    subgraph "API Layer"
        sentryAPI("Sentry API"):::api
    end

    %% Business Logic & Utilities
    subgraph "Business Logic & Utilities"
        appointActions("Appointment Actions"):::business
        patientActions("Patient Actions"):::business
        utilities("Utilities"):::business
        validation("Validation"):::business
    end

    %% External Services
    subgraph "External Services"
        sentryClient("Sentry Client"):::external
        sentryEdge("Sentry Edge"):::external
        sentryServer("Sentry Server"):::external
        appwriteConfig("Appwrite Config"):::external
    end

    %% Domain Definitions
    subgraph "Domain Definitions"
        constants("Constants"):::config
        appwriteTypes("Appwrite Types"):::config
        otherTypes("Other Types"):::config
    end

    %% Configurations & Dev Tools
    subgraph "Configurations & Dev Tools"
        nextConfig("Next Config"):::config
        tailwindConfig("Tailwind Config"):::config
        postcssConfig("PostCSS Config"):::config
        eslintConfig("ESLint Config"):::config
        packageFile("Package File"):::config
        packageLock("Package Lock"):::config
    end

    %% Relationships between Frontend pages and UI Components
    reg -->|"renders"| registerForm
    newAppt -->|"renders"| appointForm
    newAppt -->|"renders"| appointModal
    admin -->|"renders"| dataTable

    %% Frontend pages interacting with API Layer
    reg -->|"calls"| sentryAPI
    newAppt -->|"calls"| sentryAPI
    sentryPg -->|"triggers"| sentryAPI

    %% API Layer to Business Logic interactions
    sentryAPI -->|"processes"| appointActions
    sentryAPI -->|"processes"| patientActions
    sentryAPI -->|"validates"| validation
    sentryAPI -->|"utilizes"| utilities

    %% Business Logic to Domain Definitions
    appointActions -->|"uses"| constants
    appointActions -->|"uses"| appwriteTypes
    patientActions -->|"uses"| constants
    patientActions -->|"uses"| otherTypes

    %% Business Logic to External Services
    appointActions -->|"errorTrack"| sentryClient
    appointActions -->|"errorTrack"| sentryEdge
    patientActions -->|"errorTrack"| sentryServer
    patientActions -->|"integrates"| appwriteConfig

    %% Click Events for Frontend/UI Pages and Routing
    click hmp "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/page.tsx"
    click admin "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/admin/page.tsx"
    click reg "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/patients/[userId]/register/page.tsx"
    click newAppt "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/patients/[userId]/new-appointment/page.tsx"
    click apptSuccess "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/patients/[userId]/new-appointment/success/page.tsx"
    click sentryPg "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/sentry-example-page/page.tsx"

    %% Click Events for Global Layout and Error Handling
    click layout "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/layout.tsx"
    click globalError "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/global-error.tsx"
    click loading "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/loading.tsx"
    click globalStyles "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/globals.css"

    %% Click Events for Reusable UI Components and Primitives
    click appointModal "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/AppointmentModal.tsx"
    click passkeyModal "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/PasskeyModal.tsx"
    click appointForm "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/forms/AppointmentForm.tsx"
    click patientForm "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/forms/PatientForm.tsx"
    click registerForm "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/forms/RegisterForm.tsx"
    click dataTable "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/table/DataTable.tsx"
    click tableColumns "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/components/table/columns.tsx"
    click uiPrimitives "https://github.com/syedharisshahdev/healthcare_management_system/tree/main/components/ui"

    %% Click Events for API Endpoints and Server-side Logic
    click sentryAPI "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/app/api/sentry-example-api/route.ts"

    %% Click Events for External Service Integrations
    click sentryClient "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/sentry.client.config.ts"
    click sentryEdge "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/sentry.edge.config.ts"
    click sentryServer "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/sentry.server.config.ts"
    click appwriteConfig "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/lib/appwrite.config.ts"

    %% Click Events for Domain Business Logic and Utilities
    click appointActions "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/lib/actions/appointment.actions.ts"
    click patientActions "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/lib/actions/patient.actions.ts"
    click utilities "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/lib/utils.ts"
    click validation "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/lib/validation.ts"

    %% Click Events for Constants and Types for Domain Communication
    click constants "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/constants/index.ts"
    click appwriteTypes "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/types/appwrite.types.ts"
    click otherTypes "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/types/index.d.ts"

    %% Click Events for Development & Configuration Files
    click nextConfig "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/next.config.mjs"
    click tailwindConfig "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/tailwind.config.ts"
    click postcssConfig "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/postcss.config.mjs"
    click eslintConfig "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/.eslintrc.json"
    click packageFile "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/package.json"
    click packageLock "https://github.com/syedharisshahdev/healthcare_management_system/blob/main/package-lock.json"

    %% Class definitions for styling
    classDef frontend fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef ui fill:#FF9900,stroke:#333,stroke-width:2px;
    classDef api fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef business fill:#99FF99,stroke:#333,stroke-width:2px;
    classDef external fill:#FF6666,stroke:#333,stroke-width:2px;
    classDef config fill:#CCCCCC,stroke:#333,stroke-width:2px;
```
