Technical Overview > Architecture > CHT Watchdog
Monitoring and alerting system using Grafana and Prometheus
Technical overview of the CHT Core Framework
The CHT Core Framework is the primary component of the CHT. The server comes with authentication, role based authorization, data security, and a range of protected data access endpoints. Read more detail in cht-core GitHub repository.
graph TB
classDef container stroke:#63a2c6, fill:#eef5f9, color:#000
subgraph CHT_Core_Framework["<div style="width: 23em; height:2em; display:flex; justify-content: flex-start; align-items:flex-end;">Server</div>"]
direction TB
NGINX(NGINX):::container
API(API):::container
Sentinel(Sentinel):::container
HAProxy(Haproxy):::container
HealthCheck(HealthCheck):::container
CouchDB[(CouchDB)]:::container
Nouveau[(Nouveau)]:::container
end
Upgrade["Upgrade Service"]:::container
subgraph Client["<div style="width: 28em; height:2em; display:flex; justify-content: flex-start; align-items:flex-end;">Client (Android & Browser)</div>"]
subgraph Webapp["Webapp"]
PouchDB[(PouchDB)]:::container
end
Admin["App Management"]:::container
end
Webapp --> NGINX
Admin --> NGINX
NGINX --> API
API <--> Upgrade
Sentinel --> HAProxy
API --> HAProxy
HAProxy --> CouchDB
HealthCheck --> CouchDB
HAProxy --> HealthCheck
CouchDB --> Nouveau
style CHT_Core_Framework fill: transparent
style Client fill: transparent
style Webapp fill: transparent
A NodeJS service that runs on the server and provides security and APIs for browsers and integrations. It also includes a custom implementation of filtered replication to allow it to support more concurrent users. See more at the CHT Core API repo on GitHub.
Another NodeJS service running on the server, sentinel performs actions called transitions every time a document in CouchDB is added or modified. Some examples are validations, generating scheduled messages, automatic responses, creating patients, and sending alerts. See more at the CHT Core Sentinel repo on GitHub.
A free and open source NoSQL database used as the primary store for all app data and configuration. This can be multiple instances clustered together for additional scalability. CouchDB is really good at replication which is the process of sending the data to another database and back again, which makes it ideal for replicating data to the phone for offline access. See more at the CouchDB site.
Nouveau is a CouchDB service, added to the CHT in version 5.0.0, leverages the Lucene search engine to modernize how freetext searches are done. Nouveau is faster at running these queries and more efficient at storing and creating the indexes. Offline users do not use this.
NGINX provides SSL termination and routes requests to API.
HAProxy provides logging and reverse proxying for any request that makes it to CouchDB.
A service that periodically verifies the health status of the CouchDb cluster. HAProxy uses this service for checking server status.
The CHT Upgrade Service is used within the CHT to update individual Docker containers when an upgrade is requested. Read more detail in the cht-upgrade-service GitHub repository.
The CHT Core Framework provides two web applications: the CHT Web App for care teams and program staff, and App Management for program administrators.
The CHT Web Application is used by Community Health Workers and provides a large variety of features. View the source code in our GitHub repository.
The CHT Web Application is reactive, responsive, and a single page application built with Angular and NgRx frameworks. Additionally, it uses the following technology:
| Technology | Usage |
|---|---|
| PouchDB | To implement an Offline-First strategy, which means the data is stored on the client and all pages can load immediately regardless of whether the user has a fast connection, slow connection, or no connection at all. The data is stored in PouchDB, which replicates changes back and forth in the background with the server CouchDB. |
| Enketo | To render configured xforms and help with styling and dynamic elements such as show/hide and validation rules. |
| ngx-bootstrap | To integrate Bootstrap components in the Angular application. |
| ngx-translate | To automatically translate the labels from a Angular application. Read more about how to configure translations. |
| Karma | A test runner for unit tests |
| MochaJS | A test framework to run the unit tests |
| WebDriverIO | To run the e2e tests |
| Less | A CSS preprocessor |
The CHT Web Application has the following high level structure:
App Management is an interface for non-technical administrative users to manage users and settings.
View the application source code in our GitHub repository.
App Management is a single page application built with AngularJS framework and implements Redux to manage a reactive state. Additionally, it uses the following technology:
| Technology | Usage |
|---|---|
| Angular Translate | To automatically translate the labels from a AngularJS application. Read more about how to manage translations. |
| Karma | A test runner for unit tests |
| MochaJS | A test framework to run the unit tests |
| WebDriverIO | To run the e2e tests |
| Less | A CSS preprocessor |
flowchart TD
subgraph webapp
webapp/online[/Online User\]
webapp/offline[/Offline User\]
webapp/cht-datasource/offline/pouch[PouchDB]
end
subgraph api
replication{Replication}
api/router(( ))
end
couchdb[(CouchDB)]
replication -->|POST medic/_bulk_get| couchdb
webapp/offline --> webapp/cht-datasource/offline/pouch -->|/api/replication| replication
webapp/online --> webapp/cht-datasource/offline/pouch -->|GET <_id>| api/router
api/router --> |GET <_id>| couchdb
flowchart TD
subgraph webapp
webapp/online[/Online User\]
webapp/offline[/Offline User\]
subgraph webapp/cht-datasource[cht-datasource]
webapp/cht-datasource/online/fetch[fetch]
webapp/cht-datasource/offline/pouch[PouchDB]
end
end
subgraph api
subgraph api/cht-datasource[cht-datasource]
api/cht-datasource/pouch[PouchDB]
end
replication{Replication}
end
couchdb[(CouchDB)]
api/cht-datasource/pouch -->|GET medic/<_id>| couchdb
webapp/offline --> webapp/cht-datasource/offline/pouch -->|/api/replication| replication
webapp/online --> webapp/cht-datasource/online/fetch -->|GET api/v1/person| api/cht-datasource
replication --> |POST medic/_bulk_get| couchdb
sequenceDiagram
participant webapp
participant api
participant couchdb
webapp ->>api: GET api/replicaiton/get-ids
api ->>couchdb: Query view <br />medic/docs_by_replication_key
couchdb ->>api: Returns docs for users hierarchy/shortcode
api ->>api: Filter our purged docs
api ->>webapp: Returns list of all doc ids/revs <br />accessible to the user
webapp ->>webapp: Compares with ids of all local docs
webapp ->>couchdb: POST medic/_bulk_get <br />(with the missing ids)
couchdb ->> webapp: Returns requested docs
webapp ->>api: POST api/v1/replication/get-deletes <br />(with local ids not returned from get-ids)
api <<->> couchdb: Uses allDocs to check deleted status
api ->>webapp: Returns list of docs to be deleted
webapp ->>webapp: Deletes docs
Monitoring and alerting system using Grafana and Prometheus
Data synchronization tools to enable analytics