How sahibjotsb/naloxnow works
Project Type & Purpose
• This is a mobile-first application built with React Native and Expo (as seen in the “app” folder, app.json, and usage of "npx expo start") and it integrates with cloud services like Firebase and Google APIs.
• The app features real-time tracking for naloxone kit locations, automated emergency workflows (including 911 calls via Orkes Constructor), live map displays, and an AI-powered chatbot for overdose advice using the Gemini API.
• It also includes native Android code (inside the “android” folder) and cloud functions (in the “functions” directory) to support backend processes.
Analyzing the File Structure
• The top-level “NaloxoneFinderApp” directory contains configuration files (.babelrc, .eslintrc.js, package.json, tsconfig.json), which indicate code styling, transpiling, and type-checking set up.
• The “app” folder suggests the main mobile application interface with React Native pages (using TypeScript and TSX files for layouts and screens) that follow a navigation pattern.
• The “android” directory contains the native code and configurations for the Android build, demonstrating that there is native layer support.
• The “functions” directory indicates the use of Firebase Cloud Functions, which likely handle server-side logic for emergency automation workflows and integration with external APIs.
• The “src” folder holds configuration (firebase configs) and navigation/page logic, reinforcing a separation of concerns between configuration, routing, and UI.
• Additional directories like “components”, “hooks”, and “scripts” reinforce modular design for UI components, custom hooks (e.g., useColorScheme), and project setup utilities.
Core Components
a. Mobile Client:
• React Native app which serves as the user interface. Highlight the “app” directory with navigation (pages like HomeScreen, MapScreen, ChatbotScreen) and UI components (in “components”).
• Native integrations like the “android” folder which configures the Android build and resources.
b. Backend Services:
• Firebase Integration: Represent Firebase (Firestore, Authentication, Storage, etc.) as the primary data store and backend provider. Note that firebase configurations are in “src/config/firebase.js” and project settings exist in firebase.json.
• Cloud Functions: Represent the “functions” directory that handles backend logic. This layer probably manages real-time updates, automated emergency workflow triggers (like sending alerts and making 911 calls), and image processing/integration with external Google Vision APIs.
c. External Integrations:
• Google Maps API: Display integration for live map data, using location data from the mobile client and Firestore.
• Google Vision API: For image verification (to validate naloxone kit locations).
• Gemini API: For the AI-powered chatbot that provides overdose aid, including tailored guidance.
• Orkes Constructor: As the automation engine for emergency workflows (triggering location sharing, contact alerts, emergency calls).
Relationships & Data Flow
• From the mobile client, show interactions with the cloud functions that process image verifications and emergency automation events.
• Mapping layer between Firebase and the mobile client for live map updates using the Google Maps API.
• Bi-directional communication between the mobile client and backend services (i.e., for data reading, writing, and receiving push notifications).
Architectural Patterns & Design Principles
• Modular separation:
• Frontend (mobile UI/UX and native Android integrations)
• Backend (Firebase services, Cloud Functions)
• External service integrations (Google services, Gemini, Orkes)
• Use a clear separation of concerns that aligns with common architectural patterns in mobile full-stack apps.
• Asynchronous or event-driven flows (for instance, the use of real-time Firestore updates and the asynchronous invocation of APIs).