The source of https://www.health-samurai.io/docs.
Run make init to set up the pre-push git hook. This hook will automatically run mandatory checks.
docker pull ghcr.io/healthsamurai/documentation:latest && docker run -p 8081:8081 \
-e BASE_URL=http://localhost:8081 \
-e DEV=true \
-e DOCS_PREFIX=/docs \
-e DOCS_REPO_PATH=/repo \
-e DOCS_VOLUME_PATH=/repo/docs-new \
-e PORT=8081 \
-e RELOAD_CHECK_INTERVAL_SEC=10 \
-e EXAMPLES_UPDATE_INTERVAL=1 \
-v $(pwd):/repo \
--rm ghcr.io/healthsamurai/documentation:latest
And go to http://localhost:8081/docs/aidbox.
Aidbox docs search:
- Run meilisearch.
docker-compose up -d meilisearch
- Index Aidbox docs from https://www.health-samurai.io/docs/aidbox.
make reindex-search
PORT=8081
Specifies the port number on which the documentation server will run. Default: 8081.
DEV=true
Enables development mode. When set to true, the server reads, parses and renders files on every request, allowing for live updates during development. Default: false.
BASE_URL=http://localhost:8081
The base URL of the documentation site. This is used in:
- Meta tags for SEO
- Sitemap generation
- robots.txt file
- Absolute URL construction
Default: http://localhost:8081.
DOCS_PREFIX=/aidbox
URL path prefix for documentation pages. The full URL of any page is constructed as:
FULL_URL = BASE_URL + DOCS_PREFIX + relative-url
This allows serving documentation under a subdirectory. Also used in meta tags, sitemap, and robots.txt.
Default: /aidbox.
VERSION=v1.0.0
Version identifier for the build. Used during the build process to tag the application version. If not specified, defaults to the short Git commit hash from the current HEAD.
Default: Git short commit hash (for example, a1b2c3d).
WORKDIR=/path/to/docs
Working directory for the build process. When specified, the build will copy files from this directory instead of the default docs directory. This is useful for building documentation from a custom location.
Default: Uses docs directory in the project root.
MEILISEARCH_URL=http://localhost:7700
Meilisearch URL.
Default: "http://localhost:7700"
MEILISEARCH_API_KEY=60DBZGy6zoDL6Q--s1-dHBWptiVKvK-XRsaacdvkOSM
Meilisearch API key.
Default: none
npm install
make tailwind
git submodule update --init --recursive
make repl
Go to dev/user.clj
Runs Meilisearch:
make up
This documentation system supports hosting multiple product documentation under a single deployment using the products.yaml configuration file.
How to add new product:
- Add new product in
docs-new/products.yaml. - Create
docs-new/<product-name>directory, which contains.gitbook.yamlfile anddocs/directory. - Set up
.gitbook.yaml. - Set up
docs-new/<product-name>/docs/SUMMARY.mdwith table of contents. - Add your markdown files to
docs-new/<product-name>/docs/directory. - Commit and push
Once the new version of gitbok is built and deployed by FluxCD, go to <domain>/<DOCS_PREFIX>/<product-name>.
When the product is deployed, we can set up search
The products.yaml file should be placed in the root of your documentation directory (for example, docs-new/products.yaml). Here's the structure:
root-redirect: "/aidbox"
products:
- id: aidbox
name: "Aidbox User Docs"
# url <BASE_URL><DOCS_PREFIX>/aidbox
path: /aidbox
config: aidbox/.gitbook.yaml
logo: .gitbook/assets/aidbox_logo.jpg
favicon: .gitbook/assets/favicon.ico
og-preview-text: "Aidbox User Docs" # Optional: custom text for OG preview images
meilisearch-index: "docs" # Meilisearch index name to search. See how to set up search below.
links:
- text: "Run Aidbox locally"
href: "/getting-started/run-aidbox-locally"
- text: "Run Aidbox in Sandbox"
href: "/getting-started/run-aidbox-in-sandbox"
- id: fhirbase
name: "fhirbase"
...Each product should have its own folder with the following structure:
docs-new/
├── products.yaml # Main products configuration
├── aidbox/ # Product folder (matches product.id)
│ ├── .gitbook.yaml # GitBook configuration
│ └── docs/ # Documentation content
│ ├── SUMMARY.md # Table of contents
│ └── ... # Other documentation files
└── fhirbase/ # Another product
├── .gitbook.yaml
└── docs/
└── ...
Each product needs a .gitbook.yaml file with the following structure:
root: ./docs/ # Root directory for documentation files
structure:
readme: README.md # Path to main README relative to root
summary: SUMMARY.md # Path to SUMMARY.md relative to root
redirects: # Optional: URL redirects
access-control/authentication/access-to-aidboxui: access-control/authentication/README.mdSUMMARY.md structure example:
# Table of contents
* [Overview](README.md)
* [Integrations](integrations/README.md)
* [Python](integrations/python.md)
* [.NET](integrations/net.md)
## Overview
* [Licensing and Support](overview/licensing-and-support.md)
...
- The system reads
products.yamlto discover available products. - Each product configuration is loaded from its respective
.gitbook.yaml. SUMMARY.md is loaded from the path provided by.gitbook.yaml. - URLs are constructed as:
BASE_URL + DOCS_PREFIX + product.path + page-path. - The
root-redirectoption (if specified) redirects the root URL to a specific product.
Go to run locally section, run locally as described, then go to localhost:8081/docs/<product-id>.
We use Meilisearch as a search engine. It is deployed in k8s (see k8s/meilisearch directory).
Every product has its own meilisearch index. To index the product documentation, we use Meilisearch docs-scraper.
Every hour (depends on a product) we scrap the html from <domain>/<DOCS_PREFIX>/<product>/sitemap.xml and recreate the index.
See k8s/meilisearch/cronjob-reindex.yaml cronjob.
You need a deployed documentation website to set up a search, because we create search index through parsing the HTML of a product documentation. Setting up search means to create Meilisearch index using Meilisearch docs-scraper.
Here's the instruction how to add meilisearch docs-scraper config and set k8s cronjob.
- Add scraper config.
cp k8s/meilisearch/config.json k8s/meilisearch/config-<your-product>.json
- Make sure that
index_uidis the same asmeilisearch-indexfrom the products.yaml file. - Change
start_urlsandsitemap_urls. - Add reindex cronjob
cp k8s/meilisearch/cronjob-reindex.yaml k8s/meilisearch/cronjob-reindex-<your-product>.yaml
Update the following fields:
metadata.name:meilisearch-reindex-<your-product>spec.schedule: adjust if you wantenv[].INDEX_NAME: set to your index name (same asindex_uidin config)volumes[].config.configMap.name:meilisearch-scraper-config-<your-product>
Example:
metadata:
name: meilisearch-reindex-<your-product>
spec:
schedule: "45 * * * *" # Adjust timing
# ...
env:
- name: INDEX_NAME
value: "<your-index-name>"
# ...
volumes:
- name: config
configMap:
name: meilisearch-scraper-config-<your-product>Note: The cronjob uses shared resources:
configmap-reindex-env.yaml: common Meilisearch URLconfigmap-reindex-script.yaml: reindex script that ensures the update is atomicmeilisearch-secret: API key
- Add scraper config to
k8s/meilisearch/kustomization.yaml
Update configMapGenerator section:
configMapGenerator:
- name: meilisearch-scraper-config-<your-product>
files:
- config.json=config-<your-product>.json- Commit and push, wait until FluxCD applies it
You can also try it locally:
- Run
make upto run meilisearch fromdocker-compose.yaml docker-compose run -v ./k8s/meilisearch/config-<your-product>.json:/docs-scraper/config.json --rm docs-scraper- GET http://localhost:7700/indexes/ (Authorization: Bearer 60DBZGy6zoDL6Q--s1-dHBWptiVKvK-XRsaacdvkOSM)