Mobile Emergency Communication System for Village Health Workers, Ambulance Drivers, and Clinics in East Africa
# HealthAlert - Backend
## Clone repo
In the directory you want to place the code, run;
```bash
git clone
github.com
cd health_app_backend
```
## Architecture
## Project Structure
```
functions/
├── src/
│ ├── index.ts # Main entry point
│ │
│ ├── models/ # Data models
│ │ └── user.model.ts # User interfaces & enums
│ │
│ ├── services/ # Business logic
│ │ └── user.service.ts # User database operations
│ │
│ ├── controllers/ # Cloud Functions
│ │ ├── auth.controller.ts # Authentication functions
│ │ └── user.controller.ts # User management functions
│ │
│ └── utils/ # Helpers
│ ├── validators.ts # Input validation
│ └── responses.ts # Response formatting
│
├── package.json
├── tsconfig.json
└── README.md
```
## Getting Started
### Prerequisites
- Node.js 22
- Firebase CLI
- Firebase project created
### 1. Install Firebase CLI
```bash
npm install -g firebase-tools
```
### 2. Login to Firebase
```bash
firebase login
```
### 3. Initialize Project (if not done)
```bash
# In the backend directory
firebase init
# Select:
# - Functions (TypeScript)
# - Firestore
# - Use existing project
```
### 4. Install Dependencies
```bash
cd functions
npm install
```
### 5. Build TypeScript
```bash
npm run build
```
### 6. Deploy to Firebase
```bash
# From backend root directory
firebase deploy --only functions,firestore:rules
```
## Available Cloud Functions
### Authentication Functions
#### `registerUser`
Creates a new user account.
**Request:**
```json
{
"firstName": "John",
"lastName": "Mukasa",
"phoneNumber": "+256700123456",
"role": "VHT"
}
```
**Response:**
```json
{
"success": true,
"message": "User registered successfully",
"user": {
"id": "user_id",
"firstName": "John",
"lastName": "Mukasa", …