# rr3s1/jsm_medical_schedule_app architecture

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

## Overview

##### Main Components

- Project Configuration & Root Files
- These include files such as .eslintrc.json, .gitignore, next.config.mjs, package.json, package-lock.json, tsconfig.json, postcss.config.mjs, tailwind.config.ts, and the README file.
- They configure the project’s linting, build, and dependency management.

- App (Pages / Routing)
- The “app” directory contains page components for both patient-facing and admin functionality.
- It uses Next.js’ file-based routing with nested directories and dynamic routes (e.g., /patients/[userId]/...).

- Components (Reusable UI Elements)
- The “components” folder holds shared UI components like CustomFormField, FileUploader, PasskeyModal, StatCard, SubmitButton, and collections of form components and UI primitives.
- This folder encapsulates presentation-specific code, including subdirectories for “forms” and “ui” elements.

- Library & Business Logic
- The “lib” folder contains business logic, such as actions for appointments and patients (e.g., appointment.actions.ts, patient.actions.ts), appwrite configuration (appwrite.config.ts), utility functions (utils.ts), and validation (validation.ts).
- These files support data operations and integrate external services (Appwrite storage, processes for encryption, date formatting, etc.).

- Constants & Types
- The “constants” directory (with index.ts) holds constant values like gender options, default patient form values, doctors’ info, and asset paths.
- The “types” directory provides TypeScript definitions including global types, Appwrite types, and custom type declarations for domain models (patient, appointment, etc.).

- Public Assets

##### Emphasized Architectural Patterns

- File-Based Routing:
The dynamic routes (e.g., /patients/[userId]/…) show Next.js’ conventions and underscore the separation between user-specific and admin pages.

- Component Reusability:
The division into “components”, “forms” and “ui” emphasizes reusability, maintainability, and separation of concerns.

