# phuoctmse/healthcare_system architecture

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

- Interactive diagram: https://gitdiagram.com/phuoctmse/healthcare_system
- Repository: https://github.com/phuoctmse/healthcare_system

## Overview

##### Main System Components

A. Frontend Layer
- Next.js Application (Client-side)
- Admin Portal
- Patient Portal
- UI Components Library

B. Backend Layer
- Next.js API Routes/Server Components
- Authentication System
- Action Handlers

C. Database Layer
- Appwrite Backend (evident from appwrite.config.ts)

##### Component Relationships

A. User Interface Level:
- Admin Dashboard (/admin)
- Patient Management (/patients)
- Appointment Booking (/patients/[userId]/new-appointment)
- Registration System (/patients/[userId]/register)

B. Component Level:
- Forms (AppointmentForm, PatientForm, RegisterForm)
- UI Elements (modals, tables, form fields)
- Shared Components (StatCard, StatusBadge)

##### Data Flow Architecture

**User Interface → Actions Layer → Appwrite Backend**
- ↑               ↓              ↓
- Components ← State Management ← Database

##### Specific Implementation Details

Create sections for:

A. Authentication Flow:
- PasskeyModal component
- Authentication states
- User sessions

B. Feature Modules:
- Appointment Management
- Patient Registration
- Admin Dashboard
- File Upload System

##### Technical Stack Indicators

Technology badges for:
- Next.js
- TypeScript
- Tailwind CSS
- Appwrite
- Shadcn UI (evident from components.json and ui components)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        UI[UI Components]
        AP["Admin Portal"]
        PP["Patient Portal"]
        Pages[Pages Router]
        Forms[Forms System]
        SharedComp[Shared Components]
        FileUp[File Upload System]
        ThemeP[Theme Provider]
        Modal[PasskeyModal]
        DT[Data Tables]
    end

    subgraph "Backend Layer"
        API[Next.js API Routes]
        Auth[Authentication System]
        Actions[Action Handlers]
        Val[Validation Layer]
    end

    subgraph "Database Layer"
        DB[(Appwrite Backend)]
        Types[Type Definitions]
        Constants[Constants]
    end

    %% Relationships
    UI --> Pages
    Pages --> AP
    Pages --> PP
    UI --> Forms
    UI --> SharedComp
    UI --> FileUp
    UI --> Modal
    UI --> DT
    ThemeP --> UI

    Forms --> Actions
    Actions --> DB
    Auth --> DB
    API --> Actions
    Actions --> Val
    DB --> Types
    DB --> Constants

    %% Click Events
    click AP "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/app/admin/page.tsx"
    click PP "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/app/patients"
    click Forms "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/components/forms"
    click UI "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/components/ui"
    click SharedComp "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/components"
    click FileUp "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/components/FileUploader.tsx"
    click ThemeP "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/components/theme-provider.tsx"
    click Modal "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/components/PasskeyModal.tsx"
    click DT "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/components/table/DataTable.tsx"
    click Auth "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/components/PasskeyModal.tsx"
    click Actions "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/lib/actions"
    click DB "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/lib/appwrite.config.ts"
    click Val "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/lib/validation.ts"
    click Types "https://github.com/phuoctmse/HealthCare_System/tree/main/healthcare_system/types"
    click Constants "https://github.com/phuoctmse/HealthCare_System/blob/main/healthcare_system/constants/index.ts"

    %% Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef database fill:#f97316,color:#fff
    classDef auth fill:#a855f7,color:#fff
    classDef util fill:#6b7280,color:#fff

    class UI,AP,PP,Pages,Forms,SharedComp,FileUp,ThemeP,DT frontend
    class API,Actions,Val backend
    class DB database
    class Auth,Modal auth
    class Types,Constants util

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        D[Database]:::database
        A[Auth]:::auth
        U[Utilities]:::util
    end
```
