Skip to content

๐Ÿงฉ Services

This section provides an overview of the services included in the CogStack-NiFi deployment. Services run in Docker and are attached to the relevant Compose network when they need to communicate.


๐Ÿ“Š Overview

Below is a high-level architecture diagram illustrating how CogStack services communicate when all components are enabled:

nifi-services


๐Ÿงฉ Primary Services

The core services defined in services.yml include:

  • samples-db โ€” PostgreSQL database populated with demo datasets.
  • cogstack-databank-db / cogstack-databank-db-mssql โ€” Production-grade PostgreSQL and optional MSSQL instances.
  • elasticsearch-1 / elasticsearch-2 / elasticsearch-3 โ€” Multi-node Elasticsearch or OpenSearch cluster.
  • metricbeat / filebeat โ€” Elastic monitoring and log-forwarding services.
  • nifi โ€” Apache NiFi single-node instance with embedded ZooKeeper.
  • nifi-nginx โ€” Reverse proxy providing secure access to NiFi.
  • kibana โ€” Kibana or OpenSearch Dashboards, depending on the backend.
  • gitea โ€” Self-hosted Git service.

Additional services, including MedCAT, MedCAT Trainer, OCR, and JupyterHub, are started from Compose files in their respective services/ directories.

๐Ÿ” Note: Core-service configuration is managed in services.yml and the associated environment files under deploy/ and security/env/.

๐Ÿ—‚๏ธ Service Definitions

All core services are defined in:

deploy/services.yml

They run inside the internal Docker network cognet.
Some services expose ports to the host for convenience.


๐Ÿ—ฃ๏ธ NLP/OCR and other services API Endpoints

Most web ETL and data-enrichment APIs provide some or all of these endpoints:

  • GET /api/info
  • POST /api/process
  • POST /api/process_bulk

Useful for NiFi workflows (see workflows).


๐Ÿงฌ MedCAT Service

This REST API uses the MedCAT library for clinical concept extraction and linking.

The service has two operation modes:

  • Concept detection extracts medical concepts and returns the original text with annotations.
  • De-identification (AnonCAT) returns de-identified text.

Access

  • http://localhost:5555/api/info โ€” concept extraction service
  • http://localhost:5556/api/info โ€” de-identification service

Containers

  • cogstack-medcat-service-production - for concept NER
  • cogstack-medcat-service-production-deid - for DE-ID/AnonCAT

Service location & files

  • directory: services/cogstack-nlp/medcat-service/
  • Docker Compose file: services/cogstack-nlp/medcat-service/docker/docker-compose.yml
  • env: located in services/cogstack-nlp/medcat-service/env/

  • app.env โ€” application settings for the concept extraction service

  • medcat.env โ€” MedCAT settings for concept extraction
  • app_deid.env โ€” application settings for de-identification
  • medcat_deid.env โ€” MedCAT settings for de-identification

Ports

Service External Port Internal Port
NER (MedCAT) 5555 5000
DE-ID / AnonCAT 5556 5000

Models

  • A default MedMentions MedMen NER+L model (includes MetaCAT models) is available for public use but needs to be downloaded.
  • To download it, go to services/cogstack-nlp/medcat-service/scripts and run bash download_medmen.sh.

README

Please check the service's own README.md


๐Ÿ› ๏ธ MedCAT Trainer

Provides UI workflows for annotation, correction, and iterative model training.

Access

  • http://localhost:8001

Containers

  • medcattrainer
  • medcattrainer_nginx
  • mct_solr

Service location & files

  • dir: services/cogstack-nlp/medcat-trainer/
  • docker compose file: services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml
  • env: services/cogstack-nlp/medcat-trainer/envs/env-prod

Ports

  • external: 8001

README

Please check the service's own README.md file and docs.


๐Ÿ“š Jupyter Hub

A multi-user JupyterHub instance deployed via Docker.

Access

  • https://localhost:8888

Containers

  • cogstack-jupyter-hub
  • cogstack-jupyter-singleuser-<USERNAME> (per user container started by each user once hub is up)

Service location & files

  • dir: services/cogstack-platform/apps/cogstack-jupyter-hub/
  • docker compose file: services/cogstack-platform/apps/cogstack-jupyter-hub/docker/
  • env: services/cogstack-platform/apps/cogstack-jupyter-hub/env/jupyter.env

