# raazgupta239/iotbased-traffic-ambulance-navigation architecture

> Architecture diagram of the GitHub repository raazgupta239/iotbased-traffic-ambulance-navigation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raazgupta239/iotbased-traffic-ambulance-navigation
- Repository: https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation

## Overview

##### Project type and purpose
- From the file tree (App.js, index.js, navigation/, screens/, android/, ios/) and the README name (“ambulance-project”), this is a React Native mobile application whose purpose is to let users sign up / log in via OTP, view ambulance locations, chat with dispatch, and request ambulance services.
- Although the repository contains only the client code, the UX flows (LoginPage, VerifyOtp, HomePage, TrafficLocation, Chatbox, Dashboard) imply a backend architecture built as a suite of microservices (authentication, user profile, dispatch/dispatch-tracking, chat, notifications, external map/traffic).

##### File structure
- Top-level:
- App.js + index.js – application entry, root navigator and context provider
- navigation/TabNavigator.js – React Navigation setup, tab/stack definitions
- screens/… – individual UI screens implementing each flow
- userContext.js – global state management via React Context
- android/ & ios/ – native build wrappers, configuration, native modules (MainActivity, AppDelegate, splash assets)

##### README for additional insights
- README only gives the project name. We infer functionality from screen names:
- Login & SignUp → OTP verification
- Home & TrafficLocation → real-time map / traffic
- Chatbox → WebSocket or push chat
- Dashboard & Profile → user data, history

##### Detail
- React Native screen’s dependency on the API (e.g. VerifyOtp → OTP Service).
- Real-time flows (WebSocket) separately from REST calls.
- Error flows (e.g. failed authentication → retry OTP).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Client Layer
    subgraph "Mobile Client" 
        direction TB
        App["App.js"]:::client
        Index["index.js"]:::client
        subgraph "UI Layer"
            direction TB
            LoginPage["LoginPage.js"]:::client
            SignUpPage["SignUpPage.js"]:::client
            VerifyOtp["VerifyOtp.js"]:::client
            HomePage["HomePage.js"]:::client
            TrafficLocation["TrafficLocation.js"]:::client
            Chatbox["Chatbox.js"]:::client
            Dashboard["Dashboard.js"]:::client
            Profile["Profile.js"]:::client
            TabNavigator["TabNavigator.js"]:::client
        end
        UserContext["userContext.js"]:::client
        subgraph "Native Layer"
            direction TB
            AndroidManifest["AndroidManifest.xml"]:::client
            MainActivity["MainActivity.kt"]:::client
            MainApplication["MainApplication.kt"]:::client
            AndroidBuild["build.gradle"]:::client
            AppDelegateH["AppDelegate.h"]:::client
            AppDelegateMM["AppDelegate.mm"]:::client
            MainM["main.m"]:::client
            BridgingHeader["Bridging-Header.h"]:::client
            InfoPlist["Info.plist"]:::client
            SplashStoryboard["SplashScreen.storyboard"]:::client
            Podfile["Podfile"]:::client
            Images["Images.xcassets"]:::client
        end
    end

    %% API Gateway
    APIGateway["API Gateway / BFF"]:::service

    %% Microservices Layer
    subgraph "Microservices" 
        direction TB
        AuthService["Authentication Service"]:::service
        OTPService["OTP Service"]:::service
        UserProfileService["User Profile Service"]:::service
        DispatchService["Dispatch Service"]:::service
        LocationService["Location Service"]:::service
        ChatService["Chat Service"]:::service
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        PrimaryDB[(Primary DB)]:::data
        Cache[(Redis Cache)]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MapsAPI["Maps & Traffic API"]:::external
        SMSProvider["SMS Provider (Twilio)"]:::external
        PushService["Push Notification Service"]:::external
    end

    %% Connections
    App -->|"HTTPS REST"| APIGateway
    Index --> APIGateway
    LoginPage --> APIGateway
    SignUpPage --> APIGateway
    VerifyOtp --> APIGateway
    HomePage --> APIGateway
    TrafficLocation --> APIGateway
    Dashboard --> APIGateway
    Profile --> APIGateway
    TabNavigator --> APIGateway
    UserContext --> APIGateway

    App -->|"WS /chat"| ChatService
    Chatbox --> ChatService

    APIGateway -->|"POST /login (JWT)"| AuthService
    APIGateway -->|"POST /otp"| OTPService
    APIGateway -->|"GET/POST /user"| UserProfileService
    APIGateway -->|"POST /dispatch"| DispatchService
    APIGateway -->|"POST /location/update"| LocationService

    AuthService --> PrimaryDB
    UserProfileService --> PrimaryDB
    OTPService --> SMSProvider
    DispatchService --> PrimaryDB
    DispatchService --> Cache
    DispatchService --> PushService
    LocationService --> Cache
    LocationService --> MapsAPI
    DispatchService --> MapsAPI
    ChatService --> PrimaryDB

    %% Data Store to services fallback
    Cache --> DispatchService

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px

    %% Click Events
    click App "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/App.js"
    click Index "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/index.js"
    click LoginPage "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/LoginPage.js"
    click SignUpPage "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/SignUpPage.js"
    click VerifyOtp "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/VerifyOtp.js"
    click HomePage "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/HomePage.js"
    click TrafficLocation "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/TrafficLocation.js"
    click Chatbox "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/Chatbox.js"
    click Dashboard "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/Dashboard.js"
    click Profile "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/screens/Profile.js"
    click TabNavigator "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/navigation/TabNavigator.js"
    click UserContext "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/userContext.js"
    click AndroidManifest "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/android/app/src/main/AndroidManifest.xml"
    click MainActivity "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/android/app/src/main/java/com/myproject/reactnative/MainActivity.kt"
    click MainApplication "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/android/app/src/main/java/com/myproject/reactnative/MainApplication.kt"
    click AndroidBuild "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/android/app/build.gradle"
    click AppDelegateH "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/AppDelegate.h"
    click AppDelegateMM "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/AppDelegate.mm"
    click MainM "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/main.m"
    click BridgingHeader "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/mynewproject-Bridging-Header.h"
    click InfoPlist "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/Info.plist"
    click SplashStoryboard "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/SplashScreen.storyboard"
    click Podfile "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/tree/main/ios/Podfile"
    click Images "https://github.com/raazgupta239/iotbased-traffic-ambulance-navigation/blob/main/ios/mynewproject/Images.xcassets"
```
