How projectsprav/xho works
1. This is a multi-app health platform monorepo.
The repository combines three client surfaces, a Python API, background workflows, and supporting infrastructure. The product domains are clearly health/wellness: onboarding, biomarker tracking, workouts, diet, period tracking, medications, readiness, and clinician/coach oversight.
2. Client boundary: mobile app.
apps/mobile is an Expo/React Native app organized around route-based screens. It covers patient-facing workflows such as onboarding, auth via OTP, home/dashboard, workouts, biomarkers, body metrics, period tracking, CGM setup/reports, diet, wearables, and medication-related features. It uses local state stores plus hook-based data fetching, and includes native health sync services for Apple Health and Google Health.
3. Client boundary: web dashboards.
apps/web is the main Next.js admin/clinical web app used for browser-based operations. It exposes admin, coach, and physician sections for evidence review, protocol assignment, workout and nutrition builders, client/patient views, and operational dashboards. The README notes browser requests go through same-origin /api/v1, which Next.js proxies to the backend locally or in Docker.
4. Second web surface: physician-web.
apps/physician-web is a separate Next.js app with a similar shape, focused on physician workflows and dashboards. It appears to mirror part of the main web experience but remains a distinct frontend boundary.
5. Backend core: the API service.
services/api is the central application server. Its structure is classic layered backend: routers expose HTTP endpoints, services hold business logic, models define persistence, schemas define request/response contracts, and dependencies enforce cross-cutting concerns like auth, consent, audit, cache, and database access. This is the main integration point for all clients.
6. Domain segmentation in the API.
The API is organized by product capability rather than by technical tier: auth, onboarding, profiles, biomarkers, body metrics, CGM, check-ins, diet/nutrition, recipes, foods, workouts, workout sessions, habits, medications, messaging, period tracking, progress photos, readiness, physician workflows, and coach workflows. That makes the backend the canonical source of truth for user state and longitudinal health data.
7. Persistent data layer.
The primary transactional store is Postgres, managed through SQLAlchemy-style models and Alembic migrations. The migration history shows the system has evolved through multiple feature waves: onboarding/profile expansion, body metrics, wearable support, CGM, biomarkers, workouts, nutrition plans, evidence governance, period tracking, and medications. The database is the shared substrate for the API, web apps, and scheduled analytics jobs.
8. Asynchronous event pipeline.
Kafka is used for event-driven processing. The API includes producers plus consumers for biomarker, CGM, wearable, spike detection, and notification dispatch flows. This separates ingest from downstream processing, enabling delayed computation, alerting, and fan-out to notifications without blocking client requests.
9. Scheduled analytics and automation.
services/airflow hosts a large set of DAGs for recurring jobs: readiness, vitality score, adherence, body metrics, CGM polling and response analysis, protocol generation, progressive overload, medication reminders/renewals, period notifications/correlations, wearable sync, and engagement metrics. These workflows read from the core data store and event streams, then materialize derived insights or trigger operational actions.
10. Protocol/evidence engine is a major business subsystem.
The backend contains dedicated protocol-engine code for clinical rules, diet plan building, workout plan building, evidence-gated generation, and progressive overload logic. The admin web UI surfaces evidence review and content management for recipes, exercises, workout templates/programs, nutrition plans, and protocol assignments. This is the mechanism that turns clinical/content rules into patient-facing plans.
11. Wearable and native health integration boundary.
Mobile-side health services collect device/platform data; the API has dedicated wearable and native-health routers, consumers, and constants for standardized data types. This implies a pipeline from phone/device sensors into the backend, then into derived metrics such as readiness, vitality score, CGM, and period-related insights.
12. Media/file handling and external services.
The repo includes storage and OCR/report-processing services, suggesting lab uploads and progress photos are stored outside the DB, likely in object storage. Appwrite is an external prerequisite for local development, so identity/auth is at least partially anchored in an external platform. MinIO is listed in the runtime stack and is the likely object store.
13. Cross-cutting observability and deployment.
Operationally, the stack is containerized with Docker Compose and includes Nginx, Promtail/Loki, Prometheus/Grafana, and Signoz/OTel collector. The API has explicit observability middleware, metrics, and OTEL wiring. This is a production-oriented setup with centralized logging, tracing, and metrics across apps and services.
14. Seed/test/tooling supports content-heavy workflows.
The repo contains many seed scripts and extensive tests, especially around protocol generation, evidence, admin surfaces, and domain services. That’s a sign the system depends heavily on curated content and rule-based behavior, not just CRUD APIs.
15. High-level data flow to diagram.
User/device data enters through mobile or web → hits the API → persists in Postgres and object storage → emits Kafka events → background consumers and Airflow DAGs compute derived insights and notifications → results are read back by mobile/web dashboards. Admin/clinician workflows feed curated content and protocol rules back into the same API, which then drives patient-facing plans and alerts.
Main entry points: api API server · docker-compose.yml Runtime stack · services Domain services · dags Airflow DAGs
Components 15
Client apps
Patient and clinician-facing surfaces
- Mobile app · Patient-facing onboarding, tracking, and workout experience
apps/mobile - Health sync · Apple Health and Google Health device data collection
apps/mobile/src/services/health - Admin web · Primary browser dashboard for admin, coach, and physician workflows
apps/web - Physician web · Separate physician-focused web surface
apps/physician-web
Core backend
API, domain services, persistence, and async processing
- API server · Central HTTP application server and integration hub
services/api - HTTP routers · Capability-specific endpoints for auth, biometrics, workouts, diet, meds, and admin
services/api/routers - Domain services · Core workflows for protocol generation, scoring, meds, periods, and reports
services/api/services - Protocol engine · Evidence-gated workout and diet plan generation with progression logic
services/api/services/protocol_engine - Data models · SQLAlchemy-style entities for longitudinal health and operational data
services/api/models - Migrations · Alembic migration history for feature waves and schema evolution
services/api/alembic/versions - Kafka pipeline · Producers and consumers for biomarker, CGM, wearable, spike, and notification flows
services/api/messaging - Airflow DAGs · Recurring analytics, reminders, correlations, and protocol jobs
services/airflow/dags - Object storage · Externalized reports, uploads, and media handling
services/api/services/storage.py
Ops & infra
Container, observability, and deployment support
- Observability · Metrics, tracing, logs, and runtime instrumentation
services/api/observability - Runtime stack · Containerized local and production-like deployment with nginx, promtail, and signoz
docker-compose.yml
Connections 19
- Mobile app → API server: patient API · Mobile screens and hooks read/write core health data
- Mobile app → Health sync: syncs data · Mobile collects native health signals for upload and sync
- Admin web → API server: same-origin API · Browser dashboards proxy requests to the backend
- Physician web → API server: clinical API · Physician workflows use the central API
- API server → HTTP routers: exposes · HTTP routes define the public application surface
- HTTP routers → Domain services: delegates · Endpoints hand off business logic to domain services
- Domain services → Protocol engine: builds plans · Clinical rules and evidence gating drive protocol generation
- Domain services → Data models: persists · Business workflows read and write domain entities
- Data models → Migrations: evolves schema · Model changes are tracked through Alembic history
- API server → Kafka pipeline: publishes events · API emits async events for downstream processing
- Kafka pipeline → Airflow DAGs: feeds jobs · Scheduled workflows consume or complement event-driven processing
- Airflow DAGs → API server: materializes insights · Recurring jobs update derived scores, alerts, and reminders
- Airflow DAGs → Data models: reads/writes · DAGs operate on the shared transactional store
- API server → Object storage: stores files · Uploads, reports, and photos are externalized from the database
- API server → Observability: emits telemetry · Middleware and metrics feed tracing and monitoring
- Runtime stack → API server: runs · Container stack launches the backend service
- Runtime stack → Admin web: runs · Container stack supports the main web app
- Runtime stack → Physician web: runs · Container stack supports the physician web app
- Runtime stack → Observability: includes · Deployment stack includes logging and monitoring components