# danielbcarvalho/taxi-app-react-native architecture

> Architecture diagram of the GitHub repository danielbcarvalho/taxi-app-react-native, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danielbcarvalho/taxi-app-react-native
- Repository: https://github.com/danielbcarvalho/taxi-app-react-native

## Overview

##### Project type and purpose
- This is a full‐stack mobile application (“WeTaxi”) built in React Native.
- Purpose: connect taxi drivers and passengers in real time, using a Socket.io server for live location/ride events and an Express REST API for authentication and data persistence.

##### File structure
- Top‐level folders:
- android/ and ios/ – native platform projects and configuration
- components/ – reusable UI components (forms, containers, buttons)
- screens/ – top‐level React Native screens (Login, SignUp, Passenger, Driver)
- __tests__/ – Jest tests for UI and logic
- Config files: babel.config.js, metro.config.js, .eslintrc.js – build, bundling, linting
- BaseUrl.js – client configuration for REST and Socket endpoints
- Third‐party native modules under node_modules (background geolocation, maps, navigation)

##### README for additional insights
- Two external services:
- Socket.io Server (real-time events)
- Express + MongoDB REST API (auth, user data, ride control)
- Uses Google Maps API for geocoding and route rendering
- React Navigation for in‐app routing
- Background geolocation for driver tracking

a. Main components:
- Mobile Client (React Native App)
– UI Layer: screens & components
– Service Layer: API client (Axios) and Socket.io client
– Native Modules: React Native Maps, Background Geolocation, Linear Gradient
- REST API Backend (Express + MongoDB)
- Real‐time Server (Socket.io)
- External Services: Google Maps Platform (Directions, Geocoding)
- Data Store: MongoDB
b. Relationships and interactions:
1. User opens app → React Navigation routes to Login / SignUp screens
2. Client uses Axios → sends HTTP requests to REST API for auth
3. Once authenticated: client opens Socket.io connection → real‐time channel for ride events
4. Passenger picks origin/destination → React Native Maps + Google APIs compute & render routes
5. Driver listens on Socket.io → receives ride requests, accepts → triggers route update
6. Driver background geolocation module reports location events → published via Socket.io → passenger view updates
7. All persistent data (users, trip records) stored/fetched from MongoDB via Express API
c. Architectural patterns & principles:
- Component‐based UI (separation of concerns between screens & shared components)
- Service abstraction: centralized baseUrl.js for endpoint configuration
- Event‐driven design for real‐time flows (Socket.io)
- Clear separation of mobile vs. backend responsibilities
d. Key technologies & libraries:
- React Native, React Navigation, Axios, Socket.io-client
- @mauron85/react-native-background-geolocation
- react-native-maps, @mapbox/polyline
- Express, Socket.io, Mongoose (MongoDB), Google Maps API

