# juliusbiascan/eduinsight-client architecture

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

- Interactive diagram: https://gitdiagram.com/juliusbiascan/eduinsight-client
- Repository: https://github.com/juliusbiascan/eduinsight-client

## Overview

##### Recognize the Project Type and Purpose
- The README explicitly describes EduInsight Client as a tool to “monitor and control” student activities in computer labs, featuring real-time screen monitoring, file sharing, quiz management, and more.
- The file tree shows the typical Electron structure: the src/main directory (for the backend/OS interfacing part) and the src/renderer directory (for the user interface).

##### And Represent the Main Components
a. Electron Shell:
- Encompasses the whole desktop application, indicating that both the main and renderer processes run in one package.
b. Main Process:
- Located in src/main, it includes assets (audio, images, scripts), a variety of handlers (database.ts, socket.ts, updater.ts, etc.), and libraries (device.ts, tray-menu.ts, database-client.ts, etc.). These modules indicate that the main process handles critical functions such as connectivity (using Socket.IO and PeerJS), device and network management, database communication (via Prisma and MySQL), and OS-level interactions.
c. Renderer Process:
- Found in src/renderer, mostly written in React (with TypeScript), covering several UI components such as dashboards, modals, and various form controls. There are multiple “windows” (e.g., dashboard, main, quiz, setup) representing different views or functions of the application.
d. Database:
- The prisma folder and the DATABASE_URL configuration (MySQL) indicate that user data, quiz details, and other persistent state are stored in a MySQL database, managed via Prisma.
e. External Services and Communications:
- The project leverages Socket.IO for real-time communications and PeerJS for peer-to-peer features. These external services should be represented as part of the data flow between the main process and the external network (or among peer clients).

##### Relationships and Interactions
- How various handlers (file, database, socket, quiz, etc.) within the main process interact with external systems (local file system, MySQL database, external socket services).
- Flow from the renderer’s UI interactions (user clicks on buttons, submits forms, selects quizzes) through API calls (e.g., using the preload API or direct Socket communication in src/renderer/lib/socket.ts) to the main process.
- A connection from the main process’s database client (prisma) to the MySQL server.

##### Important Architectural Patterns and Technologies
- Modular separation: Breaking down the application into clear modules such as handlers, libraries, components, and windows.
- Two-level processing: Clear division between the Electron main process (backend, system controls) and the renderer (frontend, UI).
- Use of real-time communication protocols (Socket.IO and PeerJS) to support the features like live screen monitoring and quiz assessments.
- Utilization of a type-safe environment (TypeScript) and styling frameworks (TailwindCSS) to ensure maintainability.

- Components from the project (as revealed by the directory structure) are represented even if at a high level.
- Do not overcomplicate initially; start with broader components and add further details (e.g., individual handlers and UI windows) in subsequent iterations.
- The separation between concerns (backend processes vs. frontend rendering) should be obvious. This clarity will also underline system dependencies like the MySQL configuration and environment-specific setups (such as Windows OS features).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Electron Application"
        subgraph "Main Process"
            MP_Entry["Entry Point (index.ts, main.d.ts)"]:::main
            MP_Assets["Assets Management"]:::main
            MP_Handlers["Handlers (database,device,files,quiz,screen,socket,updater,window)"]:::handler
            MP_Socket["Socket Handler (socket.ts)"]:::handler
            MP_Lib["Core Libraries (database-client,firewall,tray-menu,window-manager)"]:::main
        end

        subgraph "Renderer Process"
            RP_Assets["HTML & Assets (index.html)"]:::renderer
            RP_Components["React UI Components (activation-form,modals,notifications)"]:::renderer
            RP_UI["UI Elements (accordion,button,card,modal,etc)"]:::renderer
            RP_Windows["Application Windows (dashboard,main,quiz,setup,about)"]:::renderer
            RP_Lib["Client-side Libraries (api,preload,socket)"]:::renderer
            RP_Socket["Socket Provider Component"]:::renderer
        end
    end

    subgraph "External Services"
        DB_Prism["Prisma Schema (schema.prisma)"]:::database
        DB_Config["Database Config (database.ts)"]:::database
        SOCKET_SVC["Socket.IO Service"]:::external
    end

    %% Inter-Process Communication
    RP_Lib -->|"IPC"| MP_Handlers
    RP_Socket -->|"socketIPC"| MP_Socket

    %% Main Process to External Communications
    MP_Handlers -->|"prisma"| DB_Config
    MP_Socket -->|"Socket.IO"| SOCKET_SVC

    %% Renderer UI Flow
    RP_Assets --> RP_Components
    RP_Components --> RP_UI
    RP_UI --> RP_Windows
    RP_Windows --> RP_Lib
    RP_Lib -->|"socketAPI"| RP_Socket

    %% Main Process Internal Flow
    MP_Entry --> MP_Assets
    MP_Entry --> MP_Handlers
    MP_Entry --> MP_Lib

    %% Styles
    classDef main fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef handler fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef renderer fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px;

    %% Click Events
    click MP_Entry "https://github.com/juliusbiascan/eduinsight-client/blob/main/src/main/index.ts"
    click MP_Assets "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/main/assets"
    click MP_Handlers "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/main/handlers/"
    click MP_Socket "https://github.com/juliusbiascan/eduinsight-client/blob/main/src/main/handlers/socket.ts"
    click MP_Lib "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/main/lib/"
    click RP_Assets "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/renderer/assets"
    click RP_Components "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/renderer/components/"
    click RP_UI "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/renderer/components/ui/"
    click RP_Windows "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/renderer/windows/"
    click RP_Lib "https://github.com/juliusbiascan/eduinsight-client/tree/main/src/renderer/lib/"
    click RP_Socket "https://github.com/juliusbiascan/eduinsight-client/blob/main/src/renderer/components/socket-provider.tsx"
    click DB_Prism "https://github.com/juliusbiascan/eduinsight-client/blob/main/prisma/schema.prisma"
    click DB_Config "https://github.com/juliusbiascan/eduinsight-client/blob/main/src/shared/config/database.ts"
```
