Sentry App is a multi-service safety and tourism platform. The repository contains a mobile frontend, three backend services, and a Python ML folder used for preprocessing datasets and supporting risk-related features.
The project is organized as a small distributed system:
- The Expo frontend handles the user interface for mobile and web.
- The HTTPS backend provides the main REST API for auth, SOS, contacts, support, stats, booking partners, alerts, and safety zones.
- The WebSocket backend handles realtime updates, admin notifications, and chat-oriented flows.
- The email worker processes queued email jobs through BullMQ and Redis.
- The ML folder contains preprocessing scripts and notebooks that support the safety and risk workflows.
flowchart LR
U[Users] --> F[Expo Frontend]
F --> API[HTTPS Backend]
F --> WS[WebSocket Backend]
API --> DB[(PostgreSQL)]
WS --> DB
API <--> R[(Redis)]
WS <--> R
EW[Email Worker] <--> R
API --> ML[ML Services / Python Models]
WS --> ML
frontend/- Expo Router mobile appbackend/https-backend/- REST API for auth, SOS, contacts, stats, booking partners, support, alerts, and safety zonesbackend/websocket-backend/- WebSocket service for live admin updates and chat-related realtime featuresbackend/email-worker-backend/- Dedicated email worker service powered by BullMQml/- Python dependencies for preprocessing and ML workflowssrc/- Python preprocessing scriptsnotebooks/- Jupyter notebooks for the preprocessing steps
- Node.js 18 or newer for the backend services
- npm
- Python 3.10+ for the ML tooling
- Redis for queueing and realtime features
- A PostgreSQL database for Prisma-based services
The frontend lives in frontend/ and uses Expo Router.
cd frontend
npm install
npm run startUseful scripts:
npm run androidnpm run iosnpm run webnpm run lint
The Expo config reads these variables from the environment:
EXPO_PUBLIC_BACKEND_URLEXPO_PUBLIC_OPENWEATHER_API_KEYEXPO_PUBLIC_OPENWEATHER_API_URLEXPO_PUBLIC_WEATHER_FETCH_TIMEOUTEXPO_PUBLIC_MAPBOX_ACCESS_TOKENEXPO_PUBLIC_MAPBOX_API_URLEXPO_PUBLIC_DEFAULT_COUNTRY_CODEEXPO_PUBLIC_DEFAULT_LATITUDEEXPO_PUBLIC_DEFAULT_LONGITUDEEXPO_PUBLIC_MAP_FETCH_TIMEOUTEXPO_PUBLIC_FETCH_TIMEOUTEXPO_PUBLIC_AWS_RISK_BASE_URLEXPO_PUBLIC_POLICE_STATION_LOCATION_URLEXPO_PUBLIC_POLICE_STATION_BOUNDARY_URL
The REST API lives in backend/https-backend/.
cd backend/https-backend
npm install
npm run build
npm run startDevelopment mode:
npm run devAvailable scripts:
npm run start- applies Prisma migrations and starts the compiled servernpm run dev- runs the TypeScript entry point with ts-nodenpm run build- generates Prisma client, compiles TypeScript, and copies generated sourcesnpm run add-contact- runs the contact seeding helper
PORTDATABASE_URLREDIS_URLorREDISJWT_SECRETFROM_EMAILFROM_NAMEBREVO_API_KEYML_BACKEND_URLAWS_RISK_BASE_URLAWS_RISK_TIMEOUT_MS
The realtime backend lives in backend/websocket-backend/.
cd backend/websocket-backend
npm install
npm run build
npm run startDevelopment mode:
npm run devUseful scripts:
npm run worker- starts the email worker inside the websocket service process
PORTDATABASE_URLREDIS_URLorREDISJWT_SECRETRUN_EMAIL_WORKERGEMINI_API_KEYGEMINI_MODELGEMINI_FALLBACK_MODELGEMINI_TIMEOUT_MSGEMINI_MAX_RETRIESFROM_EMAILFROM_NAMEBREVO_API_KEYHIGH_RISK_THRESHOLDCHAT_MAX_QUESTION_LENGTHML_BACKEND_URL
The standalone email worker lives in backend/email-worker-backend/.
cd backend/email-worker-backend
npm install
npm run build
npm run startDevelopment mode:
npm run devPORTREDIS_URLorREDISFROM_EMAILFROM_NAMEBREVO_API_KEY
The ml/ folder contains the Python dependencies for preprocessing and analysis work used by the project.
cd ml
pip install -r requirements.txtThe preprocessing scripts live in src/, and the corresponding notebooks are in notebooks/.
- Prisma-generated files are checked into the backend services, so make sure to run the relevant
buildscript after changing schemas. - The websocket service can optionally start the email worker in-process when
RUN_EMAIL_WORKER=true. - The project uses Redis for queues and realtime session/event broadcasting.