Supports

  • Per-user containers
  • CPU/RAM limits (via services/cogstack-platform/apps/cogstack-jupyter-hub/env/jupyter.env)
  • Optional GPU support
  • Notebook image selection

Ports

Component External Port Internal Port(s)
JupyterHub 8888 8087, 443

README

Please check the service's own README.md file.


๐Ÿงช Samples DB (PostgreSQL)

Demo dataset with:

  • patients
  • encounters
  • observations
  • raw medical reports
  • cleaned reports
  • annotation tables

The bootstrap script, schemas, and compressed dumps are supplied together through one read-only mount of services/pgsamples/ at /docker-entrypoint-initdb.d. The loader resolves its input paths relative to that directory. Set POSTGRES_SAMPLES_DB_NAME in deploy/database.env to choose the sample database name; Compose passes it to the official image as POSTGRES_DB.

TLS is required by default. Run make -C deploy init-security-postgresql (or init-security) before starting the service. The sample JDBC URL verifies the server certificate and hostname using the CA mounted into NiFi.

Access

  • localhost:5554

Ports

  • external: 5554
  • internal: 5432

Credentials

Local development credentials are defined in security/env/users_database.env. Override them for non-local deployments.

NiFi uses the read-only POSTGRES_INGEST_USER_SAMPLES account rather than the bootstrap administrator. See Docker database security for credential configuration, existing-volume upgrades, and TLS.


๐Ÿฆ Cogstack databank production DB (Production only: PgSQL, MSSQL)

Empty database for production ingestion pipelines.
Supports both PostgreSQL and MSSQL.

Place schema files inside:

services/cogstack-db/<DB_PROVIDER>/schemas/

Where <DB_PROVIDER> can be mssql or pgsql.

PostgreSQL applies its initialization SQL only when its data volume is first created. Compose sets POSTGRES_DB from DATABASE_DB_NAME, and the official PostgreSQL entrypoint creates the database before running the bundled loader. PostgreSQL requires TLS by default; generate its certificate bundle with make -C deploy init-security-postgresql (also included in init-security) or provide a trusted bundle through POSTGRES_DATABANK_TLS_DIR. SQL Server runs as the main process in its own container; a separate cogstack-databank-db-mssql-init client job waits for a successful query, creates the configured database if needed, applies cogstack_db*.sql files in filename order, and then applies annotations_nlp_create_schema.sql. SQL errors fail the job instead of being hidden by a sleeping server wrapper.

Start SQL Server and wait for initialization to finish with:

make -C deploy start-production-db-mssql

Use make -C deploy stop-production-db-mssql to stop it without removing data. For direct Compose use, load deploy/export_env_vars.sh and start both cogstack-databank-db-mssql and cogstack-databank-db-mssql-init. Starting only the server does not run the initializer.

The job uses DATABASE_DB_NAME and POSTGRES_DB_SCHEMA_PREFIX from the shared database configuration. Its readiness wait defaults to 60 attempts, two seconds apart (each connection attempt has a five-second login timeout). Override MSSQL_INIT_RETRIES and MSSQL_INIT_RETRY_DELAY_SECONDS in the initializer's environment if necessary. The bundled tables use the CogStack SQL schema within the selected database. The job always requests TLS. The development default MSSQL_TRUST_SERVER_CERTIFICATE=true accepts the self-signed server certificate; set false with a trusted CA to enable certificate verification.

Bundled MSSQL initialization preserves existing tables and data on repeat runs. It does not alter existing column definitions. Apply explicit migrations when updating an existing schema, and make any site-specific initialization SQL safe to rerun. SQL files stay mounted read-only so on-premises operators can maintain them independently of the database image.

Each initializer uses one read-only bootstrap directory:

Service Host directory Container directory
samples-db services/pgsamples/ /docker-entrypoint-initdb.d
cogstack-databank-db services/cogstack-db/pgsql/ /docker-entrypoint-initdb.d
cogstack-databank-db-mssql-init services/cogstack-db/mssql/ /bootstrap

