A peer-to-peer mesh networking application for off-grid communication, built with Ionic, React, and Capacitor.
ResQLink is a mobile application designed to provide a reliable and secure communication platform in emergency situations where traditional network infrastructure is unavailable. It leverages mesh networking technology to create a decentralized, peer-to-peer network of mobile devices, allowing users to send messages, share their location, and broadcast emergency alerts without relying on cellular or internet connectivity.
- Offline Messaging: Send and receive text messages, photos, and voice notes in a completely off-grid environment.
 - E2E Encryption: All communications are end-to-end encrypted using TweetNaCl.js, ensuring that only the intended recipients can read the messages.
 - Location Sharing: Share your real-time location with your contacts or broadcast it in an emergency.
 - Emergency SOS: Broadcast emergency alerts to all nearby users, providing critical information to first responders and other users in the area.
 - Resource Mapping: View a map of nearby resources, such as shelters, medical facilities, and water sources, added by other users.
 
- Frontend: Ionic React
 - Mobile: Capacitor
 - Cryptography: TweetNaCl.js
 - Mapping: MapLibre GL JS
 - State Management: Zustand
 
Maturity: Core features are complete, and the project is currently in the production readiness phase. The focus is on improving stability, documentation, and preparing for app store deployment.
- Node.js: v18.x or higher
 - npm: v8.x or higher
 - Android Studio: For Android development
 - Xcode: For iOS development
 
- 
Clone the repository:
git clone https://github.com/your-username/ResQLink.git cd ResQLink - 
Install dependencies:
npm install
 - 
Environment Setup:
No environment variables are required for the standard build.
 - 
Platform-Specific Setup:
- 
Android
- Open the 
androiddirectory in Android Studio. - Sync the project with Gradle files.
 
 - Open the 
 - 
iOS
- 
Run the following command to sync the project:
npx cap sync ios
 - 
Open the project in Xcode:
npx cap open ios
 
 - 
 
 - 
 
To start the development server, run:
npm run devThis will open the app in your browser. Changes to the source code will be reflected in real-time.
- 
Unit Tests: Run unit tests with the following command:
npm run test.unit
 - 
End-to-End (E2E) Tests: Run E2E tests with Cypress:
npm run test.e2e
 
To create a production build, run:
npm run buildThis will generate a dist folder with the optimized and minified assets.
- 
Syncing with Native Projects:
After making changes to the web code, you need to sync it with the native projects:
npx cap sync
 - 
Opening Native IDEs:
- 
Android Studio:
npx cap open android
 - 
Xcode:
npx cap open ios
 
 - 
 
- Browser: Use the browser's developer tools for debugging the web app.
 - Android: Use Android Studio's Logcat for native Android debugging.
 - iOS: Use Xcode's console for native iOS debugging.
 
+----------------------------------------------------+
|                 ResQLink Mobile App                |
+----------------------------------------------------+
|                  UI (Ionic/React)                  |
|----------------------------------------------------|
|      State Management (Zustand) & Services         |
|----------------------------------------------------|
|      Capacitor (Native Bridge) & Mesh Manager      |
+----------------------------------------------------+
|      Native Layer (Android/iOS) & P2P Network      |
+----------------------------------------------------+
The application is structured into the following main components:
src/components: Reusable React components used throughout the application, such asChatInterface,EmergencyContacts, andResourceMap.src/pages: Top-level pages for each tab in the application, such asMessagesPage,ResourcesPage, andTab3(Settings).src/services: Core services that handle business logic, such asLocationServiceandEmergencyBroadcastService.src/lib: Core libraries and utilities, including cryptography (crypto.ts), data schemas (schema.ts), state management (store.ts), and the mesh networking manager (mesh.ts).
The mesh networking is managed by the MeshManager class, which is responsible for:
- Discovering nearby peers.
 - Establishing and maintaining connections.
 - Broadcasting and relaying messages.
 
All messages are end-to-end encrypted using TweetNaCl.js. The encryption flow is as follows:
- A symmetric key is generated for each message.
 - The message content is encrypted with the symmetric key.
 - The symmetric key is then encrypted for each recipient using their public key (X25519).
 - The encrypted message and the encrypted symmetric keys (key envelopes) are broadcast to the network.
 
State management is handled by Zustand, a small, fast, and scalable state-management solution. The store (src/lib/store.ts) holds the application state, including messages, contacts, and the mesh network status.
The service layer contains the core business logic of the application:
LocationService: Manages GPS location tracking and provides location updates to the rest of the application.EmergencyBroadcastService: Handles the creation and broadcasting of emergency alerts.
The messaging system allows users to send and receive text messages, photos, and voice notes. All messages are end-to-end encrypted and transmitted over the mesh network.
Users can capture photos and videos directly within the app and share them with their contacts. The camera integration is built using the Capacitor Camera plugin.
Users can share their real-time location with their contacts. This feature is powered by the LocationService, which uses the device's GPS to obtain location data.
The emergency broadcast system allows users to send SOS alerts to all nearby users. These alerts are given high priority and are designed to be seen by as many people as possible.
Users can add, edit, and delete contacts. They can also create groups to send messages to multiple people at once.
The settings page allows users to configure the application, including their display name, language, and location sharing preferences.
Contributions are welcome! Please follow these guidelines when contributing to the project.
This project uses Prettier for code formatting. Please run npm run lint before submitting a pull request to ensure your code conforms to the project's style.
Please follow the Conventional Commits specification for your commit messages.
- Fork the repository.
 - Create a new branch for your feature or bug fix.
 - Make your changes and commit them with a descriptive commit message.
 - Push your changes to your fork.
 - Create a pull request to the 
mainbranch of the original repository. 
Please ensure that your changes do not break any existing tests. If you are adding a new feature, please include unit tests for that feature.
If you find a bug, please open an issue on the GitHub repository. Please include a clear and concise description of the bug, as well as steps to reproduce it.