# dimig031/tms-mobile-app architecture

> Architecture diagram of the GitHub repository dimig031/tms-mobile-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dimig031/tms-mobile-app
- Repository: https://github.com/dimig031/tms-mobile-app

## Overview

TMS Mobile is an Expo/React Native client for drivers using an existing TMS REST API. Drivers sign in, then use a dashboard to reach active and upcoming tours; tour workflows include status actions, checklists, stops, expenses and documents. Separate areas cover chat, profile, notifications, work tasks and travel orders. The internal layer combines query hooks, an authenticated API client, secure session storage and queued offline writes. Some feature paths are documented but their source was not sampled, so those links are limited to README evidence.

Main entry points: [`src/lib/api.ts`](https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/api.ts) (API client), [`app/(driver)/index.tsx`](https://github.com/dimig031/tms-mobile-app/blob/main/app/(driver)/index.tsx) (Driver dashboard), [`app/(driver)/tours`](https://github.com/dimig031/tms-mobile-app/tree/main/app/(driver)/tours) (Tour workflows), [`src/providers/AuthProvider.tsx`](https://github.com/dimig031/tms-mobile-app/blob/main/src/providers/AuthProvider.tsx) (Auth session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["Driver workflows"]
  node_dashboard["Driver dashboard<br/>[index.tsx]"]
  node_tourviews["Tour workflows"]
  node_expenses["Expense sheets<br/>[useExpenseSheet.ts]"]
  node_documents["Driver documents<br/>[useDocuments.ts]"]
  node_chat["Driver chat<br/>[useChat.ts]"]
  node_tasksorders["Tasks and travel orders<br/>[useWorkTasks.ts]"]
  node_places["Driver places<br/>[useDriverPlaces.ts]"]
end

subgraph group_account["Account and experience"]
  node_login["Sign in<br/>[login.tsx]"]
  node_auth["Auth session<br/>[AuthProvider.tsx]"]
  node_authservice["Auth service<br/>[auth.ts]"]
  node_profile["Driver profile"]
end

subgraph group_data["Data and persistence"]
  node_sessionstore[("Secure session<br/>[secure-store.ts]")]
  node_tourqueries["Tour data hooks<br/>[useTours.ts]"]
  node_api["API client<br/>[api.ts]"]
  node_offline["Offline write queue<br/>[offline-queue.ts]"]
  node_querycache[("Persisted query cache<br/>[QueryProvider.tsx]")]
end

subgraph group_device["Device services"]
  node_notifications["Notifications<br/>[notifications.ts]"]
  node_gps["GPS tracking<br/>[gpsTracking.ts]"]
end

node_driver(("Driver"))
node_tmsapi{{"TMS REST API"}}
node_push{{"Push service"}}

node_driver -->|"signs in"| node_login
node_login -->|"submits credentials"| node_auth
node_auth -->|"delegates auth"| node_authservice
node_authservice -->|"stores session"| node_sessionstore
node_authservice -->|"logs in"| node_tmsapi
node_auth -->|"stops on logout"| node_gps
node_auth -->|"manages push token"| node_notifications
node_auth -->|"checks activation"| node_api
node_driver -->|"opens"| node_dashboard
node_dashboard -->|"loads tours"| node_tourqueries
node_dashboard -->|"loads chat data"| node_chat
node_dashboard -->|"loads expenses"| node_expenses
node_dashboard -->|"opens tour"| node_tourviews
node_tourviews -.->|"loads tour data"| node_tourqueries
node_tourviews -->|"manages expenses"| node_expenses
node_tourviews -->|"manages documents"| node_documents
node_driver -->|"uses messaging"| node_chat
node_chat -->|"requests chat data"| node_api
node_driver -->|"views profile"| node_profile
node_profile -->|"loads profile"| node_api
node_driver -->|"receives alerts"| node_notifications
node_notifications -->|"registers token"| node_api
node_notifications -->|"registers device"| node_push
node_driver -->|"manages work"| node_tasksorders
node_driver -.->|"finds driver places"| node_places
node_tourviews -->|"tracks transit"| node_gps
node_gps -->|"queues GPS logs"| node_api
node_expenses -->|"writes expense data"| node_api
node_documents -->|"writes metadata"| node_api
node_api -->|"sends requests"| node_tmsapi
node_api -->|"reads and refreshes token"| node_sessionstore
node_api -->|"queues offline writes"| node_offline
node_querycache -->|"persists query data"| node_driver

click node_login "https://github.com/dimig031/tms-mobile-app/blob/main/app/(auth)/login.tsx"
click node_auth "https://github.com/dimig031/tms-mobile-app/blob/main/src/providers/AuthProvider.tsx"
click node_authservice "https://github.com/dimig031/tms-mobile-app/blob/main/src/services/auth.ts"
click node_sessionstore "https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/secure-store.ts"
click node_dashboard "https://github.com/dimig031/tms-mobile-app/blob/main/app/(driver)/index.tsx"
click node_tourviews "https://github.com/dimig031/tms-mobile-app/tree/main/app/(driver)/tours"
click node_tourqueries "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useTours.ts"
click node_expenses "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useExpenseSheet.ts"
click node_documents "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useDocuments.ts"
click node_chat "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useChat.ts"
click node_profile "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useMobileProfile.ts"
click node_notifications "https://github.com/dimig031/tms-mobile-app/blob/main/src/services/notifications.ts"
click node_gps "https://github.com/dimig031/tms-mobile-app/blob/main/src/services/gpsTracking.ts"
click node_tasksorders "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useWorkTasks.ts"
click node_places "https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useDriverPlaces.ts"
click node_api "https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/api.ts"
click node_offline "https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/offline-queue.ts"
click node_querycache "https://github.com/dimig031/tms-mobile-app/blob/main/src/providers/QueryProvider.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_tourviews,node_expenses,node_documents,node_chat,node_tasksorders,node_places toneBlue
class node_login,node_auth,node_authservice,node_profile toneAmber
class node_sessionstore,node_tourqueries,node_api,node_offline,node_querycache,node_tmsapi toneMint
class node_notifications,node_gps toneRose
class node_driver,node_push toneIndigo
```

## Components

### Driver workflows

- [Driver dashboard](https://github.com/dimig031/tms-mobile-app/blob/main/app/(driver)/index.tsx): `app/(driver)/index.tsx`
- [Tour workflows](https://github.com/dimig031/tms-mobile-app/tree/main/app/(driver)/tours): `app/(driver)/tours`
- [Expense sheets](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useExpenseSheet.ts): `src/queries/useExpenseSheet.ts`
- [Driver documents](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useDocuments.ts): `src/queries/useDocuments.ts`
- [Driver chat](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useChat.ts): `src/queries/useChat.ts`
- [Tasks and travel orders](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useWorkTasks.ts): `src/queries/useWorkTasks.ts`
- [Driver places](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useDriverPlaces.ts): `src/queries/useDriverPlaces.ts`

### Account and experience

- [Sign in](https://github.com/dimig031/tms-mobile-app/blob/main/app/(auth)/login.tsx): `app/(auth)/login.tsx`
- [Auth session](https://github.com/dimig031/tms-mobile-app/blob/main/src/providers/AuthProvider.tsx): `src/providers/AuthProvider.tsx`
- [Auth service](https://github.com/dimig031/tms-mobile-app/blob/main/src/services/auth.ts): `src/services/auth.ts`
- [Driver profile](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useMobileProfile.ts): `src/queries/useMobileProfile.ts`

### Data and persistence

- [Secure session](https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/secure-store.ts): `src/lib/secure-store.ts`
- [Tour data hooks](https://github.com/dimig031/tms-mobile-app/blob/main/src/queries/useTours.ts): `src/queries/useTours.ts`
- [API client](https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Offline write queue](https://github.com/dimig031/tms-mobile-app/blob/main/src/lib/offline-queue.ts): `src/lib/offline-queue.ts`
- [Persisted query cache](https://github.com/dimig031/tms-mobile-app/blob/main/src/providers/QueryProvider.tsx): `src/providers/QueryProvider.tsx`

### Device services

- [Notifications](https://github.com/dimig031/tms-mobile-app/blob/main/src/services/notifications.ts): `src/services/notifications.ts`
- [GPS tracking](https://github.com/dimig031/tms-mobile-app/blob/main/src/services/gpsTracking.ts): `src/services/gpsTracking.ts`

### Other components

- **Driver**
- **TMS REST API**
- **Push service**

## Connections

- Driver → Sign in: signs in
- Sign in → Auth session: submits credentials (evidence: `app/(auth)/login.tsx`)
- Auth session → Auth service: delegates auth (evidence: `src/providers/AuthProvider.tsx`)
- Auth service → Secure session: stores session (evidence: `src/services/auth.ts`)
- Auth service → TMS REST API: logs in (evidence: `src/services/auth.ts`)
- Auth session → GPS tracking: stops on logout (evidence: `src/providers/AuthProvider.tsx`)
- Auth session → Notifications: manages push token (evidence: `src/providers/AuthProvider.tsx`)
- Auth session → API client: checks activation (evidence: `src/providers/AuthProvider.tsx`)
- Driver → Driver dashboard: opens
- Driver dashboard → Tour data hooks: loads tours (evidence: `app/(driver)/index.tsx`)
- Driver dashboard → Driver chat: loads chat data (evidence: `app/(driver)/index.tsx`)
- Driver dashboard → Expense sheets: loads expenses (evidence: `app/(driver)/index.tsx`)
- Driver dashboard → Tour workflows: opens tour (evidence: `app/(driver)/index.tsx`)
- Tour workflows → Tour data hooks: loads tour data (evidence: `app/(driver)/tours/index.tsx`)
- Tour workflows → Expense sheets: manages expenses (evidence: `app/(driver)/tours/[id]/expense.tsx`)
- Tour workflows → Driver documents: manages documents
- Driver → Driver chat: uses messaging
- Driver chat → API client: requests chat data (evidence: `src/queries/useChat.ts`)
- Driver → Driver profile: views profile
- Driver profile → API client: loads profile (evidence: `src/queries/useMobileProfile.ts`)
- Driver → Notifications: receives alerts
- Notifications → API client: registers token (evidence: `src/services/notifications.ts`)
- Notifications → Push service: registers device (evidence: `src/services/notifications.ts`)
- Driver → Tasks and travel orders: manages work
- Driver → Driver places: finds driver places
- Tour workflows → GPS tracking: tracks transit
- GPS tracking → API client: queues GPS logs (evidence: `src/services/gpsTracking.ts`)
- Expense sheets → API client: writes expense data (evidence: `src/queries/useExpenseSheet.ts`)
- Driver documents → API client: writes metadata
- API client → TMS REST API: sends requests (evidence: `src/lib/api.ts`)
- API client → Secure session: reads and refreshes token (evidence: `src/lib/api.ts`)
- API client → Offline write queue: queues offline writes (evidence: `src/lib/api.ts`)
- Persisted query cache → Driver: persists query data (evidence: `src/providers/QueryProvider.tsx`)