The MSSQL job executes /bootstrap/init_db.sh and reads /bootstrap/schemas/ by default. PostgreSQL reads its loader's sibling schemas/ directory, plus db_dump/ for samples. These directories stay editable on the host. Updating mounted SQL does not automatically migrate existing PostgreSQL databases.

Storage and memory

  • PostgreSQL retains the existing databank-vol volume.
  • SQL Server uses its own databank-mssql-vol volume at /var/opt/mssql.
  • The shared DATABASE_DOCKER_RAM default is 2g, including the sample database.

Existing deployments that stored MSSQL files in the formerly shared databank-vol must back up and restore their MSSQL databases into the dedicated volume before switching. No existing volumes are automatically moved or deleted.

Credentials

PostgreSQL and MSSQL development credentials are defined in security/env/users_database.env. Production credentials must be injected through deployment-local configuration or a secret manager.

Applications use the separate DATABASE_INGEST_USER and MSSQL_INGEST_USER accounts. Their grants cover read/write access to application tables, without database or schema administration. Host ports default to loopback. See Docker database security for scope, provisioning, network overrides, and verified TLS deployment.

Access

  • PgSQL: localhost:5558 โ†’ container 5432
  • MSSQL: localhost:1433 โ†’ container 1433

Containers

  • PgSQL: cogstack-production-databank-db
  • MSSQL: cogstack-production-databank-db-mssql

Service location & files

  • docker compose file: services.yml
  • dir: services/cogstack-db/
  • env:
  • security/env/users_database.env - database development credentials
  • deploy/database.env - general DB configs

Ports

Database External Port Internal Port
PgSQL 5558 5432
MSSQL 1433 1433

๐Ÿ’ง Apache NiFi

Primary ETL/processing engine.

This service is complex and is completely described in this section.

Credentials

Single-user development credentials are defined in security/env/users_nifi.env. Do not reuse them in production.

Access

https://localhost:8443 (via nifi-nginx)

Containers

  • NiFi: cogstack-nifi
  • nginx: cogstack-nifi-nginx

Service location & files

  • docker compose file: services.yml
  • dir: nifi/
  • env:
  • deploy/nifi.env - general NiFi settings, JVM memory, etc.
  • security/env/users_nifi.env - NiFi development credentials
  • security/env/certificates_nifi.env - NiFi keystore and truststore settings

Ports

Component External port Internal port
NiFi via nginx 8443 8443
NiFi direct access 8082 8443

The NiFi container also publishes its input socket on container port 10000 without assigning a fixed host port. Use docker compose port nifi 10000 from the deploy/ directory to see the assigned host port.


๐Ÿ”Ž ELK Stack (Elasticsearch / OpenSearch)

Backend search and indexing engine powering document storage, query, analytics, and NLP output retrieval.

This service is fully described in the Elasticsearch section of the documentation.

The repo supports both:

  • Elasticsearch (native)
  • OpenSearch (Amazon fork)

Switch between modes via environment variables in deploy/elasticsearch.env.

๐Ÿ›ข๏ธ Elasticsearch / OpenSearch

Credentials

Development credentials for both backends are defined in security/env/users_elasticsearch.env. Use externally managed secrets for production deployments.

Access

  • https://localhost:9200 โ€” Node 1
  • https://localhost:9201 โ€” Node 2
  • https://localhost:9202 โ€” Node 3

Containers

  • elasticsearch-1
  • elasticsearch-2
  • elasticsearch-3

Ports

The example Compose deployment assigns distinct host ports to nodes running on the same machine. Do not expose transport or analyzer ports through a public firewall. For a production multi-host cluster, allow only the required traffic between trusted cluster nodes.

Node HTTP Transport Analyzer
ES1 ${ELASTICSEARCH_NODE_1_OUTPUT_PORT:-9200} ${ELASTICSEARCH_NODE_1_COMM_OUTPUT_PORT:-9300} ${ELASTICSEARCH_NODE_1_ANALYZER_OUTPUT_PORT:-9600}
ES2 ${ELASTICSEARCH_NODE_2_OUTPUT_PORT:-9201} ${ELASTICSEARCH_NODE_2_COMM_OUTPUT_PORT:-9301} ${ELASTICSEARCH_NODE_2_ANALYZER_OUTPUT_PORT:-9601}
ES3 ${ELASTICSEARCH_NODE_3_OUTPUT_PORT:-9202} ${ELASTICSEARCH_NODE_3_COMM_OUTPUT_PORT:-9302} ${ELASTICSEARCH_NODE_3_ANALYZER_OUTPUT_PORT:-9602}

