Skip to content

bounswe/bounswe2026group8

Repository files navigation

Neighborhood Emergency Preparedness Hub

A community platform for disaster preparedness, mutual aid, and neighbourhood resilience. Users can register as Standard members or Experts, connect with neighbours, and access critical information — even offline.


Repository Structure

├── backend/          Django REST API
├── frontend/         React (Vite) web client
├── mobile/           Android (Kotlin) app
├── nginx/            Nginx config for production
└── docker-compose.yml

Local Development

Two options: Docker Compose (easiest, no local installs needed) or native setup.


Option A — Docker Compose (recommended)

Prerequisites

Tool Version
Docker Latest
Android Studio Latest (for mobile only)

Running

docker-compose -f docker-compose.yml -f docker-compose.local.yml up --build

Subsequent runs (no code changes):

docker-compose -f docker-compose.yml -f docker-compose.local.yml up

To stop:

docker-compose -f docker-compose.yml -f docker-compose.local.yml down

On first run, sample users, posts, help requests, and offers are automatically populated. Login with [email protected] / [email protected] and password password123.

If you have a backend/firebase-credentials.json file it will be used for push notifications. Without it the app runs normally — only push notifications to mobile are disabled.

Mobile: Android emulator debug builds automatically connect to http://10.0.2.2:8000 — this works out of the box since the local Docker Compose exposes port 8000 directly. Run the emulator from Android Studio while Docker Compose is up.


Option B — Native Setup

Prerequisites

Tool Version
Python 3.10+
Node.js 18+
npm 9+
Docker Latest (for local Postgres)
Android Studio Latest (for mobile)

1. Database (PostgreSQL)

The backend requires PostgreSQL. Choose one of the options below.

Option A — Docker (recommended, no install needed)

docker run -d \
  --name emergencyhub-db \
  -e POSTGRES_DB=emergencyhub \
  -e POSTGRES_USER=emergencyhub \
  -e POSTGRES_PASSWORD=emergencyhub \
  -p 5432:5432 \
  postgres:16-alpine

To stop/start it later:

docker stop emergencyhub-db
docker start emergencyhub-db

Option B — Native install

macOS (Homebrew):

brew install postgresql@16
brew services start postgresql@16
psql postgres -c "CREATE USER emergencyhub WITH PASSWORD 'emergencyhub';"
psql postgres -c "CREATE DATABASE emergencyhub OWNER emergencyhub;"

Ubuntu/Debian:

sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo -u postgres psql -c "CREATE USER emergencyhub WITH PASSWORD 'emergencyhub';"
sudo -u postgres psql -c "CREATE DATABASE emergencyhub OWNER emergencyhub;"

Windows:

Download and install from https://www.postgresql.org/download/windows/, then open pgAdmin or psql and run:

CREATE USER emergencyhub WITH PASSWORD 'emergencyhub';
CREATE DATABASE emergencyhub OWNER emergencyhub;

Either option works — the Django settings default to DB_NAME=emergencyhub, DB_USER=emergencyhub, DB_PASSWORD=emergencyhub, DB_HOST=localhost. No .env file needed if you use these exact credentials.

2. Backend (Django — port 8000)

python -m venv .venv
source .venv/bin/activate      # macOS/Linux
# .venv\Scripts\activate       # Windows

cd backend
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

API is now live at http://localhost:8000.

3. Frontend (React + Vite — port 5173)

cd frontend
npm install
npm run dev

Open http://localhost:5173 in your browser.

No .env file needed — the frontend automatically falls back to http://localhost:8000 when VITE_API_BASE is not set.

Both servers must run simultaneously.

4. Mobile (Android)

Open the mobile/ folder in Android Studio and run on an emulator.

No configuration needed — debug builds automatically point to http://10.0.2.2:8000 (the emulator's address for localhost:8000 on your machine).

The backend must be running locally for the mobile app to work.


Production

Production is deployed on EC2 via Docker Compose and served through Nginx with HTTPS.

How it works

Layer Role
Nginx Terminates SSL, routes /api/ → Django, /media/ → files, / → React
Django Runs via Gunicorn on port 8000 (internal)
React Built with VITE_API_BASE=/api, served as static files by Nginx
Mobile (release) Points to https://emergencyhub.duckdns.org/api/

Deploying

Deployment is automatic — push to main triggers the CI/CD pipeline:

  1. Runs backend, frontend, and Android unit tests in parallel
  2. SSHes into EC2 and runs docker-compose up --build -d (only if all tests pass)

To deploy manually:

ssh -i <your-key.pem> ubuntu@<EC2_HOST>
cd bounswe2026group8
git pull origin main
docker-compose up --build -d

Environment variables (EC2)

Create a .env file on the EC2 server next to docker-compose.yml:

DJANGO_SECRET_KEY=your-secret-key
DB_NAME=emergencyhub
DB_USER=emergencyhub
DB_PASSWORD=your-db-password
DJANGO_DEBUG=False

Running Tests

Backend (Django — 136 tests)

docker-compose run --rm backend python manage.py test accounts forum help_requests

Frontend (Jest + React Testing Library — 52 tests)

cd frontend
npm test

Android (JUnit 4 — 51 tests)

Requires Android Studio installed (sets up JDK and ANDROID_HOME automatically).

macOS / Linux / WSL:

cd mobile
echo "sdk.dir=$ANDROID_HOME" > local.properties
./gradlew testDebugUnitTest --no-daemon

Windows — without Android Studio (Docker required):

docker run --rm `
  -v "C:/path/to/repo/mobile:/app" `
  -w /app `
  mingc/android-build-box:latest `
  bash -c "echo 'sdk.dir=`$ANDROID_HOME' > local.properties && ./gradlew testDebugUnitTest --no-daemon"

Replace C:/path/to/repo with the actual path to your clone.


Tech Stack

  • Backend: Django 4.2, Django REST Framework, PostgreSQL
  • Frontend: React 19, Vite, React Router
  • Mobile: Android (Kotlin), Retrofit, OkHttp
  • Auth: JWT (SimpleJWT)
  • Infrastructure: EC2, Docker Compose, Nginx, Let's Encrypt

Team

CMPE354 — Group 8

About

CMPE354 Group 8 repository

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors