# nischay-code/rescure architecture

> Architecture diagram of the GitHub repository nischay-code/rescure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nischay-code/rescure
- Repository: https://github.com/nischay-code/rescure

## Overview

##### Project Type and Purpose
- Res-Cure is a full-stack emergency-response application comprised of:
- A cross-platform mobile client (React Native) for end users to request help.
- A web-based client (React SPA) for hospital staff or users on desktop.
- A static marketing site (HTML/CSS) for public information (about, contact, detail pages).
- A backend powered by Firebase (Authentication, Realtime Database, Cloud Functions).

##### Main Components
1. User Interfaces
– Mobile App (React Native, Android/iOS via rescure.apk)
– Web App (React SPA in /React)
– Marketing Site (static HTML/CSS in project root)
2. Backend Services (Firebase)
– Authentication (user sign-in, roles)
– Realtime Database (emergency requests, hospital data)
– Cloud Functions (processing requests, notifications)
– Hosting (optional for React SPA and static pages)
3. External Services
– Push Notification / SMS gateway (for hospital alerts)
– Google Maps / Location API (to locate nearby hospitals)

##### Relationships and Data Flows
- User opens Mobile App → authenticates via Firebase Auth → submits emergency request → writes to Firebase Realtime DB → triggers Cloud Function → sends notification (push/SMS) to hospital staff.
- Hospital staff view request in Web App → fetch data from Realtime DB → update patient status → updates propagate back to mobile clients in real time.
- Marketing Site is hosted separately (e.g., Firebase Hosting or CDN) and does not directly interact with DB; it links to app download and signup pages.

##### Architectural Patterns and Principles
- Client-Server: UI clients (mobile/web) communicate with backend via Firebase SDKs.
- Event-Driven: Use Cloud Functions to react to database writes (new emergencies) and send notifications.
- Real-Time Synchronization: Realtime Database enables live updates between clients and hospital dashboards.
- Separation of Concerns:
- Presentation layer (UI)
- Business logic layer (Cloud Functions)
- Data layer (Firebase DB)

##### Technologies and Frameworks
- React Native for cross-platform mobile development.
- React (create-react-app) for web dashboard.
- Firebase suite for backend (Auth, Realtime DB, Cloud Functions, Hosting).
- Android Studio for building/testing APK.
- Standard HTML/CSS for marketing site.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Actors
  subgraph "Actors"
    direction LR
    EndUser(["End User"]):::actor
    HospitalStaff(["Hospital Staff"]):::actor
  end

  %% UI Clients
  subgraph "UI Clients"
    direction TB
    MobileApp(["Mobile App<br/>(React Native)"]):::ui
    WebSPA(["Web App<br/>(React SPA)"]):::ui
    StaticSite(["Marketing Site<br/>(Static HTML/CSS)"]):::ui
  end

  %% Backend
  subgraph "Firebase Backend"
    direction TB
    Auth(["Firebase Auth"]):::backend
    RealtimeDB(["Firebase Realtime DB"]):::backend
    Functions(["Cloud Functions"]):::backend
    Hosting(["Firebase Hosting"]):::backend
  end

  %% External Services
  subgraph "External Services"
    direction TB
    PushSMS(["Push/SMS Service"]):::external
    MapsAPI(["Google Maps / Location API"]):::external
  end

  %% Connections
  EndUser -->|"Opens App"| MobileApp
  EndUser -->|"Visits Site"| StaticSite
  HospitalStaff -->|"Uses Web SPA"| WebSPA

  MobileApp -->|"Auth request (HTTPS)"| Auth
  WebSPA -->|"Auth request (HTTPS)"| Auth

  MobileApp -->|"Write emergency"| RealtimeDB
  WebSPA -->|"Read/Write status"| RealtimeDB
  RealtimeDB -->|"Triggers on write"| Functions
  Functions -->|"Send notification"| PushSMS
  PushSMS -->|"Alert"| HospitalStaff

  MobileApp <-->|"Real-time sync (WebSockets)"| RealtimeDB
  WebSPA <-->|"Real-time sync (WebSockets)"| RealtimeDB

  MobileApp -->|"Request hospital loc"| MapsAPI
  WebSPA -->|"Request hospital loc"| MapsAPI

  StaticSite -->|"Hosted via"| Hosting
  WebSPA -->|"Hosted via"| Hosting
  Functions -->|"Optional hosting"| Hosting

  %% Click Events
  click MobileApp "https://github.com/nischay-code/rescure/blob/master/ReactNative/rescure.apk"
  click WebSPA "https://github.com/nischay-code/rescure/tree/master/React/"
  click StaticSite "https://github.com/nischay-code/rescure/blob/master/index.html"

  %% Styles
  classDef ui fill:#93ccea,stroke:#333,stroke-width:1px,color:#000
  classDef backend fill:#a2d5a2,stroke:#333,stroke-width:1px,color:#000
  classDef external fill:#f7b267,stroke:#333,stroke-width:1px,color:#000
  classDef actor fill:#cccccc,stroke:#333,stroke-width:1px,color:#000
```