- Business Logic Separation:
With all backend actions and integrations organized under “lib”, non-view logic is separated from the UI, simplifying testing and scaling.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Project Root Files
  subgraph "Project Root"
    direction TB
    r1[".eslintrc.json"]:::config
    r2[".gitignore"]:::config
    r3["next.config.mjs"]:::config
    r4["package.json"]:::config
    r5["package-lock.json"]:::config
    r6["tsconfig.json"]:::config
    r7["postcss.config.mjs"]:::config
    r8["tailwind.config.ts"]:::config
    r9["README.md"]:::config
    r10["components.json"]:::config
  end

  %% Constants
  subgraph "constants"
    direction TB
    const1["index.ts"]:::constType
  end

  %% Library & Business Logic
  subgraph "lib"
    direction TB
    subgraph "actions"
      direction TB
      la1["appointment.actions.ts"]:::logic
      la2["patient.actions.ts"]:::logic
    end
    lf1["appwrite.config.ts"]:::logic
    lf2["utils.ts"]:::logic
    lf3["validation.ts"]:::logic
  end

  %% Public Assets
  subgraph "public"
    direction TB
    subgraph "assets"
      direction TB
      pa1["gifs"]:::publicAssets
      pa2["icons"]:::publicAssets
      pa3["images"]:::publicAssets
    end
  end

  %% Types
  subgraph "types"
    direction TB
    t1["index.d.ts"]:::types
    t2["appwrite.types.ts"]:::types
  end

  %% App (Pages / Routing)
  subgraph "app (Pages / Routing)"
    direction TB
    a1["globals.css"]:::appFile
    a2["layout.tsx"]:::appFile
    a3["page.tsx"]:::appFile
    subgraph "admin"
      direction TB
      a4["page.tsx"]:::appFile
    end
    subgraph "patients"
      direction TB
      subgraph "[userId]"
        direction TB
        subgraph "new-appointment"
          direction TB
          a5["page.tsx"]:::appFile
          subgraph "success"
            direction TB
            a6["page.tsx"]:::appFile
          end
        end
        subgraph "register"
          direction TB
          a7["page.tsx"]:::appFile
        end
      end
    end
  end

  %% Components (Reusable UI Elements)
  subgraph "components (Reusable UI Elements)"
    direction TB
    c1["CustomFormField.tsx"]:::component
    c2["FileUploader.tsx"]:::component
    c3["PasskeyModal.tsx"]:::component
    c4["StatCard.tsx"]:::component
    c5["SubmitButton.tsx"]:::component
    subgraph "forms"
      direction TB
      f1["AppointmentForm.tsx"]:::component
      f2["PatientForm.tsx"]:::component
      f3["RegisterForm.tsx"]:::component
    end
    ct1["theme-provider.tsx"]:::component
    subgraph "ui"
      direction TB
      u1["alert-dialog.tsx"]:::component
      u2["button.tsx"]:::component
      u3["checkbox.tsx"]:::component
      u4["dialog.tsx"]:::component
      u5["form.tsx"]:::component
      u6["input-otp.tsx"]:::component
      u7["input.tsx"]:::component
      u8["label.tsx"]:::component
      u9["radio-group.tsx"]:::component
      u10["select.tsx"]:::component
      u11["textarea.tsx"]:::component
    end
  end

  %% External Service: Appwrite Backend
  ABackend["Appwrite Backend"]:::external

  %% Interactions
  a3 -->|"uses"| c1
  a3 -->|"calls"| lf2
  lf1 -->|"integrates"| ABackend

  %% Styles
  classDef config fill:#f9c,stroke:#333,stroke-width:2px;
  classDef appFile fill:#bbf,stroke:#333,stroke-width:2px;
  classDef component fill:#fd8,stroke:#333,stroke-width:2px;
  classDef logic fill:#cfc,stroke:#333,stroke-width:2px;
  classDef constType fill:#fdd,stroke:#333,stroke-width:2px;
  classDef types fill:#ddf,stroke:#333,stroke-width:2px;
  classDef publicAssets fill:#efe,stroke:#333,stroke-width:2px;
  classDef external fill:#fcc,stroke:#333,stroke-width:2px;

  %% Click Events for Project Configuration & Root Files
  click r1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/.eslintrc.json"
  click r2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/.gitignore"
  click r3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/next.config.mjs"
  click r4 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/package.json"
  click r5 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/package-lock.json"
  click r6 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/tsconfig.json"
  click r7 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/postcss.config.mjs"
  click r8 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/tailwind.config.ts"
  click r9 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/README.md"
  click r10 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components.json"

  %% Click Events for App (Pages / Routing)
  click a1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/globals.css"
  click a2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/layout.tsx"
  click a3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/page.tsx"
  click a4 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/admin/page.tsx"
  click a5 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/patients/[userId]/new-appointment/page.tsx"
  click a6 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/patients/[userId]/new-appointment/success/page.tsx"
  click a7 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/app/patients/[userId]/register/page.tsx"

  %% Click Events for Components (Reusable UI Elements)
  click c1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/CustomFormField.tsx"
  click c2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/FileUploader.tsx"
  click c3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/PasskeyModal.tsx"
  click c4 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/StatCard.tsx"
  click c5 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/SubmitButton.tsx"
  click f1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/forms/AppointmentForm.tsx"
  click f2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/forms/PatientForm.tsx"
  click f3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/forms/RegisterForm.tsx"
  click ct1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/theme-provider.tsx"
  click u1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/alert-dialog.tsx"
  click u2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/button.tsx"
  click u3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/checkbox.tsx"
  click u4 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/dialog.tsx"
  click u5 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/form.tsx"
  click u6 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/input-otp.tsx"
  click u7 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/input.tsx"
  click u8 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/label.tsx"
  click u9 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/radio-group.tsx"
  click u10 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/select.tsx"
  click u11 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/components/ui/textarea.tsx"

  %% Click Events for Library & Business Logic
  click lf1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/lib/appwrite.config.ts"
  click lf2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/lib/utils.ts"
  click lf3 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/lib/validation.ts"
  click la1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/lib/actions/appointment.actions.ts"
  click la2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/lib/actions/patient.actions.ts"

  %% Click Events for Constants & Types
  click const1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/constants/index.ts"
  click t1 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/types/index.d.ts"
  click t2 "https://github.com/rr3s1/jsm_medical_schedule_app/blob/main/types/appwrite.types.ts"

  %% Click Events for Public Assets
  click pa1 "https://github.com/rr3s1/jsm_medical_schedule_app/tree/main/public/assets/gifs"
  click pa2 "https://github.com/rr3s1/jsm_medical_schedule_app/tree/main/public/assets/icons"
  click pa3 "https://github.com/rr3s1/jsm_medical_schedule_app/tree/main/public/assets/images"
```