Service Location & files

  • docker compose: deploy/services.yml
  • config: services/elasticsearch/config/
  • env:
  • deploy/elasticsearch.env
  • security/env/certificates_elasticsearch.env
  • security/env/users_elasticsearch.env

SSL & Certificates

Certificates stored in:

security/certificates/elastic/<ELASTICSEARCH_VERSION>/

Settings in:

  • security/env/certificates_elasticsearch.env

๐Ÿ“Š Metricbeat & Filebeat

Lightweight Elastic stack agents used for monitoring and log forwarding.
They run alongside Elasticsearch to provide observability of the cluster and ingestion pipelines.

Purpose:

  • Metricbeat โ€” collects system & Elasticsearch metrics (CPU, memory, JVM, node health).
  • Filebeat โ€” ships container and service logs into Elasticsearch.

Both run as independent containers in the deployment.

Containers

Metricbeat:

  • cogstack-metricbeat-1
  • cogstack-metricbeat-2
  • cogstack-metricbeat-3

Filebeat:

  • cogstack-filebeat-1
  • cogstack-filebeat-2
  • cogstack-filebeat-3

Service Location & Files

  • compose: deploy/services.yml
  • config:
  • services/metricbeat/metricbeat.yml
  • services/filebeat/filebeat.yml
  • env:
  • deploy/elasticsearch.env
  • security/env/users_elasticsearch.env

Ports

No external ports exposed.
All communication occurs internally within the cognet Docker network.

Notes

  • Elasticsearch must be running before Metricbeat or Filebeat start.
  • Only Elastic-native Beats are available; OpenSearch-native Beats do not exist.
  • Authentication credentials come from security/env/users_elasticsearch.env.

๐Ÿ“‰ Kibana / OpenSearch Dashboards

Web UI for exploring indexed data, visualising documents, managing index templates, monitoring the cluster, and debugging ingestion pipelines.

Purpose:

  • Search & browse Elasticsearch/OpenSearch indices
  • Visualise ingestion outputs and cluster metrics
  • Manage index patterns, dashboards, and Dev Tools
  • Validate mappings and test queries used in NiFi flows

Host Access

  • URL: https://localhost:5601

Credentials

Dashboard development credentials are defined in security/env/users_elasticsearch.env. Never use the public development values for an exposed deployment.

First login setup (OpenSearch Dashboards)

After signing in to OpenSearch Dashboards:

  1. Open the user menu and choose Switch tenant.
  2. Select Global so saved objects are shared across users/roles.
  3. Go to Stack Management โ†’ Workspaces and click Create workspace.
  4. Create a workspace (for example cogstack-main) in the Global tenant.
  5. Create data views/dashboards in that workspace.

Private tenant is isolated per user and should be avoided for shared environments.

Containers

  • cogstack-kibana (OpenSearch Dashboards or Kibana depending on configuration)

Service Location & Files

  • docker compose: deploy/services.yml
  • config files:
  • services/kibana/config/elasticsearch.yml (Elasticsearch)
  • services/kibana/config/opensearch.yml (OpenSearch Dashboards)
  • env:
  • deploy/elasticsearch.env
  • security/env/certificates_elasticsearch.env
  • security/env/users_elasticsearch.env

Image selection controlled by:

  • ${ELASTICSEARCH_KIBANA_DOCKER_IMAGE}
  • ${KIBANA_VERSION}
  • ${KIBANA_CONFIG_FILE_VERSION}

Ports

Component External Internal
Kibana / OpenSearch Dashboards 5601 5601

Notes

  • Must be started after Elasticsearch/OpenSearch
  • Connects automatically using ELASTICSEARCH_HOSTS
  • TLS/user settings are applied from the /security env files

๐Ÿค– OpenSearch AI with SGLang

To connect OpenSearch Dashboards AI features to an existing SGLang server, see the OpenSearch AI with SGLang deployment guide.


