# wili-201027/pdr_project_3 architecture

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

- Interactive diagram: https://gitdiagram.com/wili-201027/pdr_project_3
- Repository: https://github.com/wili-201027/pdr_project_3

## Overview

This is a React Native peer-to-peer messaging app, with job/offers and profile features alongside its core chat workflow. A user enters through authentication and app navigation; the app initializes P2P service for signed-in users, discovers peers, and supports encrypted message exchange with local message storage. The README also documents local discovery fallback and optional signaling. The source excerpts establish several app, chat, storage, and P2P relationships; other feature screens and networking internals are represented at their exact tree paths, but their internal calls were not sampled.

Main entry points: [`src/navigation/RootNavigator.tsx`](https://github.com/wili-201027/pdr_project_3/blob/main/src/navigation/RootNavigator.tsx) (App navigation), [`App.tsx`](https://github.com/wili-201027/pdr_project_3/blob/main/App.tsx) (App bootstrap), [`src/p2p/integrationExample.ts`](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/integrationExample.ts) (P2P service), [`src/contexts/AuthContext.ts`](https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/AuthContext.ts) (Authentication state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and navigation"]
  node_app["App bootstrap<br/>[App.tsx]"]
  node_nav["App navigation<br/>[RootNavigator.tsx]"]
  node_authui["Sign in and register<br/>[LoginScreen.tsx]"]
  node_jobui["Jobs and offers<br/>[HomeScreen.js]"]
  node_profileui["Profile and settings<br/>[ProfileScreen.js]"]
end

subgraph group_messaging["Messaging and storage"]
  node_chatui["Chat screen<br/>[ChatScreen.tsx]"]
  node_chatlist["Chat list<br/>[ChatListScreen.tsx]"]
  node_chatctx["Chat state<br/>[ChatContext.tsx]"]
  node_chatstore[("Chat and message store<br/>[localDb.ts]")]
  node_appstore[("App data helpers<br/>[localDb.ts]")]
  node_sync["Message synchronization<br/>[meshSync.ts]"]
end

subgraph group_network["P2P networking"]
  node_p2pservice["P2P service"]
  node_discovery["Peer discovery<br/>[discovery.ts]"]
  node_peer["WebRTC peer connections<br/>[peerManager.js]"]
  node_signaling["Signaling service<br/>[signalingServer.ts]"]
  node_e2ee["P2P encryption<br/>[e2ee.ts]"]
  node_trust[("Peer trust store<br/>[tofuStore.ts]")]
end

subgraph group_account["Account and security"]
  node_auth["Authentication state<br/>[AuthContext.ts]"]
  node_authutil["Session and key utilities<br/>[auth.ts]"]
  node_crypto["Key generation<br/>[crypto_e2e.ts]"]
end

subgraph group_experience["User experience"]
  node_access["Accessibility settings"]
  node_i18n["Translations<br/>[i18n.ts]"]
  node_theme["Theme system<br/>[ThemeContext.ts]"]
  node_notifications["Notifications"]
end

node_user(("App user"))
node_signalserver{{"Optional signaling server"}}

node_user -->|"opens"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"renders"| node_nav
node_app -->|"initializes"| node_p2pservice
node_app -->|"saves received messages"| node_appstore
node_app -->|"initializes"| node_notifications
node_nav -->|"routes to"| node_authui
node_nav -->|"routes to"| node_jobui
node_nav -->|"routes to"| node_profileui
node_nav -->|"routes to"| node_chatlist
node_chatlist -.->|"opens chat"| node_chatui
node_chatui -->|"reads and saves"| node_appstore
node_chatctx -->|"uses storage"| node_chatstore
node_chatctx -->|"uses sync"| node_sync
node_p2pservice -->|"uses connections"| node_peer
node_p2pservice -->|"uses encryption"| node_e2ee
node_p2pservice -.->|"discovers peers"| node_discovery
node_p2pservice -.->|"uses signaling"| node_signaling
node_signaling -.->|"connects optionally"| node_signalserver
node_p2pservice -.->|"verifies peers"| node_trust
node_user -.->|"authenticates"| node_authui
node_auth -->|"reads sessions"| node_authutil
node_auth -->|"generates keys"| node_crypto
node_auth -->|"reads profile"| node_appstore
node_access -->|"checks RTL language"| node_i18n
node_theme -->|"applies contrast"| node_access
node_nav -->|"reads theme"| node_theme
node_nav -->|"reads user state"| node_auth

click node_app "https://github.com/wili-201027/pdr_project_3/blob/main/App.tsx"
click node_nav "https://github.com/wili-201027/pdr_project_3/blob/main/src/navigation/RootNavigator.tsx"
click node_authui "https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/LoginScreen.tsx"
click node_jobui "https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/HomeScreen.js"
click node_profileui "https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ProfileScreen.js"
click node_chatui "https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ChatScreen.tsx"
click node_chatlist "https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ChatListScreen.tsx"
click node_chatctx "https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/ChatContext.tsx"
click node_chatstore "https://github.com/wili-201027/pdr_project_3/blob/main/src/lib/localDb.ts"
click node_appstore "https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/localDb.ts"
click node_sync "https://github.com/wili-201027/pdr_project_3/blob/main/src/lib/meshSync.ts"
click node_p2pservice "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/integrationExample.ts"
click node_discovery "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/discovery.ts"
click node_peer "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/peerManager.js"
click node_signaling "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/signalingServer.ts"
click node_e2ee "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/e2ee.ts"
click node_trust "https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/tofuStore.ts"
click node_auth "https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/AuthContext.ts"
click node_authutil "https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/auth.ts"
click node_crypto "https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/crypto_e2e.ts"
click node_access "https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/AccessibilityContext.ts"
click node_i18n "https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/i18n.ts"
click node_theme "https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/ThemeContext.ts"
click node_notifications "https://github.com/wili-201027/pdr_project_3/blob/main/src/notifications/initNotifications.ts"

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_app,node_nav,node_authui,node_jobui,node_profileui,node_user toneBlue
class node_chatui,node_chatlist,node_chatctx,node_chatstore,node_appstore,node_sync toneAmber
class node_p2pservice,node_discovery,node_peer,node_signaling,node_e2ee,node_trust,node_signalserver toneMint
class node_auth,node_authutil,node_crypto toneRose
class node_access,node_i18n,node_theme,node_notifications toneIndigo
```

## Components

### App and navigation

- [App bootstrap](https://github.com/wili-201027/pdr_project_3/blob/main/App.tsx): `App.tsx`
- [App navigation](https://github.com/wili-201027/pdr_project_3/blob/main/src/navigation/RootNavigator.tsx): `src/navigation/RootNavigator.tsx`
- [Sign in and register](https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/LoginScreen.tsx): `src/screens/LoginScreen.tsx`
- [Jobs and offers](https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/HomeScreen.js): `src/screens/HomeScreen.js`
- [Profile and settings](https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ProfileScreen.js): `src/screens/ProfileScreen.js`

### Messaging and storage

- [Chat screen](https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ChatScreen.tsx): `src/screens/ChatScreen.tsx`
- [Chat list](https://github.com/wili-201027/pdr_project_3/blob/main/src/screens/ChatListScreen.tsx): `src/screens/ChatListScreen.tsx`
- [Chat state](https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/ChatContext.tsx): `src/contexts/ChatContext.tsx`
- [Chat and message store](https://github.com/wili-201027/pdr_project_3/blob/main/src/lib/localDb.ts): `src/lib/localDb.ts`
- [App data helpers](https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/localDb.ts): `src/utils/localDb.ts`
- [Message synchronization](https://github.com/wili-201027/pdr_project_3/blob/main/src/lib/meshSync.ts): `src/lib/meshSync.ts`

### P2P networking

- [P2P service](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/integrationExample.ts): `src/p2p/integrationExample.ts`
- [Peer discovery](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/discovery.ts): `src/p2p/discovery.ts`
- [WebRTC peer connections](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/peerManager.js): `src/p2p/peerManager.js`
- [Signaling service](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/signalingServer.ts): `src/p2p/signalingServer.ts`
- [P2P encryption](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/e2ee.ts): `src/p2p/e2ee.ts`
- [Peer trust store](https://github.com/wili-201027/pdr_project_3/blob/main/src/p2p/tofuStore.ts): `src/p2p/tofuStore.ts`

### Account and security

- [Authentication state](https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/AuthContext.ts): `src/contexts/AuthContext.ts`
- [Session and key utilities](https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/auth.ts): `src/utils/auth.ts`
- [Key generation](https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/crypto_e2e.ts): `src/utils/crypto_e2e.ts`

### User experience

- [Accessibility settings](https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/AccessibilityContext.ts): `src/contexts/AccessibilityContext.ts`
- [Translations](https://github.com/wili-201027/pdr_project_3/blob/main/src/utils/i18n.ts): `src/utils/i18n.ts`
- [Theme system](https://github.com/wili-201027/pdr_project_3/blob/main/src/contexts/ThemeContext.ts): `src/contexts/ThemeContext.ts`
- [Notifications](https://github.com/wili-201027/pdr_project_3/blob/main/src/notifications/initNotifications.ts): `src/notifications/initNotifications.ts`

### Other components

- **App user**
- **Optional signaling server**

## Connections

- App user → App bootstrap: opens (evidence: `README.md`)
- App bootstrap → Authentication state: provides auth (evidence: `App.tsx`)
- App bootstrap → App navigation: renders (evidence: `App.tsx`)
- App bootstrap → P2P service: initializes (evidence: `App.tsx`)
- App bootstrap → App data helpers: saves received messages (evidence: `App.tsx`)
- App bootstrap → Notifications: initializes (evidence: `App.tsx`)
- App navigation → Sign in and register: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- App navigation → Jobs and offers: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- App navigation → Profile and settings: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- App navigation → Chat list: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Chat list → Chat screen: opens chat
- Chat screen → App data helpers: reads and saves (evidence: `src/screens/ChatScreen.tsx`)
- Chat state → Chat and message store: uses storage (evidence: `src/contexts/ChatContext.tsx`)
- Chat state → Message synchronization: uses sync (evidence: `src/contexts/ChatContext.tsx`)
- P2P service → WebRTC peer connections: uses connections (evidence: `src/p2p/integrationExample.ts`)
- P2P service → P2P encryption: uses encryption (evidence: `src/p2p/integrationExample.ts`)
- P2P service → Peer discovery: discovers peers
- P2P service → Signaling service: uses signaling
- Signaling service → Optional signaling server: connects optionally
- P2P service → Peer trust store: verifies peers
- App user → Sign in and register: authenticates
- Authentication state → Session and key utilities: reads sessions (evidence: `src/contexts/AuthContext.ts`)
- Authentication state → Key generation: generates keys (evidence: `src/contexts/AuthContext.ts`)
- Authentication state → App data helpers: reads profile (evidence: `src/contexts/AuthContext.ts`)
- Accessibility settings → Translations: checks RTL language (evidence: `src/contexts/AccessibilityContext.ts`)
- Theme system → Accessibility settings: applies contrast (evidence: `src/contexts/ThemeContext.ts`)
- App navigation → Theme system: reads theme (evidence: `src/navigation/RootNavigator.tsx`)
- App navigation → Authentication state: reads user state (evidence: `src/navigation/RootNavigator.tsx`)