##### Essential details
- How authentication state flows from REST API into enabling real‐time channels
- Passenger → driver event flow: ride request → acceptance → location updates

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client Layer
    subgraph "Mobile Client" 
        direction TB
        MCApp["App.js"]:::mobile
        MCIndex["index.js"]:::mobile
        subgraph "UI Layer" 
            direction TB
            LoginScreen["Login Screen"]:::mobile
            SignUpScreen["SignUp Screen"]:::mobile
            RoleSelectScreen["DriverOrPassenger Screen"]:::mobile
            PassengerScreen["Passenger Screen"]:::mobile
            DriverScreen["Driver Screen"]:::mobile
            subgraph "Reusable Components"
                direction TB
                LoginForm["LoginForm"]:::mobile
                SignUpForm["SignUpForm"]:::mobile
                BottomButton["BottomButton"]:::mobile
                GenericContainer["GenericContainer"]:::mobile
            end
        end
        subgraph "Native Modules" 
            direction TB
            RNMaps["react-native-maps"]:::native
            BackgroundGeo["Background Geolocation"]:::native
            LinearGrad["Linear Gradient"]:::native
        end
    end

    %% Client Services
    subgraph "Client Services" 
        direction TB
        BaseUrl["baseUrl.js"]:::service
        GoogleKey["google_api_key.js"]:::service
        AxiosClient["Axios HTTP Client"]:::service
        SocketClient["Socket.io Client"]:::service
    end

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        RESTAPI["Express REST API"]:::backend
        SocketServer["Socket.io Server"]:::backend
    end

    %% Data & External APIs
    subgraph "Data & External APIs"
        direction TB
        MongoDB["MongoDB"]:::database
        GoogleMaps["Google Maps Platform"]:::external
    end

    %% Testing & Configurations
    subgraph "Config & Testing"
        direction TB
        MetroConfig["metro.config.js"]:::service
        BabelConfig["babel.config.js"]:::service
        ESLintConfig[".eslintrc.js"]:::service
        JestTests["App-test.js"]:::service
        FakeGPS["fakeLocation.gpx"]:::service
        TaskDef["Task"]:::service
        AndroidProj["android/"]:::native
        IOSProj["ios/"]:::native
    end

    %% Connections
    MCApp -->|"imports"| MCIndex
    MCApp -->|"uses"| LoginScreen
    MCApp -->|"uses"| SignUpScreen
    MCApp -->|"uses"| RoleSelectScreen
    MCApp -->|"uses"| PassengerScreen
    MCApp -->|"uses"| DriverScreen

    LoginScreen -->|"renders"| LoginForm
    SignUpScreen -->|"renders"| SignUpForm

    MCApp -->|"configures"| BaseUrl
    MCApp -->|"configures"| GoogleKey
    MCApp -->|"initiates"| AxiosClient
    MCApp -->|"opens"| SocketClient

    AxiosClient -->|"HTTP/HTTPS"| RESTAPI
    SocketClient -->|"WebSocket"| SocketServer

    PassengerScreen -->|"calls"| RNMaps
    PassengerScreen -->|"calls"| GoogleMaps
    BackgroundGeo -->|"native"| AndroidProj
    BackgroundGeo -->|"native"| IOSProj

    SocketServer -->|"stores/fetches"| MongoDB
    RESTAPI -->|"stores/fetches"| MongoDB
    RESTAPI -->|"uses"| GoogleMaps

    %% Click Events
    click MCApp "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/App.js"
    click MCIndex "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/index.js"
    click LoginScreen "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/screens/Login.js"
    click SignUpScreen "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/screens/SignUp.js"
    click RoleSelectScreen "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/screens/DriverOrPassenger.js"
    click PassengerScreen "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/screens/Passenger.js"
    click DriverScreen "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/screens/Driver.js"
    click LoginForm "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/components/LoginForm.js"
    click SignUpForm "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/components/SignUpForm.js"
    click BottomButton "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/components/BottomButton.js"
    click GenericContainer "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/components/GenericContainer.js"
    click BaseUrl "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/baseUrl.js"
    click GoogleKey "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/google_api_key.js"
    click AndroidProj "https://github.com/danielbcarvalho/taxi-app-react-native/tree/main/android/"
    click IOSProj "https://github.com/danielbcarvalho/taxi-app-react-native/tree/main/ios/"
    click MetroConfig "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/metro.config.js"
    click BabelConfig "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/babel.config.js"
    click ESLintConfig "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/.eslintrc.js"
    click JestTests "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/__tests__/App-test.js"
    click FakeGPS "https://github.com/danielbcarvalho/taxi-app-react-native/blob/main/fakeLocation.gpx"
    click TaskDef "https://github.com/danielbcarvalho/taxi-app-react-native/tree/main/Task"

    %% Styles
    classDef mobile fill:#BBDEFB,stroke:#1E88E5,color:#000
    classDef native fill:#F8BBD0,stroke:#C2185B,color:#000
    classDef service fill:#B3E5FC,stroke:#0288D1,color:#000
    classDef backend fill:#C8E6C9,stroke:#43A047,color:#000
    classDef database fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef external fill:#EEEEEE,stroke:#757575,color:#000
```
