# mittrayash/hpcs-hr-panel architecture

> Architecture diagram of the GitHub repository mittrayash/hpcs-hr-panel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mittrayash/hpcs-hr-panel
- Repository: https://github.com/mittrayash/hpcs-hr-panel

## Overview

##### Project Type and Purpose
- Type: Full-stack, monolithic web application
- Purpose: An HR management portal for employee attendance, profile management, checklists, payroll, etc., built on PHP/AJAX/MySQL with a rich HTML/CSS/JS frontend

##### File Structure
- Top-level directories:
– html/ : Static HTML page templates (header, footer, form pages)
– php/ : Server-side scripts (authentication, CRUD endpoints, AJAX handlers)
– includes/ : Shared code (config.inc.php, function libraries, validation)
– css/, js/, fonts/, images/, uploads/ : Static assets served to the browser
- Database schema files: hpcs_admin.sql
- Build/deploy: No containerization—runs on a LAMP stack (Apache + PHP)
- Special features: AJAX-driven autosuggest and data tables; MSQL Events for automated checklist updates; email subsystem (php/autoMail.php)

##### Extract Insights from README
- Frontend tech: HTML5, CSS3 (Bootstrap), JavaScript, jQuery
- Backend tech: PHP 5.x/7.x, AJAX, MySQL
- Runtime: Apache or any PHP-capable web server; cookies and sessions for auth; MD5 hashing for passwords
- Modules described: Login, Dashboard, Employee Add/View/Update, Attendance, Checklist, Payroll

