# dmytro-shvetsov/employee-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/dmytro-shvetsov/employee-tracker
- Repository: https://github.com/dmytro-shvetsov/employee-tracker

## Overview

##### Project Type and Purpose
- This is a full-stack employee productivity tracking solution composed of:
- A native desktop client (ETClient) built with Qt/C++ for data collection (network packets, screenshots, idle detection).
- A backend web application (ETWeb) using Django with Channels (WebSocket) and REST Framework for data ingestion, storage, authentication, and server-side logic.
- A single-page React frontend for managers to view real-time and historical employee activity via REST calls and WebSocket updates.

##### File Structure Analysis
- Top-level folders:
- ETClient – Qt project with UI, business logic, networking, and Pcap++ dependency subfolders.
- ETWeb – Django project containing:
– accounts, projects, employees apps (models, migrations, REST serializers/views).
– api endpoints under ETWeb/api for non-app-specific services.
– consumers.py, routing.py for WebSocket entry points.
– frontend submodule (React components, services, Webpack config).
- Build/deployment:
- ETClient.pro and deployment archives for client releases.
- ETWeb requirements.txt, Procfile, runtime.txt, webpack.config.js for deployment.

##### README Insights
- Desktop client collects: HTTP/SSL/TLS traffic stats, screenshots, idle prompts with WebSocket streams to server.
- Web app provides: authentication, project/user management, real-time status updates, activity log visualizations.

a. Main Components
1. ETClient Desktop Application
– UI Layer: AuthForm, MainWindow (Model-View-Presenter)
– Data Collection Layer: NetworkManager, Base/Http/SSL StatsCollectors, ScreenshotManager, IdleDetector
– Communication Layer: WebsocketClient (Qt WebSocket)
– Packet Capture Dependency: Pcap++ library modules (Ethernet, IP, TCP, SSL layers)
2. ETWeb Backend
– WebSocket Server: Django Channels consumer(s) handling incoming streams from clients
– REST API: Django REST Framework endpoints for frontend queries (accounts, projects, employees, logs)
– Authentication & Tokens: custom auth backends, token generation/signals
– Data Persistence: Relational database (e.g., PostgreSQL) storing user, project, activity records
– Business Logic: accounts, projects, employees Django apps
3. React Frontend
– Components: Auth, Dashboard, Charts, Forms under src/components
– Services: axios instance for REST, mailService, projectsService
– WebSocket Client: receives real-time status changes pushed by backend
– Routing and Layout containers

b. Interactions and Data Flows
1. Desktop client → Backend WebSocket
- On authorization success, open WebSocket to server (ETWeb/routing.py → consumers.py).
- Stream JSON payloads containing packet stats, screenshot data, idle status.
2. Backend → Database
- WebSocket consumer processes incoming messages → persists to DB via Django models.
3. Frontend → Backend REST
- React services call protected REST endpoints (login, fetch projects, fetch logs).
4. Backend → Frontend WebSocket
- On status changes or new data, Django Channels pushes updates over WebSocket to React client.
5. Frontend → User Browser
- Render UI, charts, notifications, pages (Auth, Dashboard, Project pages).

c. Architectural Patterns
- Client uses MVP (UI form, model, presenter) and loosely-coupled collectors and managers.
- Backend follows Django’s MVT with Channels for asynchronous messaging and REST for synchronous queries.
- Frontend is a standard React SPA with component-based design and services layer.

d. Key Technologies
- C++/Qt, Pcap++ on client
- Python/Django, Django REST Framework, Django Channels, WebSockets
- React, React-Router, Axios, Webpack, npm on frontend
- Relational database (PostgreSQL or similar)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Desktop Client Layer
    subgraph "Desktop Client" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            AuthForm["AuthForm"]:::client
            MainWindow["MainWindow (MVP)"]:::client
        end
        subgraph "Data Collection Layer"
            direction TB
            BaseStatsCollector["BaseStatsCollector"]:::client
            HttpStatsCollector["HttpStatsCollector"]:::client
            SSLStatsCollector["SSLStatsCollector"]:::client
            ScreenshotManager["ScreenshotManager"]:::client
            IdleDetector["IdleDetector"]:::client
        end
        subgraph "Communication Layer"
            direction TB
            WebsocketClient["WebsocketClient"]:::client
        end
        PcapModules["Pcap++ Modules"]:::client
    end

    %% Backend Server Layer
    subgraph "ETWeb Backend" 
        direction TB
        WebSocketServer["Django Channels Consumer"]:::backend
        RESTAPI["REST API Endpoints"]:::backend
        AuthService["Authentication & Tokens"]:::backend
        BusinessLogic["Accounts/Projects/Employees Apps"]:::backend
        Database[(Database)]:::database
    end

    %% React Frontend Layer
    subgraph "React Frontend" 
        direction TB
        Components["UI Components"]:::frontend
        Services["Services Layer"]:::frontend
        FrontendWebsocket["WebSocket Client"]:::frontend
        RoutingLayout["Routing & Layout"]:::frontend
    end

    %% Data Flows
    AuthForm -->|collects credentials| MainWindow
    MainWindow -->|triggers collectors| BaseStatsCollector
    BaseStatsCollector -->|gathers data| HttpStatsCollector
    HttpStatsCollector -->|gathers data| SSLStatsCollector
    HttpStatsCollector -->|sends packets| ScreenshotManager
    SSLStatsCollector -->|sends packets| IdleDetector
    ScreenshotManager -->|screenshot binary| WebsocketClient
    IdleDetector -->|idle status| WebsocketClient
    PcapModules -->|packet capture| BaseStatsCollector

    WebsocketClient ---|WebSocket JSON stream| WebSocketServer
    WebSocketServer -->|process & persist| Database
    Database -->|store records| BusinessLogic
    BusinessLogic -->|expose endpoints| RESTAPI
    AuthService -->|token validation| RESTAPI

    Components -->|HTTP/HTTPS JSON| RESTAPI
    Services -->|calls REST| RESTAPI
    RESTAPI -->|query results| Components
    WebSocketServer <-->|"WebSocket JSON"| FrontendWebsocket
    FrontendWebsocket -->|updates| Components
    RoutingLayout -->|navigates UI| Components

    %% Click Events
    click AuthForm "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Authorization"
    click MainWindow "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/MainWindow"
    click BaseStatsCollector "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Network"
    click HttpStatsCollector "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Network"
    click SSLStatsCollector "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Network"
    click WebsocketClient "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Network"
    click PcapModules "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETClient/ETClient/Dependencies"
    click WebSocketServer "https://github.com/dmytro-shvetsov/employee-tracker/blob/master/ETWeb/ETWeb/consumers.py"
    click WebSocketServer "https://github.com/dmytro-shvetsov/employee-tracker/blob/master/ETWeb/ETWeb/routing.py"
    click RESTAPI "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/ETWeb/api"
    click AuthService "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/accounts"
    click BusinessLogic "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/projects"
    click BusinessLogic "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/employees"
    click Components "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/frontend/src/components"
    click Services "https://github.com/dmytro-shvetsov/employee-tracker/tree/master/ETWeb/frontend/src/services"
    click RoutingLayout "https://github.com/dmytro-shvetsov/employee-tracker/blob/master/ETWeb/frontend/src/routes.js"
    click RoutingLayout "https://github.com/dmytro-shvetsov/employee-tracker/blob/master/ETWeb/frontend/src/containers/Layout.js"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef database fill:#f2f2f2,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
