# doanh-dinh-7/hrms-basic-web-and-mobile-platform architecture

> Architecture diagram of the GitHub repository doanh-dinh-7/hrms-basic-web-and-mobile-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform
- Repository: https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform

## Overview

##### Project Type and Purpose
- The project is a full-stack HR management system aimed at managing employee information, payroll, and timekeeping.
- There are multiple clients:
- A mobile application (Android) located under the HRMS_Mobile directory.
- A web application (ReactJS) under the frontend directory.
- A Python Flask backend (API server) found in the backend directory.
- A SQL Server database with setup scripts under the database folder.

##### Analyzing the File Structure
- Mobile Application (HRMS_Mobile):
- Built with Java for Android.
- Contains clear module separations such as activities (UI screens), fragments (modular UI components), adapters (for bridging data and views), models (data classes), network (Retrofit API service), and utility classes.
- Backend Application:
- Developed in Python using Flask.
- Organized into application entry point (app.py), models (which define data structures like departments, employees, payroll, etc.), and routes (grouped endpoints for each module: employee, department, payslip, etc.).
- The requirements file and .env configuration ensure database connectivity and dependency management.
- Frontend Application:
- Built with ReactJS and configured with Vite.
- Contains structured directories for pages, components (laying out UI elements for Attendance, Employees, Payroll), controllers, and routing.
- Environmental configuration (with .env) connects the frontend to the backend API.

a. Main Components:
- Mobile App (Android)
- Package components like Activities, Fragments, Adapters, Models, and Network service.
- Integration with external APIs (using Retrofit for REST API calls).
- Web Frontend (ReactJS)
- UI components (components in the lib directory), pages, routing, and controller layers.
- Connection through an API Base URL (configured via .env).
- Backend API (Flask)
- Main Flask server (app.py) and segregated modules for different functional areas (routes and models).
- Endpoints (e.g., /employee, /department, /payslip, /timekeeping) that the front and mobile apps consume.
- Database (SQL Server)
- SQL Server database which is externally configured per the README.
- That database scripts (ScriptTaoDatabase.sql and TaoDataDump.sql) are used to initialize the HRMS DB.

b. Relationships and Interactions:
- The Mobile App communicates with the Backend API to perform CRUD operations.
- The Web Frontend interacts with the Backend API (via HTTP REST calls).
- The Backend API handles requests and interacts with the SQL Server database.
- Optionally, include a link back to the ERD provided in the README to show data relationships.
- Incorporate descriptions of request and response flows (e.g., from user actions in the mobile/web UI to backend processing and then to the database).

c. Architectural Patterns and Design Principles:
- Use a layered (n-tier) approach:
- Presentation Layer: Mobile application (Android) and Web Frontend (ReactJS).
- Application Layer: API backend (Flask) that handles business logic, routing, and integration.
- Data Layer: SQL Server database where persistent data is stored.
- For the mobile app, note the Model-View-Controller (MVC) like pattern present in activities, fragments, adapters, and network classes.
- For the backend, highlight the modularization of routes and models, reflecting separation of concerns.
- For the frontend, the structured directories (components, pages, controllers) indicate a component-based architecture common in React projects.

d. Relevant Technologies and Frameworks:
- Mobile: Java (Android), Retrofit (for network API calls), XML for layout design.
- Backend: Python, Flask, and related libraries listed in requirements.txt.
- Frontend: ReactJS, Vite for bundling, Node.js as runtime, and ESLint for code quality.
- Database: SQL Server (with configuration details in the README).

##### Detail
- Don’t hesitate to add subcomponents where needed (e.g., breaking down the mobile app into its activities, fragments, and network module; listing the package grouping in the backend if it helps clarify routing and models; outlining the key React components and pages in the frontend).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App (Android)"
        A1["Activities"]:::mobile
        A2["Fragments"]:::mobile
        A3["Adapters"]:::mobile
        A4["Models"]:::mobile
        A5["Network Service"]:::mobile
        A6["Utility Classes"]:::mobile
    end

    subgraph "Web Frontend (ReactJS)"
        F1["Pages"]:::frontend
        F2["UI Components"]:::frontend
        F3["Controllers"]:::frontend
        F4["Routing"]:::frontend
        F5["Environmental Configurations"]:::frontend
    end

    subgraph "Backend API (Flask)"
        B1["Application Entry Point (app.py)"]:::backend
        B2["Data Models"]:::backend
        B3["API Routes"]:::backend
    end

    subgraph "SQL Server Database"
        DS1["ScriptTaoDatabase.sql"]:::database
        DS2["TaoDataDump.sql"]:::database
    end

    %% Connections
    A1 -->|"HTTP_Request"| B3
    F1 -->|"HTTP_Request"| B3
    B3 -->|"Data_Query"| DS1

    %% Click Events for Mobile App
    click A1 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/activity/"
    click A2 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/fragment/"
    click A3 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/adapter/"
    click A4 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/model/"
    click A5 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/network/"
    click A6 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/HRMS_Mobile/app/src/main/java/com/example/hrms_mobile/util/"

    %% Click Events for Web Frontend
    click F1 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/frontend/src/pages/"
    click F2 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/frontend/src/lib/components/"
    click F3 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/frontend/src/lib/controller/"
    click F4 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/frontend/src/lib/router/"
    click F5 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/blob/main/frontend/.env"

    %% Click Events for Backend API
    click B1 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/blob/main/backend/app.py"
    click B2 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/backend/models/"
    click B3 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/tree/main/backend/routes/"

    %% Click Events for SQL Server Database Setup Scripts
    click DS1 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/blob/main/database/ScriptTaoDatabase.sql"
    click DS2 "https://github.com/doanh-dinh-7/hrms-basic-web-and-mobile-platform/blob/main/database/TaoDataDump.sql"

    %% Styles
    classDef mobile fill:#a2d2ff,stroke:#1e6091,stroke-width:2px;
    classDef frontend fill:#ffc6ff,stroke:#a100a0,stroke-width:2px;
    classDef backend fill:#caffbf,stroke:#40916c,stroke-width:2px;
    classDef database fill:#ffadad,stroke:#f94144,stroke-width:2px;
```
