# cvarad96/employee-rating-system architecture

> Architecture diagram of the GitHub repository cvarad96/employee-rating-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cvarad96/employee-rating-system
- Repository: https://github.com/cvarad96/employee-rating-system

## Overview

##### Project type and purpose
- This is a monolithic, full-stack PHP web application (“Employee Rating System”) backed by a MySQL database.
- It serves two user roles (Admin and Manager), has both synchronous user-facing flows (through PHP views and JS/CSS assets) and asynchronous processes (cron jobs for reminders and report generation), plus an API endpoint for push notifications.

##### File structure
- Top-level “api” folder holds an API endpoint (push.php) for web-push.
- “assets”, “css”, and “js” folders contain front-end resources (Bootstrap + custom CSS/JS).
- “views” is subdivided into “admin”, “manager”, “auth” – the presentation layer.
- “classes” contains domain models and services (User, Employee, Department, EmailService, ReportGenerator, Notification, AuditLog, PasswordReset, etc.).
- “includes” has shared scripts (auth guard, header/footer, common functions, notification snippets).
- “config” holds application and database configuration templates.
- “cron” contains CLI scripts for weekly reminders and report emails.
- “tools” includes helper scripts (key generation, password hashing).
- “vendor” and composer.json/lock show use of Composer for third-party libraries.

##### README for technical stack and behavior
- PHP 7.4+, MySQL 5.7+
- Email and push-notification support
- Responsive UI
- Cron-driven weekly jobs for reminders and reports