##### Main Components and Their Relationships
a. User (Browser)
– UI pages under html/, css/, js/
– Sends HTTP(S) requests (GET/POST) and AJAX calls via jQuery
b. Web Server & Application Layer
– Apache/Nginx serving static assets and routing requests to PHP
– includes/config.inc.php loads DB credentials and global settings
– includes/function.inc.php holds business-logic functions (e.g., addEmployee(), getAttendance())
– php/*.php scripts implement each feature: login.php, AddEmp2.php, attendance2.php, etc.
– Session & Cookie manager for authentication
– Email service (autoMail.php) using SMTP or PHP mail() for notifications
c. Database Layer
– MySQL database `hpcs_admin`
– Tables: login, employees, attendance, checklist, payroll, etc.
– MSQL Event Scheduler for checklist status updates
d. File Storage
– uploads/ for employee photos or attachments

Interaction Flow (high level):
1. Browser → Web Server: HTTP GET/POST (login, form submissions)
2. Web Server → PHP scripts: request handling, session validation
3. PHP → MySQL: CRUD queries via config.inc.php connection
4. MySQL → PHP: result sets (JSON for AJAX, HTML for full page)
5. PHP → Browser: HTML/CSS/JS or JSON data
6. PHP → File System: save uploaded images, logs
7. PHP → SMTP/email: send autoMail notifications

##### Architectural Patterns and Design Principles
- Three-Tier Architecture: Presentation (Client), Application (PHP), Data (MySQL)
- Modularization:
– “includes” folder for shared logic (DRY principle)
– Separate scripts per feature in php/ (single-responsibility)
- AJAX pattern for partial updates (autosuggest, data tables)
- Event-driven tasks in DB (MSQL Events for checklist automation)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["User Browser"]:::frontend

    %% Web Server Layer
    subgraph "Web Server"
        direction TB
        subgraph "Static Asset Server"
            direction TB
            HTMLTemplates["HTML Templates (html/)"]:::static
            CSS["CSS (css/)"]:::static
            JS["JavaScript (js/)"]:::static
            Fonts["Fonts (fonts/)"]:::static
            Images["Images (images/)"]:::static
        end

        subgraph "PHP Application Server"
            direction TB
            subgraph "Authentication Module"
                direction TB
                Config["config.inc.php"]:::dynamic
                Functions["function.inc.php"]:::dynamic
                Login["login.php"]:::dynamic
                Logout["logout.php"]:::dynamic
                ResetPass["resetpass.php"]:::dynamic
            end
            subgraph "Employee Management Module"
                direction TB
                AddEmpHTML["AddEmployee.html"]:::dynamic
                ViewClientHTML["viewclientdetails.html"]:::dynamic
                AddEmp1["AddEmp.php"]:::dynamic
                AddEmp2["AddEmployee.php"]:::dynamic
                AddEmp3["addEmp2.php"]:::dynamic
                UpdateEmp1["updateEmp.php"]:::dynamic
                UpdateEmp2["updateEmp2.php"]:::dynamic
                UpdateEmp3["updateEmp3.php"]:::dynamic
                UpdateSuggest["updateEmpSuggest.php"]:::dynamic
                ViewEmp["viewEmp.php"]:::dynamic
                ViewEmps["viewEmployees.php"]:::dynamic
            end
            subgraph "Attendance Module"
                direction TB
                Attendance1["attendance.php"]:::dynamic
                Attendance2["attendance2.php"]:::dynamic
                EmpAttendance["empAttendance.php"]:::dynamic
            end
            subgraph "Checklist Module"
                direction TB
                Checklist1["checklist.php"]:::dynamic
                Checklist2["checklistUpdate.php"]:::dynamic
                Checklist3["checklistUpdate2.php"]:::dynamic
                Checklist4["checklistUpdate3.php"]:::dynamic
                Checklist5["checklistUpdate4.php"]:::dynamic
            end
            subgraph "Payroll Module"
                direction TB
                GetPayroll["getPayroll.php"]:::dynamic
                ViewPayroll["viewPayroll.php"]:::dynamic
                ViewProjects["viewProjects.php"]:::dynamic
            end
            subgraph "AJAX Validation Endpoints"
                direction TB
                VerifyContact["verifyContact.php"]:::dynamic
                VerifyEmail["verifyEmail.php"]:::dynamic
                VerifyUser["verifyUsername.php"]:::dynamic
                UserExists1["userExists.php"]:::dynamic
                UserExists2["userExists2.php"]:::dynamic
            end
            subgraph "Email Service"
                direction TB
                AutoMail["autoMail.php"]:::dynamic
            end
        end

        SessionMgr["Session & Cookie Manager"]:::dynamic
    end

    %% Data Layer
    subgraph "Data & Storage"
        direction TB
        MySQLDB["MySQL Database (hpcs_admin)"]:::db
        SQLSchema["hpcs_admin.sql"]:::db
        FileStorage["File Storage (uploads/)"]:::storage
        MsqlEvent["MSQL Event Scheduler"]:::db
    end

    %% Relationships
    Browser -->|"HTTP/S Requests"| HTMLTemplates
    Browser -->|"HTTP/S Requests"| Login
    Browser -->|"AJAX Calls"| VerifyContact
    HTMLTemplates --> CSS
    HTMLTemplates --> JS
    JS --> VerifyEmail
    Login --> SessionMgr
    SessionMgr --> Functions
    Functions --> MySQLDB
    AddEmp1 --> Functions
    Attendance1 --> Functions
    Checklist1 --> Functions
    GetPayroll --> Functions
    VerifyUser --> Functions
    AutoMail --> SessionMgr
    AutoMail -->|"SMTP"| MySQLDB
    Functions --> FileStorage
    MySQLDB --> MsqlEvent
    MsqlEvent --> Checklist3

    %% Click Events
    click Config "https://github.com/mittrayash/hpcs-hr-panel/blob/master/includes/config.inc.php"
    click Functions "https://github.com/mittrayash/hpcs-hr-panel/blob/master/includes/function.inc.php"
    click Login "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/login.php"
    click Logout "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/logout.php"
    click ResetPass "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/resetpass.php"
    click AddEmpHTML "https://github.com/mittrayash/hpcs-hr-panel/blob/master/html/AddEmployee.html"
    click ViewClientHTML "https://github.com/mittrayash/hpcs-hr-panel/blob/master/html/viewclientdetails.html"
    click AddEmp1 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/AddEmp.php"
    click AddEmp2 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/AddEmployee.php"
    click AddEmp3 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/addEmp2.php"
    click UpdateEmp1 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/updateEmp.php"
    click UpdateEmp2 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/updateEmp2.php"
    click UpdateEmp3 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/updateEmp3.php"
    click UpdateSuggest "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/updateEmpSuggest.php"
    click ViewEmp "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/viewEmp.php"
    click ViewEmps "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/viewEmployees.php"
    click Attendance1 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/attendance.php"
    click Attendance2 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/attendance2.php"
    click EmpAttendance "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/empAttendance.php"
    click Checklist1 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/checklist.php"
    click Checklist2 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/checklistUpdate.php"
    click Checklist3 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/checklistUpdate2.php"
    click Checklist4 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/checklistUpdate3.php"
    click Checklist5 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/checklistUpdate4.php"
    click GetPayroll "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/getPayroll.php"
    click ViewPayroll "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/viewPayroll.php"
    click ViewProjects "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/viewProjects.php"
    click VerifyContact "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/verifyContact.php"
    click VerifyEmail "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/verifyEmail.php"
    click VerifyUser "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/verifyUsername.php"
    click UserExists1 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/userExists.php"
    click UserExists2 "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/userExists2.php"
    click AutoMail "https://github.com/mittrayash/hpcs-hr-panel/blob/master/php/autoMail.php"
    click SQLSchema "https://github.com/mittrayash/hpcs-hr-panel/blob/master/hpcs_admin.sql"
    click HTMLTemplates "https://github.com/mittrayash/hpcs-hr-panel/tree/master/html/"
    click CSS "https://github.com/mittrayash/hpcs-hr-panel/tree/master/css/"
    click JS "https://github.com/mittrayash/hpcs-hr-panel/tree/master/js/"
    click Fonts "https://github.com/mittrayash/hpcs-hr-panel/tree/master/fonts/"
    click Images "https://github.com/mittrayash/hpcs-hr-panel/tree/master/images/"
    click FileStorage "https://github.com/mittrayash/hpcs-hr-panel/tree/master/uploads/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef static fill:#d4edda,stroke:#28a745,color:#000;
    classDef dynamic fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef db fill:#f8d7da,stroke:#dc3545,color:#000;
    classDef storage fill:#f8d7da,stroke:#e07a5f,color:#000;
```
