# jatin-purbia/jarsafari architecture

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

- Interactive diagram: https://gitdiagram.com/jatin-purbia/jarsafari
- Repository: https://github.com/jatin-purbia/jarsafari

## Overview

##### Project type and purpose
- JARSafari is a React Native mobile application (iOS/Android) for campus navigation, tailored to IIT Jodhpur.
- It packages both the native Android wrapper (android/…) and the JavaScript/TypeScript UI and business logic in the “Frontend/app” tree.
- There is no in-repo backend service—routing and map data come from external OpenStreetMap-based services (OSMR).

##### File structure
- Top-level “Frontend/android” holds the native Android project (MainActivity.kt, build.gradle, resources).
- “Frontend/app” contains the React Native entrypoint and Routes (Next.js-style, though for a native app).
- /(auth), /(tabs), screens, components, data, services, store, utils, theme
- “services” subdivides into API clients, location wrappers (GPS), and local storage (favorites).
- “store” uses Redux (actions, reducers, selectors) for state management.
- Configuration/build files: babel.config.js, metro.config.js, tailwind.config.js, tsconfig.json, package.json.
- Assets (animations, fonts, images) and tests/docs directories support UI and developer workflows.

##### README for insights
- Key features: multi-stop planning, live GPS, favorites, trie autocomplete, dynamic time-aware map.
- Backend routing: uses OSMR + Dijkstra/A* implemented in the app or via an OSMR API.
- Performance goals: caching, adjacency-list graph, sub-50 ms routing, 40% speed gain.

