# mateuszserafin/glovobot architecture

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

- Interactive diagram: https://gitdiagram.com/mateuszserafin/glovobot
- Repository: https://github.com/mateuszserafin/glovobot

## Overview

##### Project type and purpose
- This is an open-source Java-based CLI tool (“GlovoBOT”) that automates booking courier slots on Glovo’s Android API by reverse-engineering the official app.
- Its core responsibility is to log in, generate or spoof a device ID, schedule or revoke shifts via HTTP calls, and optionally bypass emulator checks.

##### File structure
- Top level
- build.gradle, gradlew/gradlew.bat, settings.gradle → standard Gradle build and wrapper
- src/main/java/com/gmail/genek530 → Java source package
- sample-images → README illustrations (not part of runtime)
- In src/main/java/com/gmail/genek530:
- Main.java → entry point, orchestrates tasks
- commons/ → utility code: response parsing, URL construction, generic utilities
- tasks/ → individual functional modules: Login.java, deviceID.java, revoke.java, schedule.java
- userContainer.java → domain model for courier account data
- No database; interactions are purely HTTP calls to Glovo’s backend.

##### README for additional insights
- Describes reverse-engineering steps (apktool, smali modifications, networkSecurityConfig) → these are developer-side setup steps, not runtime components.
- Emphasizes ability to update the code when Glovo changes its API.

##### Main components
- A. Command-Line Interface (CLI) / User
- B. Bot Orchestrator (Main.java)
- C. Task Modules (login, deviceID, schedule, revoke)
- D. Commons Library (urlHelper, response, utils)
- E. External Service: Glovo Courier API

##### Relationships and interactions
- User → submits commands to CLI
- Main.java → parses user input and delegates to a Task Module
- Task Modules → use commons.urlHelper to build HTTP requests
- HTTP requests → sent over the network to Glovo’s API endpoints
- Responses → parsed by commons.response, turned into user-readable output

##### Architectural patterns and design principles
- Modular tasks pattern: each high-level interaction (login, deviceID, schedule, revoke) is encapsulated in its own class.
- Separation of concerns: request construction (urlHelper), response parsing (response), generic utilities (utils) are factored out of business logic.
- Single executable JAR (via Gradle) with no external persistence; stateless HTTP interactions.

- [ ] Place “User / CLI” on the far left, “Glovo API” on the far right.
- [ ] In the center stack, vertically arrange:
- Main.java (orchestrator)
- Commons library modules below or alongside
- From CLI to Main.java
- From Main.java to each Task module
- From Task modules to Commons.urlHelper/response
- From Commons.urlHelper out to Glovo API
- [ ] Annotate each module with its purpose (e.g. “Login.java – handles authentication token exchange”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Invocation"
        CLI["User CLI"]:::internal
    end

    subgraph "Core"
        Main["Main.java\n(Orchestrator)"]:::internal

        subgraph "Task Modules"
            Login["Login.java\nhandles authentication"]:::internal
            deviceID["deviceID.java\ngenerates/spoofs device ID"]:::internal
            schedule["schedule.java\nschedules shifts"]:::internal
            revoke["revoke.java\nrevokes shifts"]:::internal
        end

        subgraph "Commons Library"
            urlHelper["urlHelper.java\nURL Construction"]:::internal
            response["response.java\nResponse Parsing"]:::internal
            utils["utils.java\nUtilities"]:::internal
        end

        userContainer["userContainer.java\ncourier account model"]:::internal
    end

    API["Glovo Courier API"]:::external

    Dev["Developer Setup\nAndroid Emulator + MITM Proxy"]:::developer

    subgraph "Build & Packaging"
        Packaging["Gradle Wrapper & Build Scripts"]:::internal
    end

    CLI -->|"command"| Main
    Main -->|"delegates to"| Login
    Main -->|"delegates to"| deviceID
    Main -->|"delegates to"| schedule
    Main -->|"delegates to"| revoke

    Login -->|"uses"| urlHelper
    deviceID -->|"uses"| urlHelper
    schedule -->|"uses"| urlHelper
    revoke -->|"uses"| urlHelper

    Login -->|"parses"| response
    deviceID -->|"parses"| response
    schedule -->|"parses"| response
    revoke -->|"parses"| response

    urlHelper -->|"HTTP request"| API
    API -->|"JSON response"| response

    response -->|"parsed data"| Main
    Main -->|"output"| CLI

    Dev -.->|"offline analysis"| Login
    Dev -.->|"offline analysis"| deviceID
    Dev -.->|"offline analysis"| schedule
    Dev -.->|"offline analysis"| revoke

    Main --> Packaging

    click Main "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/Main.java"
    click Login "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/tasks/Login.java"
    click deviceID "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/tasks/deviceID.java"
    click schedule "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/tasks/schedule.java"
    click revoke "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/tasks/revoke.java"
    click urlHelper "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/commons/urlHelper.java"
    click response "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/commons/response.java"
    click utils "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/commons/utils.java"
    click userContainer "https://github.com/mateuszserafin/glovobot/blob/main/src/main/java/com/gmail/genek530/userContainer.java"
    click Packaging "https://github.com/mateuszserafin/glovobot/blob/main/build.gradle"

    classDef internal fill:#a2fca2,stroke:#333,stroke-width:1px
    classDef external fill:#a2c8f4,stroke:#333,stroke-width:1px
    classDef developer fill:#fce78d,stroke:#333,stroke-width:1px
```
