# skygr0u/pfe-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/skygr0u/pfe-dashboard
- Repository: https://github.com/skygr0u/pfe-dashboard

## Overview

##### Project type and purpose
- This is a full-stack web application providing user management, chat, calendar scheduling, approval workflows, and embedded analytics (PowerBI).
- The Client-Side is a React/TypeScript SPA built with Vite. The Server-Side is a Node.js/Express REST API with MVC-style controllers and services. It integrates with Firebase for authentication, uses a relational (or NoSQL) database (configured in config/config.js), and sends emails for notifications.

##### File structure
- Top Level:
- Client-Side/ – React app
- Server-Side/ – Express API
- README.md (empty)
- Client-Side patterns:
- src/components, pages, layout, context, hooks, services, firebase – standard React feature folders
- Auth flow (SignIn/SignUp/ProtectedRoute), chat, calendar, pending-approvals, user CRUD, PowerBI embed
- Context providers for Auth, Theme, Sidebar
- Services layer encapsulating HTTP calls to backend
- Server-Side patterns:
- controllers/ – handle HTTP requests
- services/ – business logic (authService, chatService, calendarService, userService, approvalService, emailService)
- routes/ – map URLs to controllers
- middleware/authMiddleware.js – JWT or Firebase token validation
- config/ – DB and Firebase Admin SDK configs

##### README
- (No content provided – infer from structure)

a. Main components:
1. Browser (React SPA)
2. Vite Dev/Static File Server
3. Express API
4. Database (e.g. PostgreSQL or MongoDB)
5. Firebase Authentication (Firebase Auth service)
6. Email Service (SMTP, e.g. nodemailer or external API)
7. External Analytics (PowerBI)
b. Relationships and interactions:
- Browser ↔ Express API: REST calls for auth, users, chat, calendar, pending approvals
- Express API ↔ Database: CRUD operations via services
- Express API ↔ Firebase Auth: token issuance/verification (via firebase.js admin SDK)
- Express API ↔ Email Service: send password resets, approvals notifications
- Browser ↔ Firebase Auth SDK: initial sign-in & token management
- Browser ↔ PowerBI Embed: iframe or library integration for dashboards
c. Architectural patterns:
- Client: Component-based MVVM with Context for state, Service layer for API calls
- Server: MVC (Routes → Controllers → Services → Data layer)
- Layered architecture separates presentation, business logic, data access
d. Key technologies:
- React, Vite, TypeScript, Context API, React Router
- Node.js, Express, JavaScript
- Firebase Auth SDK (client) & Admin SDK (server)
- Database (configured via config/config.js)
- nodemailer or external email API
- PowerBI JavaScript Embed API

