# nguyenminhquan004/quanlythuexe architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenminhquan004/quanlythuexe
- Repository: https://github.com/nguyenminhquan004/quanlythuexe

## Overview

##### Project Type and Purpose
- The project is a full-stack mobile application for renting motorbikes – “Cho-Thu-Xe”. The application supports functionalities such as vehicle management, reservation, return & payment, notifications, and value-added services.

##### File Structure
- There are two main parts:
- The mobile frontend in the “loginapp” directory built with React Native (with JS/TS files, Screens, assets, and components).
- The backend (Node.js) inside the “backend” folder, including service scripts (e.g., package.json, script.sql) that support RESTful APIs, payment integration, and database operations.
- Additional support files (e.g., Expo configuration in the .expo directory, Visual Studio Code settings) indicate modern mobile development practices.

##### Main Components
a. Frontend Mobile Application:
- Represented by the “loginapp” folder.
- Functional screens—such as Login (DangNhap), Registration (DangKy), Home, Company Details, and user-specific screens.
- Integration of QR code scanning for vehicle check-in/check-out.
- Mention the role of third-party services (maps, payment integrations, momo SDK).
b. Backend Server:
- The Node.js server (in “backend”) handling the business logic.
- Handles RESTful APIs processing vehicle management, reservations, notifications, and payments.
- Dependency on the SQL database (configured via “script.sql”).
c. Data Store:
- A SQL database (MySQL) maintaining vehicle data, user accounts, booking logs, invoices, and additional metadata for insurance, equipment, and services.
d. External Services:
- Payment gateway integrations (momo sdk, electronic wallet systems).
- Services for determining vehicle locations.
- Possibly a third-party notification service (for push notifications, email, or SMS).

##### Relationships and Interactions
- Data flows for user actions, such as vehicle search, reservations, verification (via QR scan), and payment processing.
- A two-way communication where backend sends notifications and updates to the application (e.g., rental status updates, booking confirmations).
- That the backend interacts directly with the SQL database and external service APIs.

##### Architectural Patterns and Design Principles
- Separation of concerns:
- UI (React Native screens) vs. business logic (Node.js backend).
- Clear layering: presentation, API/middleware, and data persistence.
- Use of RESTful APIs.
- That the mobile app leverages Expo for rapid development and deployment.
- The use of micro- or modular services can be stressed if additional services (i.e., Notification, Payment, Vehicle management) are treated as separate modules within the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Frontend
    subgraph "Mobile Frontend"
        direction TB
        MA["Mobile App (React Native)"]:::frontend

        subgraph "App Entry Points"
            direction TB
            appjs["App.js"]:::entry
            aptsx["App.tsx"]:::entry
            appnav["AppNavigator.js"]:::entry
        end
        MA --> appjs
        MA --> aptsx
        MA --> appnav

        subgraph "Screens"
            direction TB
            DN["DangNhap Screen"]:::screen
            DK["DangKy Screen"]:::screen
            CD["Company Details Screen"]:::screen
            HS["Home Screen"]:::screen
            HS2["Hoi So Screen"]:::screen
        end
        MA --> DN
        MA --> DK
        MA --> CD
        MA --> HS
        MA --> HS2

        Expo["Expo Mobile Support"]:::support
        MA --> Expo
    end

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        BA["Backend API (Node.js)"]:::backend

        subgraph "Configuration Files"
            direction TB
            pkg["package.json"]:::config
            pkgLock["package-lock.json"]:::config
            sqlFile["script.sql"]:::config
        end
        BA --> pkg
        BA --> pkgLock
        BA --> sqlFile
    end

    %% SQL Database
    SQL["SQL Database (MySQL)"]:::database

    %% External Services
    subgraph "External Services"
        direction TB
        Payment["Payment Gateway (momo sdk)"]:::external
        Maps["Mapping Service"]:::external
        Notification["Notification Service"]:::external
    end

    %% Relationships
    MA -->|"API_call"| BA
    BA -->|"DB_ops"| SQL
    BA -->|"Integrates_with"| Payment
    BA -->|"Integrates_with"| Maps
    BA -->|"Integrates_with"| Notification
    BA -->|"Push_notif"| MA

    %% Click Events for Mobile App
    click MA "https://github.com/nguyenminhquan004/quanlythuexe/tree/master/loginapp"
    click appjs "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/App.js"
    click aptsx "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/App.tsx"
    click appnav "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/AppNavigator.js"
    click DN "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/Screens/DangNhap.js"
    click DK "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/Screens/DangKy.js"
    click CD "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/Screens/CompanyDetails.js"
    click HS "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/Screens/HomeScreen.js"
    click HS2 "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/loginapp/Screens/HoiSo.js"
    click Expo "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/.expo"

    %% Click Events for Backend API
    click BA "https://github.com/nguyenminhquan004/quanlythuexe/tree/master/backend"
    click pkg "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/backend/package.json"
    click pkgLock "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/backend/package-lock.json"
    click sqlFile "https://github.com/nguyenminhquan004/quanlythuexe/blob/master/backend/script.sql"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#1E90FF,stroke-width:2px;
    classDef entry fill:#B3E283,stroke:#228B22,stroke-width:2px;
    classDef screen fill:#C3FDB8,stroke:#32CD32,stroke-width:2px;
    classDef support fill:#F0E68C,stroke:#DAA520,stroke-width:2px;
    classDef backend fill:#FFC0CB,stroke:#FF69B4,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#FFD700,stroke-width:2px;
    classDef database fill:#FFE4B5,stroke:#FF8C00,stroke-width:2px;
    classDef external fill:#E6E6FA,stroke:#9370DB,stroke-width:2px;
```
