# git-denial/admin_dashboard architecture

> Architecture diagram of the GitHub repository git-denial/admin_dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/git-denial/admin_dashboard
- Repository: https://github.com/git-denial/admin_dashboard

## Overview

##### Main System Components

a) Frontend Layer:
- Subdivide into two main routes:
- Authenticated Routes (/cardiologists, /consultations, /users, /settings)
- Unauthenticated Routes (/login)

b) API Layer:
- Main API modules visible in /src/app/api:
- AdminAPI
- CardiologistAPI
- ChatAPI
- ConsultationAPI
- UserAPI

c) Server Actions Layer:
- Four main actions:
- Admin Actions
- Cardiologist Actions
- Consultation Actions
- User Actions

d) Database Layer:
- Prisma ORM
- Database (likely PostgreSQL based on prisma/schema.prisma)

##### Component Relationships

- Client → API Services (REST/HTTP)
- API Services → Server Actions
- Server Actions → Prisma ORM
- Prisma ORM → Database

##### Authentication Flow

- Auth Provider (visible in src/lib/auth.ts)
- Authentication flow between client and server
- Protected route middleware (src/middleware.ts)

##### UI Component Library

- Relationship to main application
- Major components like:
- Data Tables
- Forms
- Dialogs
- Common UI Elements

##### Additional Elements

- Testing infrastructure (E2E and Unit tests)
- Utility services (src/utils)
- Configuration (environment, build tools)

##### Specific Implementation Details

Notes for:
- Next.js 13+ App Router architecture
- Server/Client component separation
- API route structure
- Database schema relationships

- → Synchronous data flow
- ⇢ Asynchronous data flow
- 🔒 Protected routes/actions
- 📡 API endpoints
- 💾 Data persistence
- 🔄 State management

Remember to highlight the real-time aspects of the consultation system, especially in the chat functionality, as indicated by the chatBox components in the consultations section.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        direction TB
        Client["Client Side (Next.js App)"]
        
        subgraph AuthRoutes["Authenticated Routes"]
            direction TB
            Card["Cardiologists"]
            Cons["Consultations"]
            Users["Users"]
            Set["Settings"]
        end
        
        subgraph UnAuthRoutes["Unauthenticated Routes"]
            Login["Login"]
        end
        
        Client --> AuthRoutes
        Client --> UnAuthRoutes
    end
    
    subgraph "API Layer"
        direction TB
        AdminAPI["Admin API"]:::api
        CardioAPI["Cardiologist API"]:::api
        ChatAPI["Chat API"]:::api
        ConsAPI["Consultation API"]:::api
        UserAPI["User API"]:::api
    end
    
    subgraph "Server Actions Layer"
        direction TB
        AdminAct["Admin Actions"]
        CardioAct["Cardiologist Actions"]
        ConsAct["Consultation Actions"]
        UserAct["User Actions"]
    end
    
    subgraph "Database Layer"
        direction TB
        PrismaORM["Prisma ORM"]
        DB[(Database)]
    end
    
    subgraph "Authentication System"
        direction TB
        AuthProv["Auth Provider"]
        AuthMid["Auth Middleware"]
    end
    
    subgraph "UI Components"
        direction TB
        DataTables["Data Tables"]
        Forms["Forms"]
        Dialogs["Dialogs"]
        CommonUI["Common UI Elements"]
    end
    
    %% Relationships
    AuthRoutes --> API_Layer
    UnAuthRoutes --> API_Layer
    API_Layer --> Server_Actions
    Server_Actions --> PrismaORM
    PrismaORM --> DB
    AuthProv --> AuthMid
    AuthMid --> AuthRoutes
    
    %% Component Mappings
    click Card "https://github.com/git-denial/admin_dashboard/tree/main//src/app/(authenticated)/cardiologists"
    click Cons "https://github.com/git-denial/admin_dashboard/tree/main//src/app/(authenticated)/consultations"
    click Users "https://github.com/git-denial/admin_dashboard/tree/main//src/app/(authenticated)/users"
    click Set "https://github.com/git-denial/admin_dashboard/tree/main//src/app/(authenticated)/settings"
    click Login "https://github.com/git-denial/admin_dashboard/tree/main//src/app/(unauthenticated)/login"
    click AdminAPI "https://github.com/git-denial/admin_dashboard/blob/main//src/app/api/AdminAPI.ts"
    click CardioAPI "https://github.com/git-denial/admin_dashboard/blob/main//src/app/api/CardiologistAPI.ts"
    click ChatAPI "https://github.com/git-denial/admin_dashboard/blob/main//src/app/api/ChatAPI.ts"
    click ConsAPI "https://github.com/git-denial/admin_dashboard/blob/main//src/app/api/ConsultationAPI.ts"
    click UserAPI "https://github.com/git-denial/admin_dashboard/blob/main//src/app/api/UserApi.ts"
    click AdminAct "https://github.com/git-denial/admin_dashboard/blob/main//src/app/server_actions/admin.tsx"
    click CardioAct "https://github.com/git-denial/admin_dashboard/blob/main//src/app/server_actions/cardiologist.tsx"
    click ConsAct "https://github.com/git-denial/admin_dashboard/blob/main//src/app/server_actions/consultation.tsx"
    click UserAct "https://github.com/git-denial/admin_dashboard/blob/main//src/app/server_actions/user.tsx"
    click AuthProv "https://github.com/git-denial/admin_dashboard/blob/main//src/lib/auth.ts"
    click AuthMid "https://github.com/git-denial/admin_dashboard/blob/main//src/middleware.ts"
    click DataTables "https://github.com/git-denial/admin_dashboard/blob/main//src/components/ui/dataTable.tsx"
    click Forms "https://github.com/git-denial/admin_dashboard/blob/main//src/components/ui/form.tsx"
    click Dialogs "https://github.com/git-denial/admin_dashboard/blob/main//src/components/ui/dialog.tsx"
    click CommonUI "https://github.com/git-denial/admin_dashboard/tree/main//src/components/ui"
    click PrismaORM "https://github.com/git-denial/admin_dashboard/blob/main//src/lib/prisma.ts"
    click DB "https://github.com/git-denial/admin_dashboard/blob/main//prisma/schema.prisma"
    
    %% Styling
    classDef frontend fill:#3498db
    classDef api fill:#2ecc71
    classDef server fill:#f1c40f
    classDef database fill:#9b59b6
    classDef auth fill:#e74c3c
    
    class Client,AuthRoutes,UnAuthRoutes,Card,Cons,Users,Set,Login frontend
    class AdminAPI,CardioAPI,ChatAPI,ConsAPI,UserAPI api
    class AdminAct,CardioAct,ConsAct,UserAct server
    class PrismaORM,DB database
    class AuthProv,AuthMid auth
    
    %% Legend
    subgraph Legend
        direction TB
        L1[Frontend]:::frontend
        L2[API Services]:::api
        L3[Server Actions]:::server
        L4[Database]:::database
        L5[Auth Components]:::auth
    end
```
