# gabriel-dee/rchs architecture

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

- Interactive diagram: https://gitdiagram.com/gabriel-dee/rchs
- Repository: https://github.com/gabriel-dee/rchs

## Overview

##### High-Level Architecture Components

a) Client Layer
- Next.js Frontend (App Router Architecture)
- Authentication Layer
- Dashboard Interface
- Components Library

b) Server Layer
- Next.js API Routes
- Authentication Service
- Database Connection Layer

c) Database Layer
- User Management
- Healthcare Records Storage

##### Detailed Component Breakdown

Create sections for the following major components:

a) Authentication Flow
- Login/Register System
- Password Recovery
- Session Management (using NextAuth.js)

b) Core Features
- Patient Management (Mother/Child)
- Visit Tracking
- Immunization Records
- Analytics & Reporting
- User Settings

##### Data Flow Representation

Following interactions:

**Client Components ↔ Server Components ↔ API Routes ↔ Database**

##### Specific Implementation Details

- Blue: Client-side components
- Green: Server-side components
- Yellow: Authentication components
- Purple: Database interactions
- Orange: External services/APIs

##### Component Organization

- Authentication Module
- Login
- Register
- Password Recovery

- Dashboard Module
- Analytics
- Reports
- Settings

- Patient Management
- Mother Profiles
- Child Profiles
- Visit Records

- Medical Records
- Immunization
- Growth Tracking
- Visit History

##### Technical Stack Indicators

- Next.js 13+
- TypeScript
- Tailwind CSS
- NextAuth.js
- Database (show connection)

##### Key Design Patterns

Highlight:
- App Router Architecture
- Server Components
- Client Components
- API Routes Structure

##### Important Notes

- Separation between client and server components
- Protected routes and public routes
- Demonstrate the authentication flow
- Data flow between components
- Error handling paths
- Reporting system structure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client_Layer
        UI["User Interface"]:::frontend
        Auth["Authentication UI"]:::frontend
        Dash["Dashboard Interface"]:::frontend
        Comp["Components Library"]:::frontend
    end

    subgraph Server_Layer
        API["API Routes"]:::backend
        AuthService["Authentication Service"]:::backend
        DBConn["Database Connection"]:::backend
    end

    subgraph Database_Layer
        DB[(Database)]:::database
    end

    subgraph Auth_Module["Authentication Module"]
        Login["Login"]:::auth
        Register["Register"]:::auth
        PassRec["Password Recovery"]:::auth
    end

    subgraph Dashboard_Module["Dashboard Module"]
        MainDash["Main Dashboard"]:::dashboard
        Analytics["Analytics"]:::dashboard
    end

    subgraph Patient_Management["Patient Management"]
        MotherProf["Mother Profiles"]:::patient
        ChildProf["Child Profiles"]:::patient
        Registration["Registration"]:::patient
    end

    subgraph Medical_Records["Medical Records"]
        MotherRec["Mother Records"]:::records
        ChildRec["Child Records"]:::records
        Immun["Immunization"]:::records
    end

    subgraph Visit_System["Visit Tracking"]
        ChildVisit["Child Visits"]:::visit
        ParentVisit["Parent Visits"]:::visit
        Consult["Consultation"]:::visit
    end

    subgraph Reports["Reports System"]
        ChildRep["Child Reports"]:::report
        PostNatal["Postnatal Care"]:::report
    end

    subgraph Settings["Settings Management"]
        AccSet["Account Settings"]:::settings
        Notif["Notifications"]:::settings
        Display["Display Settings"]:::settings
    end

    subgraph Growth_Charts["Growth Monitoring"]
        BMI["BMI Charts"]:::charts
        Weight["Weight Charts"]:::charts
        Length["Length Charts"]:::charts
    end

    UI --> Auth_Module
    Auth_Module --> AuthService
    AuthService --> DB
    UI --> Dashboard_Module
    Dashboard_Module --> API
    API --> DBConn
    DBConn --> DB

    %% Click Events
    click Login "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(Authentication)/Login/page.tsx"
    click Register "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(Authentication)/Register/page.tsx"
    click PassRec "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(Authentication)/ForgotPassword/page.tsx"
    click MainDash "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Dashboard/page.tsx"
    click Analytics "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Analytics/page.tsx"
    click MotherProf "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Profiles/Mother/page.tsx"
    click ChildProf "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Profiles/Child/page.tsx"
    click Registration "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Registration/"
    click MotherRec "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Records/Mother/page.tsx"
    click ChildRec "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Records/Child/page.tsx"
    click Immun "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Immunisation/page.tsx"
    click ChildVisit "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Visits/ChildVisits/page.tsx"
    click ParentVisit "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Visits/ParentVisits/page.tsx"
    click Consult "https://github.com/Gabriel-Dee/RCHS/blob/main/app/(dashboard)/Visits/ConsultationVisits/page.tsx"
    click ChildRep "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Reports/ChildFollowupReports/"
    click PostNatal "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Reports/PostnatalCareReports/"
    click AccSet "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Settings/account/"
    click Notif "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Settings/notifications/"
    click Display "https://github.com/Gabriel-Dee/RCHS/tree/main/app/(dashboard)/Settings/display/"
    click BMI "https://github.com/Gabriel-Dee/RCHS/blob/main/app/components/graphs/patient-bmi-age-*.tsx"
    click Weight "https://github.com/Gabriel-Dee/RCHS/blob/main/app/components/graphs/patient-weight-age-*.tsx"
    click Length "https://github.com/Gabriel-Dee/RCHS/blob/main/app/components/graphs/patient-length-age-*.tsx"
    click DBConn "https://github.com/Gabriel-Dee/RCHS/blob/main/utils/db.ts"
    click AuthService "https://github.com/Gabriel-Dee/RCHS/tree/main/app/api/auth/[...nextauth]/"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef database fill:#9C27B0,color:white
    classDef auth fill:#FFC107,color:black
    classDef dashboard fill:#03A9F4,color:white
    classDef patient fill:#00BCD4,color:white
    classDef records fill:#009688,color:white
    classDef visit fill:#4CAF50,color:white
    classDef report fill:#8BC34A,color:white
    classDef settings fill:#CDDC39,color:black
    classDef charts fill:#FFEB3B,color:black
```
