# mmd-rehan/adms-server-zkteco architecture

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

- Interactive diagram: https://gitdiagram.com/mmd-rehan/adms-server-zkteco
- Repository: https://github.com/mmd-rehan/adms-server-zkteco

## Overview

##### Project type and purpose
- This is a full-stack web application called “Access (Attendance Device Management System)” built on Laravel (PHP).
- Its primary purpose is to receive, process, and display biometric attendance data from ZKTeco SpeedFace-V5L-RFID devices, and to provide an admin UI for managing users, devices, employees, and attendance logs.

##### File structure
- Top-level folders:
- app/ (core PHP code: Controllers, Middleware, Models, Console commands, Helpers, Providers)
- config/ (application & service configuration)
- database/ (migrations, seeders, factories)
- public/ (index.php front controller, assets, .htaccess)
- resources/ (Blade views, CSS, JS, Sass)
- routes/ (web.php, api.php, console.php, channels.php)
- bootstrap/ (app bootstrap & cache)
- tests/ (unit & feature)
- Build tooling: package.json, vite.config.js for asset compilation.
- Deployment artifacts: .env.example, .htaccess, Apache collection for Postman.

##### README for additional insights
- Describes Ubuntu + Apache deployment with port 8080, Cloudflare routing, Basic Auth protection on `/iclock/*` routes.
- Lists PHP, Composer, Node, MySQL setup steps.
- Emphasizes three device-facing endpoints: `/iclock/cdata`, `/iclock/test`, `/iclock/getrequest`.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Systems
    subgraph "External Systems" 
        direction TB
        Devices["ZKTeco SpeedFace-V5L-RFID Devices"]:::external
        Browser["Admin Browser"]:::client
    end

    %% Network & Security Layer
    subgraph "Network & Security Layer"
        direction TB
        CF["Cloudflare Proxy (DNS, CDN, SSL)"]:::external
        Apache["Apache HTTP Server\n(port 8080)"]:::server
        HTAccessRoot["/.htaccess"]:::config
        HTAccessPublic["/public/.htaccess"]:::config
    end

    %% Laravel Application
    subgraph "Laravel Application" 
        direction TB

        subgraph "Public Layer"
            direction TB
            Index["index.php"]:::server
            Assets["public/assets (CSS/JS)"]:::app
        end

        subgraph "HTTP Middleware Pipeline"
            direction TB
            AuthMW["Authenticate.php"]:::app
            AdminMW["AdminMiddleware.php"]:::app
            CsrfMW["VerifyCsrfToken.php"]:::app
            OtherMW["Other Middleware\n(/app/Http/Middleware)"]:::app
        end

        subgraph "Controllers"
            direction TB
            IClockCtrl["iclockController.php"]:::app
            DeviceCtrl["DeviceController.php"]:::app
            EmployeeCtrl["EmployeeController.php"]:::app
            UserCtrl["UserController.php"]:::app
            AuthCtrls["Auth Controllers\n(/app/Http/Controllers/Auth)"]:::app
            HomeCtrl["HomeController.php"]:::app
        end

        subgraph "Service Providers"
            direction TB
            RouteProv["RouteServiceProvider.php"]:::app
            AuthProv["AuthServiceProvider.php"]:::app
            EventProv["EventServiceProvider.php"]:::app
            BroadcastProv["BroadcastServiceProvider.php"]:::app
            AppProv["AppServiceProvider.php"]:::app
        end

        subgraph "Models (Eloquent)"
            direction TB
            DeviceModel["Device.php"]:::model
            EmployeeModel["Employee.php"]:::model
            AttendanceModel["Attendance.php"]:::model
            FingerLogModel["FingerLog.php"]:::model
            UserModel["User.php"]:::model
        end

        subgraph "Routes"
            direction TB
            WebRoutes["web.php"]:::config
            ApiRoutes["api.php"]:::config
            ConsoleRoutes["console.php"]:::config
            ChannelsRoutes["channels.php"]:::config
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MySQL["MySQL Database"]:::db
    end

    %% Client UI
    subgraph "Client UI"
        direction TB
        BladeViews["Blade Templates\n(resources/views)"]:::app
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        direction TB
        NPM["package.json\nvite.config.js"]:::config
        SrcJS["/resources/js"]:::app
        SrcCSS["/resources/css,/resources/sass"]:::app
        ViteBuild["Vite Build → public/assets"]:::app
    end

    %% Connections
    Devices -->|"HTTP Basic Auth\n/iclock/*"| CF
    CF -->|"HTTPS port 8080"| Apache
    Apache -->|"mod_rewrite\n.htaccess"| Index
    Apache -->|".htaccess rules"| HTAccessRoot
    Apache -->|".htaccess rules"| HTAccessPublic

    Index -->|"requests routed"| AuthMW
    AuthMW --> AdminMW
    AdminMW --> CsrfMW
    CsrfMW --> OtherMW
    OtherMW --> Controllers

    IClockCtrl -->|"Eloquent ORM"| DeviceModel
    DeviceCtrl --> DeviceModel
    EmployeeCtrl --> EmployeeModel
    EmployeeCtrl --> AttendanceModel
    FingerLogModel -->|logs| MySQL
    AttendanceModel --> MySQL
    DeviceModel --> MySQL
    UserModel --> MySQL

    WebRoutes --> DeviceCtrl
    WebRoutes --> EmployeeCtrl
    WebRoutes --> UserCtrl
    ApiRoutes --> IClockCtrl

    Controllers -->|"bootstrap via"| AppProv
    Controllers -->|"routes via"| RouteProv
    Controllers --> AuthProv
    Controllers --> EventProv
    Controllers --> BroadcastProv

    Browser -->|"HTTPS"| CF
    CF --> Apache
    Apache --> Index
    Index --> AuthMW
    AuthMW --> BladeViews
    BladeViews --> Browser

    SrcJS --> ViteBuild
    SrcCSS --> ViteBuild
    NPM --> ViteBuild
    ViteBuild --> Assets
    Assets --> Apache

    %% Click events
    click HTAccessRoot "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//.htaccess"
    click HTAccessPublic "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//public/.htaccess"
    click Index "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//public/index.php"
    click AuthMW "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Middleware/Authenticate.php"
    click AdminMW "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Middleware/AdminMiddleware.php"
    click CsrfMW "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Middleware/VerifyCsrfToken.php"
    click OtherMW "https://github.com/mmd-rehan/adms-server-zkteco/tree/main//app/Http/Middleware"
    click IClockCtrl "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Controllers/iclockController.php"
    click DeviceCtrl "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Controllers/DeviceController.php"
    click EmployeeCtrl "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Controllers/EmployeeController.php"
    click UserCtrl "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Controllers/UserController.php"
    click AuthCtrls "https://github.com/mmd-rehan/adms-server-zkteco/tree/main//app/Http/Controllers/Auth"
    click HomeCtrl "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Http/Controllers/HomeController.php"
    click RouteProv "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Providers/RouteServiceProvider.php"
    click AuthProv "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Providers/AuthServiceProvider.php"
    click EventProv "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Providers/EventServiceProvider.php"
    click BroadcastProv "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Providers/BroadcastServiceProvider.php"
    click AppProv "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Providers/AppServiceProvider.php"
    click DeviceModel "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Models/Device.php"
    click EmployeeModel "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Models/Employee.php"
    click AttendanceModel "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Models/Attendance.php"
    click FingerLogModel "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Models/FingerLog.php"
    click UserModel "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//app/Models/User.php"
    click WebRoutes "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//routes/web.php"
    click ApiRoutes "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//routes/api.php"
    click ConsoleRoutes "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//routes/console.php"
    click ChannelsRoutes "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//routes/channels.php"
    click NPM "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//package.json"
    click NPM "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//vite.config.js"
    click SrcJS "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//resources/js/app.js"
    click SrcCSS "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//resources/css/app.css"
    click SrcCSS "https://github.com/mmd-rehan/adms-server-zkteco/blob/main//resources/sass/app.scss"

    %% Styles
    classDef external fill:#a2f5a2,stroke:#333,stroke-width:1px
    classDef client fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef server fill:#97c2fc,stroke:#333,stroke-width:1px
    classDef app fill:#c2e0ff,stroke:#333,stroke-width:1px
    classDef model fill:#ffd580,stroke:#333,stroke-width:1px
    classDef db fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef config fill:#f5e1a4,stroke:#333,stroke-width:1px
```