##### Details
- Subdomains: Authentication flow, User CRUD, Chat messaging, Calendar scheduling, Approval workflow, Analytics embed.
- Token flows: Client obtains Firebase token → includes it in REST headers → authMiddleware validates via Firebase Admin.
- Service responsibilities (e.g. emailService sends notifications).
- Don’t omit folder-level insights: e.g. Context vs. Hooks vs. Services in the client.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client (Frontend)"
        direction TB
        Browser["Browser (React SPA)"]:::frontend
        Vite["Vite Dev/Static File Server"]:::frontend
        AuthSDK["Firebase Auth SDK"]:::external
        PowerBI["PowerBI Embed"]:::external

        subgraph "UI Components"
            direction TB
            SignIn["SignInForm"]:::frontend
            SignUp["SignUpForm"]:::frontend
            ProtectedRoute["ProtectedRoute"]:::frontend
            SignOut["SignOut"]:::frontend
            UsersTable["Users-Table.tsx"]:::frontend
            ChatPage["ChatPage"]:::frontend
            CalendarPage["CalendarPage"]:::frontend
            PendingTable["PendingUserTable"]:::frontend
            PowerBIComp["PowerBIEmbed"]:::frontend
        end

        subgraph "Context & Services"
            direction TB
            AuthContext["AuthContext"]:::frontend
            UseAuth["useAuth Hook"]:::frontend
            ThemeContext["ThemeContext"]:::frontend
            SidebarContext["SidebarContext"]:::frontend
            UserServiceClient["userService"]:::frontend
            AuthServiceClient["authServiceClient"]:::frontend
            ChatServiceClient["chatServiceClient"]:::frontend
            CalendarServiceClient["calendarService"]:::frontend
        end
    end

    subgraph "Server (Backend)"
        direction TB
        Server["Express API"]:::backend

        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes"]:::backend
            ChatRoutes["chatRoutes"]:::backend
            CalendarRoutes["calendarRoutes"]:::backend
            UserRoutes["userRoutes"]:::backend
            SuperAdminRoutes["superadminRoutes"]:::backend
        end

        Middleware["authMiddleware"]:::backend

        subgraph "Controllers"
            direction TB
            AuthController["authController"]:::backend
            ChatController["chatController"]:::backend
            CalendarController["calendarController"]:::backend
            UserController["userController"]:::backend
            SuperAdminController["superadminController"]:::backend
            ImageController["imageController"]:::backend
        end

        subgraph "Services"
            direction TB
            AuthService["authService"]:::services
            ChatService["chatService"]:::services
            CalendarService["calendarService"]:::services
            UserServiceServer["userService"]:::services
            ApprovalService["approvalService"]:::services
            EmailService["emailService"]:::services
        end

        DBConfig["config.js"]:::config
        FirebaseAdmin["firebase.js"]:::config
    end

    Database["Database"]:::database
    EmailServiceExt["Email Service (SMTP)"]:::external
    FirebaseAuth["Firebase Auth Service"]:::external

    Browser --> Vite
    Browser --> AuthSDK
    AuthSDK --> Browser
    Browser --> PowerBI
    Browser --> SignIn
    Browser --> SignUp
    Browser --> ProtectedRoute
    Browser --> SignOut
    Browser --> UsersTable
    Browser --> ChatPage
    Browser --> CalendarPage
    Browser --> PendingTable
    Browser --> PowerBIComp

    SignIn --> AuthServiceClient
    SignUp --> AuthServiceClient
    ProtectedRoute --> AuthContext
    SignOut --> AuthContext
    UsersTable --> UserServiceClient
    ChatPage --> ChatServiceClient
    CalendarPage --> CalendarServiceClient
    PendingTable --> UserServiceClient

    AuthServiceClient --> Server
    UserServiceClient --> Server
    ChatServiceClient --> Server
    CalendarServiceClient --> Server

    Server --> AuthRoutes
    Server --> ChatRoutes
    Server --> CalendarRoutes
    Server --> UserRoutes
    Server --> SuperAdminRoutes

    AuthRoutes --> Middleware
    ChatRoutes --> Middleware
    CalendarRoutes --> Middleware
    UserRoutes --> Middleware
    SuperAdminRoutes --> Middleware

    Middleware --> AuthController
    Middleware --> ChatController
    Middleware --> CalendarController
    Middleware --> UserController
    Middleware --> SuperAdminController
    Middleware --> ImageController

    AuthController --> AuthService
    ChatController --> ChatService
    CalendarController --> CalendarService
    UserController --> UserServiceServer
    SuperAdminController --> ApprovalService
    ImageController --> ApprovalService

    AuthService --> DBConfig
    ChatService --> DBConfig
    CalendarService --> DBConfig
    UserServiceServer --> DBConfig
    ApprovalService --> DBConfig

    AuthService --> FirebaseAdmin
    ChatService --> FirebaseAdmin
    CalendarService --> FirebaseAdmin
    UserServiceServer --> FirebaseAdmin
    ApprovalService --> FirebaseAdmin

    AuthService --> EmailServiceExt
    ApprovalService --> EmailServiceExt

    DBConfig --> Database

    click Browser "https://github.com/skygr0u/pfe-dashboard/tree/main/Client-Side/"
    click Vite "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/vite.config.ts"
    click Server "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/index.js"
    click AuthRoutes "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/routes/authRoutes.js"
    click ChatRoutes "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/routes/chatRoutes.js"
    click CalendarRoutes "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/routes/calendarRoutes.js"
    click UserRoutes "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/routes/userRoutes.js"
    click SuperAdminRoutes "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/routes/superadminRoutes.js"
    click AuthController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/authController.js"
    click ChatController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/chatController.js"
    click CalendarController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/calendarController.js"
    click UserController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/userController.js"
    click SuperAdminController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/superadminController.js"
    click ImageController "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/controllers/imageController.js"
    click AuthService "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/authService.js"
    click ChatService "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/chatService.js"
    click CalendarService "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/calendarService.js"
    click UserServiceServer "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/userService.js"
    click ApprovalService "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/approvalService.js"
    click EmailService "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/services/emailService.js"
    click Middleware "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/middleware/authMiddleware.js"
    click FirebaseAdmin "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/config/firebase.js"
    click DBConfig "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/config/config.js"
    click EmailServiceExt "https://github.com/skygr0u/pfe-dashboard/blob/main/Server-Side/test-email.js"
    click AuthSDK "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/firebase/firebaseConfig.ts"
    click SignIn "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/components/auth/SignInForm/SignInForm.tsx"
    click SignUp "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/components/auth/SignUpForm/SignUpForm.tsx"
    click ProtectedRoute "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/components/auth/ProtectedRoute/ProtectedRoute.tsx"
    click SignOut "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/components/auth/SignOut/SignOut.tsx"
    click AuthContext "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/context/AuthContext.tsx"
    click UseAuth "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/hooks/useAuth.tsx"
    click UsersTable "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/pages/Crud-Table/Users-Table.tsx"
    click UserServiceClient "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/services/userService.ts"
    click ChatPage "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/pages/Chat/ChatPage.tsx"
    click CalendarPage "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/pages/Calendar.tsx"
    click PowerBIComp "https://github.com/skygr0u/pfe-dashboard/blob/main/Client-Side/src/components/PowerBIEmbed/PowerBIEmbed.tsx"

    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#008000,stroke-width:1px
    classDef services fill:#FFFF99,stroke:#CCCC00,stroke-width:1px
    classDef config fill:#FFF0F5,stroke:#FF69B4,stroke-width:1px
    classDef database fill:#FFA500,stroke:#FF8C00,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:1px
```