a. Main components
- Mobile Device (Android/iOS)
– React Native JS layer
· UI Components (screens, nav tabs, auth flows)
· State Management (Redux store)
· Business Logic (routing engine, time-aware filtering, autocomplete trie)
· Services
· Location Service (GPS, geolocation API)
· Storage Service (AsyncStorage/SQLite for favorites & cached routes)
· API Client (OSMR requests for map/routing data)
– Native Bridge (React Native → Android/iOS modules)
– Native Android host (MainActivity, Application)
- External Services
– OpenStreetMap Routing (OSMR) API or custom routing server
– (Optional) Map Tiles Provider (e.g., OpenStreetMap or Mapbox)
– (Optional) Analytics/Error-tracking (e.g., Sentry)
b. Relationships & interactions
1. User taps UI → Redux action dispatched
2. Middleware invokes Services →
- Location API returns current GPS coordinates
- API Client fetches route segments from OSMR
- Routing engine (Dijkstra/A*) processes graph and returns optimized multi-stop path
- Storage Service caches routes/favorites
3. Store updates → UI re-renders map view and directions
c. Architectural patterns & principles
- Modular separation (UI / state / services / utils)
- Unidirectional data flow (Redux)
- Single Responsibility per folder (services vs. utils vs. store)
- Caching layer for performance
d. Key technologies & frameworks
- React Native (JS/TS, Metro bundler)
- Native Android (Kotlin) host
- Redux for state management
- TailwindCSS/nativewind for styling
- OpenStreetMap Routing (OSMR)
- Dijkstra/A* algorithm library or custom implementation
- AsyncStorage/SQLite for persistence

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Native host
  subgraph "Native Android Host"
    direction TB
    MainActivity["MainActivity.kt"]:::native
    MainApplication["MainApplication.kt"]:::native
  end

  %% React Native JS layer
  subgraph "React Native JS Layer"
    direction TB
    Entrypoint["index.jsx"]:::ui
    Layout["_layout.jsx"]:::ui

    subgraph "UI Components" 
      direction TB
      subgraph "Auth Flows"
        direction TB
        AuthLayout["(auth)/_layout.jsx"]:::ui
        Login["login.jsx"]:::ui
        CreateAccount["create-account.jsx"]:::ui
        ForgotPass["forgot-pass.jsx"]:::ui
        ResetPass["reset-pass.jsx"]:::ui
        VerifyEmail["verifyemail.jsx"]:::ui
      end
      subgraph "Tab Navigation"
        direction TB
        TabsLayout["(tabs)/_layout.jsx"]:::ui
        Homepage["Homepage.jsx"]:::ui
        SearchTab["search.jsx"]:::ui
        ProfileTab["profile.jsx"]:::ui
      end
      subgraph "Primary Screens"
        direction TB
        MapScreen["Mapscreen.jsx"]:::ui
        Locations["Locations.jsx"]:::ui
        ComingSoon["ComingSoon.jsx"]:::ui
        About["about.jsx"]:::ui
        Favorites["favorites.jsx"]:::ui
        UserInfo["user-info.jsx"]:::ui
        Contact["contact.jsx"]:::ui
      end
      Loader["loader.jsx"]:::ui
    end

    DataModule["locationData.js"]:::data

    subgraph "Services Layer"
      direction TB
      LocationService["Location Service"]:::service
      APIClient["API Client"]:::service
      StorageService["Storage Service"]:::service
    end

    subgraph "State Management (Redux)"
      direction TB
      Store["Redux Store"]:::persistence
      Actions["Actions"]:::service
      Reducers["Reducers"]:::service
      Selectors["Selectors"]:::service
    end

    subgraph "Business Logic / Utils"
      direction TB
      RoutingEngine["Routing Engine\n(Dijkstra/A*)"]:::service
      AutocompleteTrie["Autocomplete Trie"]:::service
    end

  end

  %% External services
  subgraph "External Services"
    direction TB
    OSMR["OSMR Routing API"]:::external
    MapTiles["Map Tiles Provider"]:::external
    Analytics["Analytics / Sentry"]:::external
  end

  %% Data stores
  CacheDB["AsyncStorage / SQLite"]:::persistence

  %% Data flow
  User["User Interaction"]:::user
  User -->|taps UI| Entrypoint
  Entrypoint --> Layout
  Layout --> AuthLayout
  Layout --> TabsLayout
  Layout --> MapScreen

  MapScreen -->|dispatch action| Actions
  Actions --> Store
  Store --> Reducers
  Reducers --> Store
  Store --> Selectors
  Selectors -->|get state| MapScreen

  Actions -->|invoke| LocationService
  Actions -->|invoke| APIClient
  Actions -->|invoke| RoutingEngine
  Actions -->|invoke| StorageService

  LocationService -->|GPS coords| Store
  APIClient -->|GET /route?stops=…| OSMR
  OSMR -->|route data| APIClient
  RoutingEngine -->|compute path| Store
  StorageService -->|cache data| CacheDB
  CacheDB -->|cache hit| Store

  MapScreen -->|render map| MapTiles

  %% Bridge between JS and Native
  Entrypoint -->|"Metro bundler"| MainActivity
  MainActivity -->|React Native Bridge| Entrypoint

  %% Click events
  click MainActivity "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/android/app/src/main/java/com/iitianvibes/Frontend/MainActivity.kt"
  click MainApplication "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/android/app/src/main/java/com/iitianvibes/Frontend/MainApplication.kt"
  click Entrypoint "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/index.jsx"
  click Layout "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/_layout.jsx"
  click AuthLayout "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/_layout.jsx"
  click Login "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/login.jsx"
  click CreateAccount "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/create-account.jsx"
  click ForgotPass "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/forgot-pass.jsx"
  click ResetPass "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/reset-pass.jsx"
  click VerifyEmail "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(auth)/verifyemail.jsx"
  click TabsLayout "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(tabs)/_layout.jsx"
  click Homepage "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(tabs)/Homepage.jsx"
  click SearchTab "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(tabs)/search.jsx"
  click ProfileTab "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/(tabs)/profile.jsx"
  click MapScreen "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/Mapscreen.jsx"
  click Locations "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/Locations.jsx"
  click ComingSoon "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/ComingSoon.jsx"
  click About "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/about.jsx"
  click Favorites "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/favorites.jsx"
  click UserInfo "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/user-info.jsx"
  click Contact "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/contact.jsx"
  click Loader "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/components/loader.jsx"
  click DataModule "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app/data/locationData.js"
  click AssetsAnimations "https://github.com/jatin-purbia/jarsafari/tree/backend/Frontend/assets/Animations"
  click AssetsView "https://github.com/jatin-purbia/jarsafari/tree/backend/Frontend/assets/app_view"
  click AssetsFonts "https://github.com/jatin-purbia/jarsafari/tree/backend/Frontend/assets/fonts"
  click AssetsImages "https://github.com/jatin-purbia/jarsafari/tree/backend/Frontend/assets/images"
  click BabelConfig "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/babel.config.js"
  click MetroConfig "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/metro.config.js"
  click TailwindConfig "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/tailwind.config.js"
  click Tsconfig "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/tsconfig.json"
  click PackageJson "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/package.json"
  click AppJson "https://github.com/jatin-purbia/jarsafari/blob/backend/Frontend/app.json"

  %% Styles
  classDef ui fill:#D0E8FF,stroke:#2B6CB0,color:#2B6CB0
  classDef service fill:#DFFFE0,stroke:#2F855A,color:#2F855A
  classDef persistence fill:#FFF4E6,stroke:#DD6B20,color:#DD6B20
  classDef native fill:#E2E8F0,stroke:#4A5568,color:#4A5568
  classDef external fill:#F9FAFB,stroke:#A0AEC0,color:#A0AEC0
  class User user
  classDef user fill:#FFE3E3,stroke:#C53030,color:#C53030
```
