# prudhvir3ddy/rideshare architecture

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

- Interactive diagram: https://gitdiagram.com/prudhvir3ddy/rideshare
- Repository: https://github.com/prudhvir3ddy/rideshare

## Overview

##### Project type and purpose
- This is an Android “ride-sharing” (Uber/Lyft clone) mobile app built in Kotlin, using Google Maps/Directions/Places APIs to fetch and render routes, and employing a simulated WebSocket “backend” to deliver real-time vehicle data and booking events. It follows a basic Model-View-Presenter (MVP) pattern, split into two Gradle modules:
- app (the mobile client)
- simulator (the WebSocket server emulator)

##### File structure
Top-level:
- app/ – Android application module
– src/main/java/com/prudhvir3ddy/rideshare/ui/maps → MapsActivity (View), MapsPresenter, MapsView interface
– src/main/java/com/prudhvir3ddy/rideshare/data/network → NetworkService (WebSocket client abstraction)
– src/main/java/com/prudhvir3ddy/rideshare/utils → animation, permission, map helper classes
– res/ → layouts, drawables, values (UI assets & configuration)
- simulator/ – backend simulator module
– src/main/java/com/mindorks/ridesharing/simulator → Simulator (establishes WebSocket server behavior), WebSocket, WebSocketListener
- build scripts and Gradle wrappers

##### README for additional insights
- Features: “nearby cabs,” “pickup/drop selection,” “cab booking,” “live car animation,” “trip lifecycle (start/end),” all delivered over a simulated WebSocket API.
- Architecture: Explicitly uses MVP in the client, and a simple WebSocket protocol simulator on the server module.
- External dependencies: Google Maps SDK (map display), Directions API (route geometry), Places API (geocoding), Android FusedLocationProvider.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Mobile Client" 
        direction TB
        RSApp["RideShareApp"]:::mobile
        subgraph "UI Layer"
            direction TB
            MapsActivity["MapsActivity"]:::mobile
            MapsView["MapsView"]:::mobile
        end
        subgraph "Presenter Layer"
            direction TB
            MapsPresenter["MapsPresenter"]:::mobile
        end
        subgraph "Network/Data Layer"
            direction TB
            NetworkService["NetworkService"]:::mobile
        end
        subgraph "Utility Helpers"
            direction TB
            AnimationUtil["AnimationUtil"]:::mobile
            MapUtils["MapUtils"]:::mobile
            PermissionUtils["PermissionUtils"]:::mobile
            ViewUtils["ViewUtils"]:::mobile
            Constants["Constants"]:::mobile
        end
    end

    subgraph "Simulator Module" 
        direction TB
        Simulator["Simulator"]:::server
        WebSocket["WebSocket"]:::server
        WebSocketListener["WebSocketListener"]:::server
    end

    subgraph "External Services"
        direction TB
        GoogleMaps["Google Maps SDK"]:::external
        DirectionsAPI["Directions API"]:::external
        PlacesAPI["Places API"]:::external
    end

    %% User interaction
    User[/"User"/] -->|"tap UI event"| MapsActivity
    MapsActivity -->|"implements MapsView"| MapsView

    %% MVP flow
    MapsActivity -->|"forward event"| MapsPresenter
    MapsPresenter -->|"invoke WebSocket calls"| NetworkService
    MapsPresenter -->|"call REST route"| DirectionsAPI
    DirectionsAPI -->|"return polyline points"| MapsPresenter
    MapsPresenter -->|"update overlays"| MapsActivity

    %% WebSocket communication
    NetworkService -->|"openWebSocket()"| Simulator
    Simulator -->|"acceptConnection()"| NetworkService
    Simulator -->|"emit JSON events"| NetworkService
    NetworkService -->|"onMessage() parse JSON"| MapsPresenter

    %% External SDK
    MapsActivity -->|"render markers, polylines"| GoogleMaps
    MapsPresenter -->|"geocode/place data"| PlacesAPI

    %% Click events
    click MapsActivity "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/ui/maps/MapsActivity.kt"
    click MapsPresenter "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/ui/maps/MapsPresenter.kt"
    click MapsView "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/ui/maps/MapsView.kt"
    click NetworkService "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/data/network/NetworkService.kt"
    click RSApp "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/RideShareApp.kt"
    click AnimationUtil "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/utils/AnimationUtil.kt"
    click MapUtils "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/utils/MapUtils.kt"
    click PermissionUtils "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/utils/PermissionUtils.kt"
    click ViewUtils "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/utils/ViewUtils.kt"
    click Constants "https://github.com/prudhvir3ddy/rideshare/blob/master/app/src/main/java/com/prudhvir3ddy/rideshare/utils/Constants.kt"
    click Simulator "https://github.com/prudhvir3ddy/rideshare/blob/master/simulator/src/main/java/com/mindorks/ridesharing/simulator/Simulator.kt"
    click WebSocket "https://github.com/prudhvir3ddy/rideshare/blob/master/simulator/src/main/java/com/mindorks/ridesharing/simulator/WebSocket.kt"
    click WebSocketListener "https://github.com/prudhvir3ddy/rideshare/blob/master/simulator/src/main/java/com/mindorks/ridesharing/simulator/WebSocketListener.kt"

    classDef mobile fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef server fill:#d4edda,stroke:#333,stroke-width:1px
    classDef external fill:#ffe5b4,stroke:#333,stroke-width:1px
```