๐Ÿค– OCR Service

High-performance document text-extraction engine for OCR and text processing.

The service comes in two variants:

  • ocr-service โ€” full OCR pipeline (images โ†’ text)
  • ocr-service-text-only โ€” lightweight mode (text extraction only, no OCR)

Both expose a simple REST API.

Purpose:

  • Extract text from PDFs, images, and scanned documents
  • Provide OCR via Tesseract (wrapped in optimised Python service)
  • Provide fast plain text extraction for digital PDFs (text-only variant)
  • Designed for large-scale throughput within NiFi ingestion pipelines

Access

  • ocr-service: http://localhost:8090/api/process
  • ocr-service-text-only: http://localhost:8091/api/process

Containers

  • ocr-service
  • ocr-service-text-only

Both built from:

cogstacksystems/cogstack-ocr-service:<release>

Service Location & Files

  • Docker Compose files: services/cogstack-platform/apps/ocr-service/docker/docker-compose.base.yml and services/cogstack-platform/apps/ocr-service/docker/docker-compose.prod.yml
  • service directory: services/cogstack-platform/apps/ocr-service/
  • logs:
  • Host: services/cogstack-platform/apps/ocr-service/log/
  • Container: /ocr_service/log/

  • env files:

  • deploy/general.env โ€” shared variables
  • services/cogstack-platform/apps/ocr-service/env/ocr_service.env โ€” full OCR config
  • services/cogstack-platform/apps/ocr-service/env/ocr_service_text_only.env โ€” overrides for text-only pipeline

Ports

Service External Internal
ocr-service 8090 8090
ocr-service-text-only 8091 8090

Both expose the API internally on port 8090.

Please check the service's own README.md


๐Ÿ—‚๏ธ Gitea

Self-hosted Git instance (Gitea). Lightweight GitHub/GitLab-style service used for hosting repositories inside secure or offline environments.

Purpose:

  • Internal code hosting for organisations without external Git access
  • Repository management, issue tracking, wiki, and basic CI hooks
  • Ideal for notebooks, configs, workflows, and internal project code

Access

  • URL: https://localhost:3000 (default local Gitea port)

Containers

  • cogstack-gitea

Service Location & Files

  • docker compose file: deploy/services.yml
  • config file: services/gitea/app.ini
  • certificate directory: security/certificates/gitea/

Persistent repository data is stored in the volume defined in services.yml.

Ports

Service External Internal
Gitea 3000 3000

Notes

  • Supports repository migration from external Git servers
  • Mirroring available when external access is allowed
  • Uses a dedicated CogStack-signed Gitea leaf certificate for local HTTPS

๐Ÿงฑ NGINX

NGINX is used as a lightweight reverse proxy to provide HTTPS access to NiFi. MedCAT Trainer has a separate nginx instance in its own Compose project.

Purpose:

  • nifi-nginx terminates TLS and proxies NiFi UI and API traffic.
  • medcattrainer_nginx proxies the MedCAT Trainer application separately.

Access

Examples (actual paths depend on config):

  • NiFi: https://localhost:8443
  • MedCAT Trainer: http://localhost:8001

Routing rules are defined in the NGINX configuration files.

Containers

  • cogstack-nifi-nginx โ€” proxy for NiFi
  • medcattrainer_nginx โ€” proxy for MedCAT Trainer

Service Location & Files

  • NiFi Compose file: deploy/services.yml
  • MedCAT Trainer Compose file: services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml
  • config files:
  • services/nginx/config/nginx.conf.template
  • services/cogstack-nlp/medcat-trainer/nginx/nginx.conf
  • services/cogstack-nlp/medcat-trainer/nginx/sites-enabled/
  • env / certificates:
  • security/env/certificates_general.env
  • security/env/certificates_nifi.env
  • Uses the NiFi leaf certificate for server TLS and root-ca.pem as a trust anchor. The root CA private key is not mounted as a service key.

Port

Proxy Target External Internal
NiFi 8443 8443

Notes

  • Provides HTTPS entrypoints for internal services
  • Works with CogStack certificate bundle
  • Trainer uses a separate NGINX instance for routing differences
  • Modify NGINX configs only if comfortable with its syntax