You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-71Lines changed: 90 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,101 +1,127 @@
1
1
# Off Chat: A Decentralized Digital Concierge
2
2
### Bachelor Thesis Project | CTU FEE, Prague
3
3
4
-
**Off Chat** is an offline-first, peer-to-peer communication platform built with Flutter. It utilizes Bluetooth Low Energy (BLE) to enable device discovery, relative location tracking (Radar), and secure messaging without any reliance on internet or cellular connectivity.
4
+
**Off Chat** is an offline-first, peer-to-peer decentralized communication platform built with Flutter. It utilizes Bluetooth Low Energy (BLE) to enable instant device discovery, relative location tracking (Radar), and secure messaging without any reliance on internet, cellular connectivity, or central infrastructure.
5
5
6
-
This project was developed as part of a Bachelor Thesis at the **Czech Technical University in Prague (CTU), Faculty of Electrical Engineering (FEE)**.
6
+
This project was developed as part of a Bachelor Thesis in Open Informatics at the **Czech Technical University in Prague (CTU), Faculty of Electrical Engineering (FEE)**.
7
7
8
8
---
9
9
10
10
## 🌟 Key Features
11
11
12
-
-**The Nodes (Discovery):** Real-time scanning of nearby active devices. Displays user profiles (avatar, alias) and proximity metadata.
13
-
-**The Radar (Location):** A custom-painted visualization showing the relative bearing and distance of peers using a combination of GPS coordinates and device compass data.
14
-
-**Off-Grid Messaging:** Reliable text and media exchange (images up to 512x512) over BLE GATT characteristics.
15
-
-**Identity Protocol:** Secure local profile management with automated image compression and background synchronization.
16
-
-**Aurelian Noir Aesthetic:** A premium "Digital Concierge" design system featuring deep black surfaces, gold primary accents, and fluid geometry.
12
+
### 📡 Zero-read Identification Protocol
13
+
-**Instant Discovery:** Avoids the high overhead of establishing GATT connections for simple identification. Nearby active devices are discovered and verified immediately upon capturing a single advertisement packet.
14
+
-**Cache-Hit Proximity:** If a peer's `stableId` is already cached locally and their `versionTag` hasn't changed, they are instantly visualized on the radar without any active radio transmission.
15
+
16
+
### 🗺️ Custom-Painted Location Radar
17
+
-**Relative Proximity Canvas:** A gorgeous, custom-painted radar visualization showing the relative bearing and distance of peers in real-time.
18
+
-**Sensor Fusion:** Merges high-precision GPS coordinates from the `geolocator` package with active compass data from `flutter_compass` to correctly rotate and render neighboring nodes relative to the user's orientation.
19
+
20
+
### ⚡ Dual-role Mesh Topography (Store & Forward)
21
+
-**Central + Peripheral:** Each device runs simultaneous BLE Central (scanning/connecting) and BLE Peripheral (advertising/serving) roles using coordinated asynchronous timers.
22
+
-**Background Persistence:** Utilizes a dedicated foreground service isolate on Android to ensure continuous mesh operations and location updates, even when the OS is under heavy memory pressure.
23
+
24
+
### 🛣️ Intelligent Mesh Routing Engines
25
+
-**Directed Beam Routing (Geographic LAR):** When geographic locations are available, the app calculates a weighted *Forwarding Score* based on angular deviation (bearing via sférická trigonometrie) and RSSI signal strength. Messages are selectively routed towards the destination, reducing radio traffic by up to 65%.
26
+
-**Starburst Routing (Flooding):** Used as a fallback when geographic data is unavailable. Floods the network with a strict 10-hop Time-To-Live (TTL) limit and duplicate message deduplication via local cache.
27
+
-**Breadcrumb ACK Tracking:** ACKs travel back along the reversed paths of the messages, updating delivery states deterministically.
28
+
29
+
### 🛡️ End-to-End Cryptography (Security Level 4)
30
+
-**Key Exchange:** Secure, local key exchange using **X25519 Diffie-Hellman** curves during first-contact synchronization.
31
+
-**Symmetric Encryption:** All subsequent message payloads are encrypted end-to-end using **ChaCha20-Poly1305 AEAD** to ensure confidentiality, integrity, and authenticity.
32
+
33
+
### 📦 Chunked Transfer Engine
34
+
-**Dynamic MTU Adaptation:** An abstract chunking protocol that dynamically resizes data chunks (from standard 23 bytes up to 512 bytes) based on MTU values negotiated during connection.
35
+
-**Profile Synchronization:** Seamlessly streams and reconstructs larger data files, such as custom profile pictures, over BLE GATT characteristics.
36
+
37
+
### 🎨 Aurelian Noir Aesthetics
38
+
-**Digital Concierge Style:** Premium dark UI designed to feel prestigious and elegant.
39
+
-**Visual Palette:** Deep obsidian black background surfaces (`#131313`) with subtle textures, radiant gold accents (`#F2CA50`), fluid glassmorphic cards, custom typography (Plus Jakarta Sans/Outfit), and smooth bento-grid layouts.
17
40
18
41
---
19
42
20
43
## 🏗 Architecture
21
44
22
-
The project follows a **Feature-First Architecture**, ensuring high cohesion and low coupling between modules. Each feature is self-contained with its own Presentation, Domain, and Data layers.
45
+
The project follows a rigorous **Domain-Driven Design (DDD) Feature-First Architecture**, keeping features modular, highly cohesive, and loosely coupled.
│ └── notifications/# Background local notification service
37
60
└── app.dart # Root Material application
38
61
```
39
62
40
63
---
41
64
42
-
## 🛰 The Off-Chat Protocol
65
+
## 🛰 The Off-Chat BLE Protocol
66
+
67
+
To overcome BLE advertisement limits (31 bytes) and iOS background constraints, Off Chat splits data transmission between the primary packet and the scan response.
43
68
44
-
To overcome standard BLE advertisement limits (31 bytes) and iOS background restrictions, this project implements a **Hybrid Discovery Strategy**:
-**Bytes 1-4:** Profile Hash (Deterministic CRC32 of username/avatar).
50
-
-**Bytes 5-8:** Latitude (Float32).
51
-
-**Bytes 9-12:** Longitude (Float32).
77
+
### 2. Scan Response Packet (12 Bytes)
78
+
Dispatched only when requested by active scanners to conserve battery:
79
+
-**Bytes 0-2 (24 bits):**`Latitude` compressed to a 24-bit fixed-point integer.
80
+
-**Bytes 3-5 (24 bits):**`Longitude` compressed to a 24-bit fixed-point integer.
81
+
-**Bytes 6-11 (6 bytes):**`Full Profile Hash` for cryptographically verifying user identity.
52
82
53
-
### 2. Hybrid Strategy
54
-
-**Primary Advertisement:** Broadcasts only the Service UUID and essential flags to minimize packet size and maximize discovery reliability (especially for iOS background).
55
-
-**Scan Response:** The 13-byte custom metadata is moved to the Scan Response packet.
56
-
-**Local Name:** Disabled to free up primary advertisement bandwidth.
57
-
-**Background (iOS):** When Scan Response data is stripped by the OS, the app initiates a **silent GATT connection** to read the "Identity Characteristic," fetching the 13-byte payload before disconnecting.
83
+
### 3. iOS Background Fallback
84
+
iOS strips Manufacturer Data from advertisement packets when in the background. Off Chat handles this gracefully:
85
+
- When a background node is detected without manufacturer data, the Central node initiates a **silent GATT connection** to read the designated `identityCharUuid` characteristic.
86
+
- It extracts the same 5-byte and 12-byte metadata blocks and disconnects immediately, preserving battery.
58
87
59
-
### 3. Intelligent Motion (Flight Mode)
60
-
To ensure stability in high-speed environments (airplanes, fast trains), the protocol implements **Adaptive Throttling**:
61
-
-**Normal Mode (< 72 km/h):** Updates location and restarts advertising every **10 meters**.
62
-
-**High-Speed Mode (≥ 72 km/h):** Switches to a stable **2-minute timer**, ignoring distance changes. This prevents rapid Bluetooth stack resets and allows peers a reliable window to connect.
63
-
-**Heartbeat:** Forced update every **5 minutes** even if the device is stationary.
88
+
### 4. Throttled Heartbeat (Energy Conservation)
89
+
Continuous scanning and advertising is resource-heavy. Off Chat utilizes **Adaptive Throttling**:
90
+
-**Stationary State:** If the user is sitting still, the advertiser sleeps and restarts advertising only every **300 seconds** (Heartbeat) to maintain connection tables.
91
+
-**Motion State:** When a change of **111 meters** or movement from physical sensors is detected, advertising rates instantly spike to maximum frequency to facilitate rapid handshake loops.
0 commit comments