# h1mzy0ti/gps-x architecture

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

- Interactive diagram: https://gitdiagram.com/h1mzy0ti/gps-x
- Repository: https://github.com/h1mzy0ti/gps-x

## Overview

##### Key architectural components
- Hardware Module: This includes the ESP12F microcontroller code (written in C) dealing with GPS and GSM functionalities. Files such as gpsX_esp12F.c, gpsX_esp12f_wifi.c, and neo6_test.c in the "src/hardware" directory illustrate the low-level firmware element. This module interacts with the SIM800 GSM module and the NEO-6 GPS module.
- Mobile App: Found in "src/app" (with files such as main.dart, AndroidManifest.xml, and pubspec.yaml), this component is likely built using Flutter/Dart. It provides the user interface for real-time location display, remote control (e.g., enabling/disabling anti-theft mode), and historical route playback.
- Server: Located under "src/server" (server.py, start_server.sh), the server-side logic handles receiving and logging GPS coordinates, storing data for route playback, handling OTA updates, and potentially alert configurations.

##### Depicting Relationships and Data Flow
- Server to Mobile App Communication: The server processes incoming data and then provides it to the mobile app for display and user interaction. Additionally, it might also send commands back to the hardware (for OTA updates or alert configurations).
- Mobile App as the User Interface: Clearly separate the mobile app’s responsibilities; it receives display data, enables features (such as anti-theft mode), and allows route playback.
- Additional flows for external communications (e.g., SMS alerts) that may be triggered based on pre-defined geolocation rules.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separate the three layers (hardware, server, and mobile app) to highlight modular responsibilities.
- Real-time Communication: Emphasize that the design supports real-time data updates from the hardware to the server and then to the mobile interface.
- Power/Energy Management: The hardware component’s focus on different operating modes (Active vs. Light Sleep) should be visually noted.
- Extensibility: Note the potential for OTA updates and configurable alert mechanisms as part of the system’s design.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Hardware Layer
    subgraph "Hardware Layer"
        HW_Main["GPS Tracker Hardware\n(ESP12F + SIM800 + NEO-6)"]:::hardware
        subgraph "Firmware Files"
            HW1["gpsX_esp12F.c"]:::hardware
            HW2["gpsX_esp12f_wifi.c"]:::hardware
            HW3["neo6_test.c"]:::hardware
        end
    end

    %% Server Layer
    subgraph "Server Layer"
        SV_Main["Data & Command Server\n(Python)"]:::server
        subgraph "Server Files"
            SV1["server.py"]:::server
            SV2["start_server.sh"]:::server
            SV3["Note.txt"]:::server
        end
    end

    %% Mobile App Layer
    subgraph "Mobile App Layer"
        MA_Main["Flutter Mobile Application\n(Android)"]:::mobile
        subgraph "App Files"
            MA1["main.dart"]:::mobile
            MA2["AndroidManifest.xml"]:::mobile
            MA3["pubspec.yaml"]:::mobile
            MA4["assets"]:::mobile
            MA5["info.txt"]:::mobile
        end
    end

    %% Data Flow Connections
    HW_Main -->|"SendGPSData"| SV_Main
    SV_Main -->|"RealTimeData"| MA_Main
    MA_Main -->|"CommandsOTA"| SV_Main
    SV_Main -->|"OTA/Alerts"| HW_Main

    %% Click Events for Hardware Files
    click HW1 "https://github.com/h1mzy0ti/gps-x/blob/main/src/hardware/gpsX_esp12F.c"
    click HW2 "https://github.com/h1mzy0ti/gps-x/blob/main/src/hardware/gpsX_esp12f_wifi.c"
    click HW3 "https://github.com/h1mzy0ti/gps-x/blob/main/src/hardware/neo6_test.c"

    %% Click Events for Server Files
    click SV1 "https://github.com/h1mzy0ti/gps-x/blob/main/src/server/server.py"
    click SV2 "https://github.com/h1mzy0ti/gps-x/blob/main/src/server/start_server.sh"
    click SV3 "https://github.com/h1mzy0ti/gps-x/blob/main/src/server/Note.txt"

    %% Click Events for Mobile App Files
    click MA1 "https://github.com/h1mzy0ti/gps-x/blob/main/src/app/main.dart"
    click MA2 "https://github.com/h1mzy0ti/gps-x/blob/main/src/app/AndroidManifest.xml"
    click MA3 "https://github.com/h1mzy0ti/gps-x/blob/main/src/app/pubspec.yaml"
    click MA4 "https://github.com/h1mzy0ti/gps-x/tree/main/src/app/assets"
    click MA5 "https://github.com/h1mzy0ti/gps-x/blob/main/src/app/info.txt"

    %% Styles
    classDef hardware fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef mobile fill:#87CEFA,stroke:#333,stroke-width:2px;
```
