# andrewmtz23/healthcheckback architecture

> Architecture diagram of the GitHub repository andrewmtz23/healthcheckback, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andrewmtz23/healthcheckback
- Repository: https://github.com/andrewmtz23/healthcheckback

## Overview

HealthCheck is a multi-service backend for health-news analysis, news management, accounts, and alerts. The main workflow sends a user’s text or article URL through the gateway to ML classification, which extracts and stores article data, assigns a topic and keywords, and returns a prediction. Users can also access the separately exposed news API, manage accounts and consultation history, and receive preference-based alerts. The graph includes documented capabilities whose implementation was not sampled; those relationships are based on the README rather than inspected runtime code.

Main entry points: [`services/news-service/src/app.ts`](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/app.ts) (News API), [`services/ml-service/api/routes/classify_routes.py`](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/classify_routes.py) (Article classification), [`api-gateway/src/routes/proxy.ts`](https://github.com/andrewmtz23/healthcheckback/blob/main/api-gateway/src/routes/proxy.ts) (Service proxy), [`services/ml-service/app.py`](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/app.py) (ML API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["API gateway"]
  node_gateway_app["Gateway app<br/>[app.ts]"]
  node_gateway_routes["Gateway routes"]
  node_gateway_proxy["Service proxy<br/>[proxy.ts]"]
end

subgraph group_accounts["Accounts"]
  node_auth_app["Auth service<br/>[app.ts]"]
  node_auth_flows["Account and OAuth<br/>[authController.ts]"]
  node_auth_profile["Profile preferences<br/>[routes.ts]"]
end

subgraph group_news["News management"]
  node_news_app["News API<br/>[app.ts]"]
  node_news_content["Articles and search<br/>[newsController.ts]"]
  node_news_interactions["Interactions"]
  node_news_reports["Reports"]
  node_news_history["Consultation history"]
end

subgraph group_ml["ML and collection"]
  node_ml_app["ML API<br/>[app.py]"]
  node_ml_classify["Article classification<br/>[classify_routes.py]"]
  node_ml_extract["Article extraction"]
  node_ml_inference["BERT inference"]
  node_ml_data["Article persistence<br/>[db_utils.py]"]
  node_ml_scrapers["News scrapers"]
  node_ml_training["Model management<br/>[train_routes.py]"]
  node_ml_chatbot["Search chatbot<br/>[chatbot_routes.py]"]
end

subgraph group_notifications["Notifications"]
  node_notification_app["Notification API<br/>[app.js]"]
  node_notification_send["Send notifications"]
  node_notification_scheduler["Alert scheduler"]
  node_notification_preferences["Notification preferences"]
  node_notification_delivery["Email and SMS delivery"]
end

node_client(("Web client"))
node_postgres[("PostgreSQL")]
node_bert["Local BERT model"]
node_search_services["OpenAI and Google Search"]
node_delivery_services["SMTP and Twilio"]

node_client -->|"calls gateway"| node_gateway_app
node_client -->|"accesses directly"| node_news_app
node_gateway_app -->|"mounts routes"| node_gateway_routes
node_gateway_routes -->|"proxies requests"| node_gateway_proxy
node_gateway_proxy -->|"forwards auth"| node_auth_app
node_gateway_proxy -->|"forwards ML"| node_ml_app
node_gateway_proxy -->|"forwards alerts"| node_notification_app
node_auth_app -->|"mounts routes"| node_auth_flows
node_auth_flows -->|"mounts profiles"| node_auth_profile
node_auth_flows -->|"stores accounts"| node_postgres
node_auth_profile -->|"queries preferences"| node_postgres
node_news_app -->|"serves news"| node_news_content
node_news_app -->|"serves interactions"| node_news_interactions
node_news_app -->|"serves reports"| node_news_reports
node_news_app -->|"serves history"| node_news_history
node_news_content -->|"reads and writes"| node_postgres
node_news_interactions -->|"reads and writes"| node_postgres
node_news_reports -->|"reads and writes"| node_postgres
node_news_history -->|"reads history"| node_postgres
node_ml_app -->|"registers routes"| node_ml_classify
node_ml_app -->|"registers routes"| node_ml_training
node_ml_app -->|"registers routes"| node_ml_chatbot
node_ml_classify -->|"extracts article"| node_ml_extract
node_ml_classify -->|"predicts news"| node_ml_inference
node_ml_classify -->|"stores analysis"| node_ml_data
node_ml_classify -->|"dispatches scraping"| node_ml_scrapers
node_ml_inference -.->|"loads model"| node_bert
node_ml_training -->|"updates model records"| node_postgres
node_ml_data -->|"reads and writes"| node_postgres
node_ml_chatbot -->|"searches with"| node_search_services
node_notification_app -->|"routes requests"| node_notification_send
node_notification_app -->|"starts scheduler"| node_notification_scheduler
node_notification_send -->|"dispatches delivery"| node_notification_delivery
node_notification_send -->|"stores notifications"| node_postgres
node_notification_scheduler -->|"loads preferences"| node_notification_preferences
node_notification_scheduler -.->|"dispatches alerts"| node_notification_delivery
node_notification_scheduler -->|"queries alert data"| node_postgres
node_notification_delivery -->|"sends email or SMS"| node_delivery_services

click node_gateway_app "https://github.com/andrewmtz23/healthcheckback/blob/main/api-gateway/src/app.ts"
click node_gateway_routes "https://github.com/andrewmtz23/healthcheckback/tree/main/api-gateway/src/routes"
click node_gateway_proxy "https://github.com/andrewmtz23/healthcheckback/blob/main/api-gateway/src/routes/proxy.ts"
click node_auth_app "https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/app.ts"
click node_auth_flows "https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/controllers/authController.ts"
click node_auth_profile "https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/profile/routes.ts"
click node_news_app "https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/app.ts"
click node_news_content "https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/newsController.ts"
click node_news_interactions "https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/interactionController.ts"
click node_news_reports "https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/reportController.ts"
click node_news_history "https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/historyController.ts"
click node_ml_app "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/app.py"
click node_ml_classify "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/classify_routes.py"
click node_ml_extract "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/utils/article_extractor.py"
click node_ml_inference "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/core/classify_service.py"
click node_ml_data "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/utils/db_utils.py"
click node_ml_scrapers "https://github.com/andrewmtz23/healthcheckback/tree/main/services/ml-service/scrapers"
click node_ml_training "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/train_routes.py"
click node_ml_chatbot "https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/chatbot_routes.py"
click node_notification_app "https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/app.js"
click node_notification_send "https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/controllers/notification.controller.js"
click node_notification_scheduler "https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/services/scheduler.service.js"
click node_notification_preferences "https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/services/preference.service.js"
click node_notification_delivery "https://github.com/andrewmtz23/healthcheckback/tree/main/services/notification-service/src/services/notification"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gateway_app,node_gateway_routes,node_gateway_proxy,node_client toneBlue
class node_auth_app,node_auth_flows,node_auth_profile,node_postgres toneAmber
class node_news_app,node_news_content,node_news_interactions,node_news_reports,node_news_history toneMint
class node_ml_app,node_ml_classify,node_ml_extract,node_ml_inference,node_ml_data,node_ml_scrapers,node_ml_training,node_ml_chatbot toneRose
class node_notification_app,node_notification_send,node_notification_scheduler,node_notification_preferences,node_notification_delivery,node_bert,node_search_services,node_delivery_services toneIndigo
```

## Components

### API gateway

- [Gateway app](https://github.com/andrewmtz23/healthcheckback/blob/main/api-gateway/src/app.ts): `api-gateway/src/app.ts`
- [Gateway routes](https://github.com/andrewmtz23/healthcheckback/tree/main/api-gateway/src/routes): `api-gateway/src/routes`
- [Service proxy](https://github.com/andrewmtz23/healthcheckback/blob/main/api-gateway/src/routes/proxy.ts): `api-gateway/src/routes/proxy.ts`

### Accounts

- [Auth service](https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/app.ts): `services/auth-service/src/app.ts`
- [Account and OAuth](https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/controllers/authController.ts): `services/auth-service/src/controllers/authController.ts`
- [Profile preferences](https://github.com/andrewmtz23/healthcheckback/blob/main/services/auth-service/src/profile/routes.ts): `services/auth-service/src/profile/routes.ts`

### News management

- [News API](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/app.ts): `services/news-service/src/app.ts`
- [Articles and search](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/newsController.ts): `services/news-service/src/controllers/newsController.ts`
- [Interactions](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/interactionController.ts): `services/news-service/src/controllers/interactionController.ts`
- [Reports](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/reportController.ts): `services/news-service/src/controllers/reportController.ts`
- [Consultation history](https://github.com/andrewmtz23/healthcheckback/blob/main/services/news-service/src/controllers/historyController.ts): `services/news-service/src/controllers/historyController.ts`

### ML and collection

- [ML API](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/app.py): `services/ml-service/app.py`
- [Article classification](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/classify_routes.py): `services/ml-service/api/routes/classify_routes.py`
- [Article extraction](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/utils/article_extractor.py): `services/ml-service/utils/article_extractor.py`
- [BERT inference](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/core/classify_service.py): `services/ml-service/core/classify_service.py`
- [Article persistence](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/utils/db_utils.py): `services/ml-service/utils/db_utils.py`
- [News scrapers](https://github.com/andrewmtz23/healthcheckback/tree/main/services/ml-service/scrapers): `services/ml-service/scrapers`
- [Model management](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/train_routes.py): `services/ml-service/api/routes/train_routes.py`
- [Search chatbot](https://github.com/andrewmtz23/healthcheckback/blob/main/services/ml-service/api/routes/chatbot_routes.py): `services/ml-service/api/routes/chatbot_routes.py`

### Notifications

- [Notification API](https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/app.js): `services/notification-service/src/app.js`
- [Send notifications](https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/controllers/notification.controller.js): `services/notification-service/src/controllers/notification.controller.js`
- [Alert scheduler](https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/services/scheduler.service.js): `services/notification-service/src/services/scheduler.service.js`
- [Notification preferences](https://github.com/andrewmtz23/healthcheckback/blob/main/services/notification-service/src/services/preference.service.js): `services/notification-service/src/services/preference.service.js`
- [Email and SMS delivery](https://github.com/andrewmtz23/healthcheckback/tree/main/services/notification-service/src/services/notification): `services/notification-service/src/services/notification`

### Other components

- **Web client**
- **PostgreSQL**
- **Local BERT model**
- **OpenAI and Google Search**
- **SMTP and Twilio**

## Connections

- Web client → Gateway app: calls gateway
- Web client → News API: accesses directly
- Gateway app → Gateway routes: mounts routes (evidence: `api-gateway/src/app.ts`)
- Gateway routes → Service proxy: proxies requests (evidence: `api-gateway/src/routes/ml.routes.ts`)
- Service proxy → Auth service: forwards auth
- Service proxy → ML API: forwards ML
- Service proxy → Notification API: forwards alerts
- Auth service → Account and OAuth: mounts routes (evidence: `services/auth-service/src/app.ts`)
- Account and OAuth → Profile preferences: mounts profiles (evidence: `services/auth-service/src/routes/authRoutes.ts`)
- Account and OAuth → PostgreSQL: stores accounts
- Profile preferences → PostgreSQL: queries preferences (evidence: `services/auth-service/src/profile/routes.ts`)
- News API → Articles and search: serves news
- News API → Interactions: serves interactions
- News API → Reports: serves reports
- News API → Consultation history: serves history
- Articles and search → PostgreSQL: reads and writes
- Interactions → PostgreSQL: reads and writes (evidence: `services/news-service/src/controllers/interactionController.ts`)
- Reports → PostgreSQL: reads and writes (evidence: `services/news-service/src/controllers/reportController.ts`)
- Consultation history → PostgreSQL: reads history
- ML API → Article classification: registers routes (evidence: `services/ml-service/app.py`)
- ML API → Model management: registers routes (evidence: `services/ml-service/app.py`)
- ML API → Search chatbot: registers routes (evidence: `services/ml-service/app.py`)
- Article classification → Article extraction: extracts article (evidence: `services/ml-service/api/routes/classify_routes.py`)
- Article classification → BERT inference: predicts news (evidence: `services/ml-service/api/routes/classify_routes.py`)
- Article classification → Article persistence: stores analysis (evidence: `services/ml-service/api/routes/classify_routes.py`)
- Article classification → News scrapers: dispatches scraping (evidence: `services/ml-service/api/routes/classify_routes.py`)
- BERT inference → Local BERT model: loads model
- Model management → PostgreSQL: updates model records (evidence: `services/ml-service/api/routes/train_routes.py`)
- Article persistence → PostgreSQL: reads and writes
- Search chatbot → OpenAI and Google Search: searches with
- Notification API → Send notifications: routes requests
- Notification API → Alert scheduler: starts scheduler (evidence: `services/notification-service/src/app.js`)
- Send notifications → Email and SMS delivery: dispatches delivery (evidence: `services/notification-service/src/controllers/notification.controller.js`)
- Send notifications → PostgreSQL: stores notifications (evidence: `services/notification-service/src/controllers/notification.controller.js`)
- Alert scheduler → Notification preferences: loads preferences (evidence: `services/notification-service/src/services/scheduler.service.js`)
- Alert scheduler → Email and SMS delivery: dispatches alerts (evidence: `services/notification-service/src/services/scheduler.service.js`)
- Alert scheduler → PostgreSQL: queries alert data (evidence: `services/notification-service/src/services/scheduler.service.js`)
- Email and SMS delivery → SMTP and Twilio: sends email or SMS