##### Elements
- Annotations for technologies (PHP-FPM, MySQL, Bootstrap, Composer).

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Client Layer
  subgraph "Client Layer"
    Browser["Browser (HTML/JS/CSS)"]:::client
    Offline["offline.html"]:::client
  end

  %% Web Server
  subgraph "Web Server"
    WebServer["Apache/Nginx + PHP-FPM"]:::backend
  end

  %% Application Layer
  subgraph "Application Layer"
    subgraph "Controllers/Routing"
      Index["index.php"]:::backend
      ChangePwd["change_password.php"]:::backend
      ForgotPwd["forgot_password.php"]:::backend
      ResetPwd["reset_password.php"]:::backend
      TestEmail["test_email.php"]:::backend
      PushEP["api/push.php"]:::backend
    end
    subgraph "Views (Presentation)"
      AdminViews["views/admin/"]:::frontend
      ManagerViews["views/manager/"]:::frontend
      AuthViews["views/auth/logout.php"]:::frontend
      GlobalNotif["views/notifications.php"]:::frontend
    end
    subgraph "Includes (Shared Components)"
      AuthInc["includes/auth.php"]:::backend
      HeaderInc["includes/header.php"]:::backend
      FooterInc["includes/footer.php"]:::backend
      FuncInc["includes/functions.php"]:::backend
      NotifInc["includes/notifications.php"]:::backend
    end
    subgraph "Domain Models & Services"
      UserC["classes/User.php"]:::backend
      EmpC["classes/Employee.php"]:::backend
      DeptC["classes/Department.php"]:::backend
      TeamC["classes/Team.php"]:::backend
      RatingC["classes/Rating.php"]:::backend
      AuditC["classes/AuditLog.php"]:::backend
      NotifC["classes/Notification.php"]:::backend
      PwResetC["classes/PasswordReset.php"]:::backend
      EmailSvc["classes/EmailService.php"]:::backend
      ReportGen["classes/ReportGenerator.php"]:::backend
    end
    subgraph "Config & Data Access"
      ConfigT["config/config.php.template"]:::infra
      DBConfig["config/database.php"]:::infra
    end
  end

  %% Background & Tools
  subgraph "Infrastructure & Background Jobs"
    Scheduler["Cron Scheduler"]:::infra
    WeeklyRem["cron/weekly-reminder.php"]:::infra
    SendReports["cron/send_weekly_reports.php"]:::infra
    ToolsVapid["tools/generate-vapid-keys.php"]:::infra
    ToolsPwd["tools/password.php"]:::infra
    LogsDir["logs/"]:::infra
    CompJson["composer.json"]:::infra
    CompLock["composer.lock"]:::infra
    VendorDir["vendor/"]:::infra
  end

  %% Assets
  subgraph "Front-end Assets"
    CSSAssets["assets/css/"]:::frontend
    JSAssets["assets/js/"]:::frontend
    ImgAssets["assets/img/"]:::frontend
    CSSDup["css/"]:::frontend
    JSDup["js/"]:::frontend
  end

  %% External Services & Data
  subgraph "External Services"
    MySQLDB["MySQL Database"]:::db
    SMTP["Email Service (SMTP)"]:::external
    PushService["Push Service (Web Push)"]:::external
  end

  %% Connections
  Browser -->|loads static assets| CSSAssets
  Browser --> JSAssets
  Browser --> ImgAssets
  Browser --> CSSDup
  Browser --> JSDup
  Browser -->|HTTP GET/POST| WebServer
  Browser -->|offline fallback| Offline
  Browser -->|subscribe to push| PushEP
  WebServer -->|routes to| Index
  WebServer -->|routes to| ChangePwd
  WebServer -->|routes to| ForgotPwd
  WebServer -->|routes to| ResetPwd
  WebServer -->|routes to| TestEmail
  WebServer -->|routes to| PushEP
  Index -->|uses includes| AuthInc
  Index --> HeaderInc
  Index --> FooterInc
  Index --> FuncInc
  Index --> NotifInc
  Index --> AdminViews
  ChangePwd --> AuthViews
  ForgotPwd --> AuthViews
  ResetPwd --> AuthViews
  TestEmail --> GlobalNotif
  PushEP --> NotifC
  NotifC --> PushService
  Index --> UserC
  Index --> EmpC
  Index --> DeptC
  Index --> TeamC
  Index --> RatingC
  Index --> AuditC
  Index --> PwResetC
  Index --> ReportGen
  EmailSvc --> SMTP
  UserC --> MySQLDB
  EmpC --> MySQLDB
  DeptC --> MySQLDB
  TeamC --> MySQLDB
  RatingC --> MySQLDB
  AuditC --> MySQLDB
  PwResetC --> MySQLDB
  ReportGen --> MySQLDB

  Scheduler --> WeeklyRem
  Scheduler --> SendReports
  WeeklyRem --> EmailSvc
  WeeklyRem --> ReportGen
  WeeklyRem --> MySQLDB
  WeeklyRem --> LogsDir
  SendReports --> EmailSvc
  SendReports --> ReportGen
  SendReports --> MySQLDB
  SendReports --> LogsDir
  ToolsVapid -->|generate keys| PushEP
  ToolsPwd -->|hash passwords| PwResetC
  ConfigT --> DBConfig
  DBConfig --> MySQLDB
  CompJson --> VendorDir
  CompLock --> VendorDir
  Index --> DBConfig

  %% Click Events
  click PushEP "https://github.com/cvarad96/employee-rating-system/blob/main/api/push.php"
  click CSSAssets "https://github.com/cvarad96/employee-rating-system/tree/main/assets/css/"
  click JSAssets "https://github.com/cvarad96/employee-rating-system/tree/main/assets/js/"
  click ImgAssets "https://github.com/cvarad96/employee-rating-system/tree/main/assets/img/"
  click CSSDup "https://github.com/cvarad96/employee-rating-system/tree/main/css/"
  click JSDup "https://github.com/cvarad96/employee-rating-system/tree/main/js/"
  click Offline "https://github.com/cvarad96/employee-rating-system/blob/main/offline.html"
  click Index "https://github.com/cvarad96/employee-rating-system/blob/main/index.php"
  click ChangePwd "https://github.com/cvarad96/employee-rating-system/blob/main/change_password.php"
  click ForgotPwd "https://github.com/cvarad96/employee-rating-system/blob/main/forgot_password.php"
  click ResetPwd "https://github.com/cvarad96/employee-rating-system/blob/main/reset_password.php"
  click TestEmail "https://github.com/cvarad96/employee-rating-system/blob/main/test_email.php"
  click AdminViews "https://github.com/cvarad96/employee-rating-system/tree/main/views/admin/"
  click ManagerViews "https://github.com/cvarad96/employee-rating-system/tree/main/views/manager/"
  click AuthViews "https://github.com/cvarad96/employee-rating-system/blob/main/views/auth/logout.php"
  click GlobalNotif "https://github.com/cvarad96/employee-rating-system/blob/main/views/notifications.php"
  click AuthInc "https://github.com/cvarad96/employee-rating-system/blob/main/includes/auth.php"
  click HeaderInc "https://github.com/cvarad96/employee-rating-system/blob/main/includes/header.php"
  click FooterInc "https://github.com/cvarad96/employee-rating-system/blob/main/includes/footer.php"
  click FuncInc "https://github.com/cvarad96/employee-rating-system/blob/main/includes/functions.php"
  click NotifInc "https://github.com/cvarad96/employee-rating-system/blob/main/includes/notifications.php"
  click UserC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/User.php"
  click EmpC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/Employee.php"
  click DeptC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/Department.php"
  click TeamC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/Team.php"
  click RatingC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/Rating.php"
  click AuditC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/AuditLog.php"
  click NotifC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/Notification.php"
  click PwResetC "https://github.com/cvarad96/employee-rating-system/blob/main/classes/PasswordReset.php"
  click EmailSvc "https://github.com/cvarad96/employee-rating-system/blob/main/classes/EmailService.php"
  click ReportGen "https://github.com/cvarad96/employee-rating-system/blob/main/classes/ReportGenerator.php"
  click ConfigT "https://github.com/cvarad96/employee-rating-system/blob/main/config/config.php.template"
  click DBConfig "https://github.com/cvarad96/employee-rating-system/blob/main/config/database.php"
  click WeeklyRem "https://github.com/cvarad96/employee-rating-system/blob/main/cron/weekly-reminder.php"
  click SendReports "https://github.com/cvarad96/employee-rating-system/blob/main/cron/send_weekly_reports.php"
  click ToolsVapid "https://github.com/cvarad96/employee-rating-system/blob/main/tools/generate-vapid-keys.php"
  click ToolsPwd "https://github.com/cvarad96/employee-rating-system/blob/main/tools/password.php"
  click LogsDir "https://github.com/cvarad96/employee-rating-system/blob/main/logs/.gitkeep"
  click CompJson "https://github.com/cvarad96/employee-rating-system/blob/main/composer.json"
  click CompLock "https://github.com/cvarad96/employee-rating-system/blob/main/composer.lock"
  click VendorDir "https://github.com/cvarad96/employee-rating-system/tree/main/vendor/"

  %% Styles
  classDef client fill:#bbdefb,stroke:#333,stroke-width:1px
  classDef frontend fill:#e3f2fd,stroke:#333,stroke-width:1px
  classDef backend fill:#c8e6c9,stroke:#333,stroke-width:1px
  classDef db fill:#ffe0b2,stroke:#333,stroke-width:1px
  classDef external fill:#e1bee7,stroke:#333,stroke-width:1px
  classDef infra fill:#f0f4c3,stroke:#333,stroke-width:1px
```
